0

I have 3D animation and display it on Raw Image. The animation was quite ok testing on 3D plane, now changed to 2D Raw Image, then I am a bit weird about origins of GameObjects.

On 3D plane, animation models have origin on the ground between two legs. Once changed to 2D Raw Image, the origin is shifted to chest. The first image is on 3D plane and the second is on 2D Raw Image.

enter image description here enter image description here

All other position of club handle, club shaft and club head are also shifted to chest.

enter image description hereenter image description here

When I print the (x,y,z) position of club head, I have 374.9705,741.7168,-0.4869962. They should be less than 2 in 3D plane and less than 2 is correct.

How I run 3D animation on 2D Raw Image is discussed here and stated below

(1)Put the object in a specific layer (called MyLayer for the sake of the example)
(2)Set the Culling mask of a new camera to render only this specific layer
(3)Uncheck the MyLayer in the Culling mask of your main camera in order to prevent the latter to render your model
(4)Create a new Render texture in the project, and drag & drop it in the Render Texture field of your new Camera
(5) Add a new Raw Image to your UI canvas and assign the render texture in the Texture field
(6)Run my 3D animation

How can I have position of clubhead same as in my previous 3D plane?

I can't shift the origin, when I drag the whole GameObject is also shifted.

EDIT:

Let me add in why I run animation on RawImage is I need to display 3D animation on 2D canvas. For that I need Raw Image and RenderTexture to run 3D animation. Please see the below image.

enter image description here

EDIT 1:

I take out of the canvas, but I don't see my model at the scene view to set the position. Why I can't see my model.

I see the model on the preview of my RawImage, but not at the scene.

enter image description here

enter image description here

DisplayCamera can see the model, but when I run I don't see model on the greencanvas too.

enter image description here

batuman
  • 7,066
  • 26
  • 107
  • 229
  • Do you want to change the pivot of gameobject? If so you can do it only in 3d editors. Or maybe you could find some asset that does that for you, but there isnt a way in standard unity. – Arman Papikyan Oct 29 '17 at 16:55
  • I assume that the image at the top shows golfer in world coordinates and the image at the bottom shows the origin of the golfer image relative to other ui components. Your model does not need to be child of RawImage. Think that you are watching golf from tv. You can change position of the tv in your living room (=change position of RawImage in UI), but the golfers don't need to move anywhere. The position of the golfer in the tv screen depends on what camera sees. – Mikko Koivisto Oct 29 '17 at 20:58
  • @MikkoKoivisto thank you. I added more information in EDIT. Running on 3D plane is in world coordinate and yes, the origin of golfer is relative to other UI components. So that I have difficulty to get position of club head. Why I need to do that is, that 3D animation needs to run on 2D canvas. How can I have position of clubhead? – batuman Oct 30 '17 at 01:30
  • @ArmanPapikyan whch kind of 3D editors and how can I do that? – batuman Oct 30 '17 at 01:31
  • @ArmanPapikyan Basically is I need to know the positions of clubpath. – batuman Oct 30 '17 at 01:36
  • @batuman The 3d model and the image that it is rendered on are 2 different things. Currently your model is somewhere at the middle of the image and it looks tiny in comparison with it (canvas is 1400 units high and the golfer model im guessing 1 or 2 units). As Mikko said you can move the 3d model anywhere (from `374,741,0` to `0,0,0` for example), along with the camera that renders it, and things should still look the same on the rawimage. – Pluto Oct 30 '17 at 02:57
  • @Pluto thanks now I understand a bit. As I am new, I can't understand immediately. I need more discussion. What I need to do is move the model to 0,0,0 position together with DisplayCamera. So that clubhead will be within 2 units. I don't get one point, you said canvas is 1400 and model is 1 or 2 units. 1400 is I set for iPhone6 resolution. Now model is half of the canvas, how you can tell model is 1 or 2 units? – batuman Oct 30 '17 at 04:24
  • @batuman You mentioned that "The animation was quite ok testing on 3D plane". You can drag your model and DisplayCamera out from Canvas (so that they are at the same level as Main Camera , lights etc.). Then you can set position and scale as they were "on 3D plane". Then you can do the animation as you would do it "on 3D plane". Golfer model should still be rendered on GreenCanvas. If not, check that DisplayCamera sees the golfer. – Mikko Koivisto Oct 30 '17 at 05:06
  • "how you can tell model is 1 or 2 units?" I assumed the model z position is `0` so if the club head is at z `-0.48` the whole thing must be ~2 units. If you double click on `Model` in the hierarchy unity will zoom in on the actual 3D model. You can try dragging `Model` outside the canvas in the hierarchy so it is no longer a child of it, and change its position to `0,0,0`. Don't forget to change the position of the camera that renders the model also. – Pluto Oct 30 '17 at 05:06
  • @MikkoKoivisto thank you. I'll test for that. – batuman Oct 30 '17 at 06:13
  • @Pluto thanks a lot, let me try. – batuman Oct 30 '17 at 06:14
  • Have you tried using a RenderTexture for this? – Serkan Pekçetin Oct 30 '17 at 06:27
  • @SerkanPekçetin yes I have RenderTexture set to RawImage, also to DisplayCamera. – batuman Oct 30 '17 at 06:40
  • @MikkoKoivisto, I have added new EDIT1. Why I don't see model on the scene view? – batuman Oct 30 '17 at 07:03
  • @Pluto, I took out of the canvas, but I don't see my model on the scene view. I have added EDIT1. thank you – batuman Oct 30 '17 at 07:05
  • @batuman. I don't know why you don't see model. Your RawImage UI component should now be under GreenCanvas (and under Canvas) and Model and DisplayCamera should be outside Canvas. Did you accidentally move RawImage out from Canvas? What kind of GameObject is ModelImage? – Mikko Koivisto Oct 30 '17 at 07:36
  • @MikkoKoivisto Hi I took out to the same level as MainCamera. So this ModelImag( Raw Image, the place 3D animation is to be rendered) is no more under Canvas. Is this correct? Please see Hierarchy view in EDIT1. – batuman Oct 30 '17 at 07:51
  • @MikkoKoivisto, now ok, I just need to take out ModelImage just out of GreenCanvas. Thank you – batuman Oct 30 '17 at 07:56
  • @batuman. Drag Model and DisplayCamera out from ModelImage. Then put ModelImage back into canvas. If you need common transform for Model and DisplayCamera, you can make new empty gameobject or set camera as child of Model. – Mikko Koivisto Oct 30 '17 at 08:02

0 Answers0