Sign in to follow this  
VanillaSnake21

move 3D Cam with mouse

Recommended Posts

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

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