Sign in to follow this  

Mouse-model movement in 3D

This topic is 3869 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

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
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

This topic is 3869 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.

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