Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


First Person Camera Proper Mouse Input


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   -  Reputation: 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?

Sponsor:

#2 Erik Rufelt   Crossbones+   -  Reputation: 3517

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



PARTNERS