move 3D Cam with mouse

Started by
3 comments, last by noNchaoTic 17 years, 4 months ago
How would I move a 3D cam with a mouse (how can I yaw & pitch the cam, based on how I move the mouse), can you please explain any formulas you provide, i asked this question before but I wanna understand how it works. Thanks

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

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

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

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!
Steven ToveySPUify | Twitter
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.
Steven ToveySPUify | Twitter

This topic is closed to new replies.

Advertisement