Skip to main content
GameDev.net gamedev.net
🔒 Locked

Getting started with mouselook

Started by tbecker82 Feb 16, 2005 at 12:42 PM 1 replies 450+ views
Original Post
tbecker82
tbecker82
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
hplus0603
hplus0603
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.
enum Bool { True, False, FileNotFound };
tbecker82
tbecker82
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?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.