Sign in to follow this  
tbecker82

Getting started with mouselook

Recommended Posts

tbecker82    122
Hey Im trying to implement mouselook in my program. I currently have a class that will handle sliding along the axes, as well as yaw, roll, and pitch from keyboard input. Are there any good tutorials out there that can get me started, or if someone already has some code they wouldnt mind letting me take a look at I would apprecite it. Thanks

Share this post


Link to post
Share on other sites
hplus0603    11356
Typically, in mouselook, you will keep track of two variables: heading, and pitch. There is no explicit roll (you're always standing).

When you receive mouse input, you just apply the difference between the new position and the old position (mouse delta) to heading (for the X axis) and pitch (for the Y axis), by applying some scaling (for sensitivity).

When you want to get the camera orientation (each frame), you first rotate around the X axis by your pitch variable, and then rotate around the Y axis by your heading variable, and then you're done.

Share this post


Link to post
Share on other sites
tbecker82    122
Thanks Hplus for the reply. Do you know of any way that you can lock the mouse into the middle of the screen so that when the mouse will move, the screen will stay centered?

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