Continious Mouse Rotation (like Quake)

Hello all

I’m trying to implement a behavior which rotates an object continiously as you roll the mouse in a direction.

The problem I have is that the mouse has Limits on it’s coordinates once I reach (0,0) I cannot keep rotating.

Is there any function to reset the mouse under MacOS 9 or Windows 98?

thank you!.

The best way is to use direct input. The easiest way is to use SetCursorPos to position the cursor to a default location (like the center of the screen) and then everytime you get a mouse move calculate the relative movement and call SetCursorPos again.

if you use WM_MOUSEMOVE (or how this message calls) in WndProc you get some nice effects( maybe thats the problem):
if WM_MOUSEMOVE set mouse to center of window(SetCursor(…)) after getting some deltas( positionchanges) you have done the half of your work, because this function sends after setting the mouse to center again the same message with reversed deltas ! 1st message + 2nd message = nothing changes
!to solve this skip every second message!

sometimes you call in your WM_MOUSEMOVE routine somthing else, that will cause, that you get correct deltas without skipping some messages!

i hope this will help …
[Bad english, i know !]

Are you sure about this? I have never had this problem, although I use Delphi for my GUI work, and maybe it filters these out somehow (though I doubt it).

P.S. after thinking about, I dont even think WM_MOUSEMOVE sends relative movement, only absolute position. So I just check MSDN and confirmed…it does NOT send relative movement.

[This message has been edited by LordKronos (edited 05-08-2001).]

Under win32, the mouse events give the client RECT coords for the cursor.

And as for my engine, I also center the cursor after each WM_MOUSEMOVE event.

[This message has been edited by NeoTuri (edited 05-08-2001).]

Here’s what I do:

case WM_MOUSEMOVE:
		{	
			MainXpos = LOWORD(lParam);
			MainYpos = HIWORD(lParam);  

			Yaw+=(float)(MainXold-MainXpos)/6.0f;
			Pitch+=(float)(MainYold-MainYpos)/-6.0f;

			while(Pitch >= 360.0f)
			{
				Pitch-=360.0f;
			}

			while(Yaw >= 360.0f)
			{
				Yaw-=360.0f;
			}

			while(Pitch < 0.0f)
			{
				Pitch+=360.0f;
			}

			while(Yaw < 0.0f)
			{
				Yaw+=360.0f;
			}

			if(MainXpos < 20 &#0124; &#0124; MainXpos > 160)
			{
				MainXold=120;
				SetCursorPos(120, MainYpos);
			}
			else
			{
				MainXold=MainXpos;
			}

			if(MainYpos < 20 &#0124; &#0124; MainYpos > 160)
			{
				MainYold=120;
				SetCursorPos(MainXpos, 120);
			}
			else
			{
				MainYold=MainYpos;
			}

			return true;
		}

[This message has been edited by WhatEver (edited 05-08-2001).]

Thank you guys, your help is priceless!

If you don’t want to use DirectInput, the mouse position command is :
mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE,(x65536)/screenwidth,(y65536)/screenheight,0L,0L);
If it can help …

Originally posted by T2k:
if you use WM_MOUSEMOVE (or how this message calls) in WndProc you get some nice effects( maybe thats the problem):
if WM_MOUSEMOVE set mouse to center of window(SetCursor(…)) after getting some deltas( positionchanges) you have done the half of your work, because this function sends after setting the mouse to center again the same message with reversed deltas ! 1st message + 2nd message = nothing changes
!to solve this skip every second message!

hehe i ran into that a while ago. first i just done the skip every second message thing but now i use something like ie no more WM_MOUSEMOVE

main_loop()
{
// read input
if (using_directinput)

else
getCursorPos(…)

setcursorpos(middle of the screen)
}