PDA

View Full Version : Continious Mouse Rotation (like Quake)



garcij01
05-07-2001, 02:29 PM
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!.

LordKronos
05-07-2001, 03:34 PM
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.

T2k
05-08-2001, 01:11 AM
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 !]

LordKronos
05-08-2001, 02:11 AM
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).]

NeoTuri
05-08-2001, 12:35 PM
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).]

WhatEver
05-08-2001, 12:38 PM
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 &amp;#0124; &amp;#0124; MainXpos > 160)
{
MainXold=120;
SetCursorPos(120, MainYpos);
}
else
{
MainXold=MainXpos;
}

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

return true;
}

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

garcij01
05-08-2001, 02:12 PM
Thank you guys, your help is priceless! http://www.opengl.org/discussion_boards/ubb/smile.gif

paddy
05-08-2001, 05:46 PM
If you don't want to use DirectInput, the mouse position command is :
mouse_event(MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE, (x*65536)/screenwidth,(y*65536)/screenheight,0L,0L);
If it can help ...

zed
05-08-2001, 10:01 PM
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)
}