• Advertisement
Sign in to follow this  

move 3D Cam with mouse

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

Advertisement
Have you implemeneted 3d camera rotation using the keyboard yet? It's ok if you haven't I am just wondering if your question is more about mouse input, or more about rotations.

Share this post


Link to post
Share on other sites
Quote:
Original post by CandleJack
Have you implemeneted 3d camera rotation using the keyboard yet? It's ok if you haven't I am just wondering if your question is more about mouse input, or more about rotations.


yeah I got it working with keyboard keys and I generally know how to use rotation matrices, so i just need the method of how to transform mouse movements into 3D rotations. btw im not using quaternions.

Share this post


Link to post
Share on other sites
The way I did it was to set the mouse to center of the window upon application start, then when you detect a mousemove windows message (i am assuming windows here), then you subtract that position from the center to get the amount moved, then you scale some angle by the amount moved. To rotate up and down, you simply perform a rotation on the cameras view direction about its right vector (don't forget to do a cross product to update the up vector). Then, to handle movement of the mouse in the X axis, you just do a rotate around the world space up vector i.e.: (0, 1, 0). You don't rotate about the cameras up vector since this will cause unwanted roll. Hope this helps!

Share this post


Link to post
Share on other sites
also, don't forget to reset the deltas every time you handle the rotation in the camera, and also reposition the mouse back to the center everytime it moves! otherwise you'll just keep spinning around... which sucks.

Share this post


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

  • Advertisement