Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: Continious Mouse Rotation (like Quake)

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2000
    Location
    ny
    Posts
    7

    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!.

  2. #2
    Member Regular Contributor
    Join Date
    May 2000
    Posts
    420

    Re: Continious Mouse Rotation (like Quake)

    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.
    Ron Frazier

  3. #3
    Junior Member Regular Contributor
    Join Date
    May 2001
    Location
    Germany, Hannover
    Posts
    160

    Re: Continious Mouse Rotation (like Quake)

    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 !]

  4. #4
    Member Regular Contributor
    Join Date
    May 2000
    Posts
    420

    Re: Continious Mouse Rotation (like Quake)

    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).]
    Ron Frazier

  5. #5
    Intern Newbie
    Join Date
    Apr 2001
    Location
    FL, USA
    Posts
    36

    Re: Continious Mouse Rotation (like Quake)

    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).]
    When in doubt, press F1.

  6. #6
    Member Regular Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    410

    Re: Continious Mouse Rotation (like Quake)

    Here's what I do:

    Code :
    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).]

  7. #7
    Junior Member Newbie
    Join Date
    Oct 2000
    Location
    ny
    Posts
    7

    Re: Continious Mouse Rotation (like Quake)

    Thank you guys, your help is priceless!

  8. #8
    Email address no longer exists Regular Contributor
    Join Date
    Sep 2000
    Location
    Aix en Provence, France
    Posts
    146

    Re: Continious Mouse Rotation (like Quake)

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

  9. #9
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,407

    Re: Continious Mouse Rotation (like Quake)

    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)
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •