Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

First Person Camera Proper Mouse Input

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 bpx95   Members   

102
Like
0Likes
Like

Posted 08 January 2012 - 04:04 AM

I am wondering the best way to retrieve and handle mouse input for a first person camera. The idea is that the speed at which the camera turns does not depend on frame rate, i.e. 30 FPS plays the same as 1000 FPS.

One way to do this:

Record cursor position each frame
Reset cursor position to middle of window each frame
Scale that by some constant

Theoretically, this would produce constant camera speed, because the mouse would move more each frame at a lower frame rate, and move less at a higher frame rate. However, this doesn't work because at high frame rates, it is very possible that the cursor will move less than a pixel each frame, and you would get no movement.

How do you implement first person cameras?

If you use the mentioned method, how do you get around the flaws?

#2 Erik Rufelt   Members   

5901
Like
2Likes
Like

Posted 08 January 2012 - 08:53 AM

If the mouse hasn't moved you can't move the camera. I think the method you describe is the one usually used. On Windows you can use raw mouse input instead of reading and resetting the cursor position, which should have better resolution. http://msdn.microsoft.com/en-us/library/windows/desktop/ms645536(v=vs.85).aspx

#3 Xcrypt   Members   

154
Like
0Likes
Like

Posted 08 January 2012 - 10:35 AM

The method you describe is a common way to create one. I think (not sure) you can use DirectInput to get more accurate mouse movement input.

#4 compscialien   Members   

104
Like
0Likes
Like

Posted 09 January 2012 - 02:22 AM

If the application is windowed, you have to reset the cursor, else, you can just read in the raw mouse coordinates, and use those against the old values to find the delta values to use.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.