Sign in to follow this  
arcooke

Is there a word for this technique...

Recommended Posts

I'm trying to search around to find info about a certain technique, and it would be incredibly helpful to me if I had a keyword to search for. The technique in question is what is used in 3D games to rotate the camera with the mouse. Where a timer runs in the background resetting your cursor to center-screen every few milliseconds and returns the x and y distance your mouse moved since each tick. Is there a word for that? Thanks.

Share this post


Link to post
Share on other sites
Yeah, those are the type of replies I expected.

I'm trying to explain this to someone who doesn't know a whole lot about it.. I was hoping I could find some sort of example demonstration of how this works to show them.

Share this post


Link to post
Share on other sites
The idea is to get the relative mouse co-ords of the mouse since the last movement. Do a quick search for relative mouse movement, should provide an article for your friend :)

Share this post


Link to post
Share on other sites
Sounds like a horrible way to do things though. I assume this is, like cNoob said, to get the relative mouse movement since last time, but the input is the absolute mouse coordinates, which is constrained by the window or screen size? So weird stuff happens if the user moves the mouse too much?

I don't know what API you're using, but pick one that allows access to the actual relative mouse data. DirectInput is one that I know of. I'm sure there are others, based on your platform.

Share this post


Link to post
Share on other sites
Relative can be converted to absolute, and vice versa.

Relative to Absolute: Keep x and y variables, add the relative coords to them every frame.
Absolute to Relative: Keep the PREVIOUS x and y coords, calculate the change every frame.

The technique for resetting the mouse to centre screen is called 'warping'.

I wouldn't rely on a timer for this sort of thing, poll the mouse coords each frame instead. You didn't mention which API you are using, and if you haven't chosen one might I recommend the SDL event system? Plenty of documentation and examples on this sort of stuff.

Share this post


Link to post
Share on other sites
Quote:
Where a timer runs in the background resetting your cursor to center-screen every few milliseconds and returns the x and y distance your mouse moved since each tick.

That seems like a strange way to do it, you would have to create another thread. Unless you're running low fps, it seems like you could do it frame. WM_INPUT will do this for you if you throw it the MOUSE_MOVE_RELATIVE flag.

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