• Advertisement
Sign in to follow this  

Moving in a 3D scene

This topic is 4306 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello i've got the following prob: i loaded a scene from a .x file an displayed it. now i am trying to move but with the matrices i've set i do not get the correct results. The prob is that when i want tu turn around the cam always rotates around the origin. i think it is because of the vector i use as "look at point" for D3DXMatrixLookAtLH. I really do not know what point i have to use for this. So can anybody tell me how i can get this point?

Share this post


Link to post
Share on other sites
Advertisement
If the rotation is messed up it could be because of a phenomenon called Gimbal look maybe you heard of (http://en.wikipedia.org/wiki/Gimbal_lock). You could help it whit using Quaternions instead of vectors when rotating, there is a toolbox full of Quaternion operation in D3DX library. Also maybe you don't update your eye point?

Share this post


Link to post
Share on other sites
the eye point i do update but as i said i do not know what to do with the "look at point"

i think i need a point as "look at point" which is in front of the eyepoint so i only need a way to get such a point...?

Share this post


Link to post
Share on other sites
Quote:
Original post by madRenEGadE
the eye point i do update but as i said i do not know what to do with the "look at point"

i think i need a point as "look at point" which is in front of the eyepoint so i only need a way to get such a point...?


OK, so you just moving your eye point around. Use a unit vector, add this to the eye point and use this for look at point. Transform the unit vector everytime you transform the eyepoint. Hopefully it work

Share this post


Link to post
Share on other sites
so i only have to do something like this: eyepoint + unitvector?

if so how can i get the unit vector because i am not very good at math but i think
i have to take the angle that i use for rotation am i right?

Share this post


Link to post
Share on other sites
Quote:
Original post by madRenEGadE
so i only have to do something like this: eyepoint + unitvector?

if so how can i get the unit vector because i am not very good at math but i think
i have to take the angle that i use for rotation am i right?


D3DXVECTOR4 eyepoint = D3DXVECTOR4(5.0f,5.0f,5.0f,0.0f);
D3DXVECTOR4 lookatpoint = D3DXVECTOR4(0.0f,0.0f,0.0f,0.0f);
D3DXVECTOR4 lookatvector;
D3DXVec4Normalize(&lookatvector,&(lookatpoint-eyepoint));


Then update the lookatvector everytime you move, use 4-components vector so the vector is'nt affected whit translations

Share this post


Link to post
Share on other sites
Quote:

D3DXVECTOR4 eyepoint = D3DXVECTOR4(5.0f,5.0f,5.0f,0.0f);
D3DXVECTOR4 lookatpoint = D3DXVECTOR4(0.0f,0.0f,0.0f,0.0f);
D3DXVECTOR4 lookatvector;
D3DXVec4Normalize(&lookatvector,&(lookatpoint-eyepoint));


We want to calulate a lookatpoint but that code just choses 0|0|0.
You'd be doing sth like: a=a-b+b if you use that code for th view directionvector/unit vector.
if you want a usual first person camera:here is a nice tutorial that explains how to implement one.

regards,
m4gnus

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement