Sign in to follow this  
tonyoto

Mouse-model movement in 3D

Recommended Posts

tonyoto    122
Hi, I'm doing this model viewer experiment and I recently implemented a camera. Before, when moving the model, I could just map mouse x/y movement to the model x/y position. Now, when I rotate the camera say 90 degrees to the right, when I move the mouse right/left the model actually moves towards/from the camera, which is kind of logical considering camera x-axis now is world z-axis. Could someone please explain the best way to translate camera space mouse movements to world space so that the model always moves relative to the mouse movements regardless of the rotation/position of the camera? Thanks.

Share this post


Link to post
Share on other sites
Zanshibumi    334
You have to transform the movement vector by the the camera rotation matrix.

In xna it would be something like:

positionVector += Vector3.transform(
right/left/etc vector,
matrix.createfromquaternion(camerarotationquaternion));

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this