PDA

View Full Version : rotation of the scene with the mouse ??



Qbic
11-28-2003, 08:54 PM
Hi there

I'am trying to fix my camera to the mouse so that when I move the mouse left, the view is rotated to the left and vice-versa (as in any 1st person shooter).

I am using GLUT glutPassiveMotionFunc() to achieve that. I look at dx and dy (x - oldx and y - oldy) and perform a rotation on my camera based on that. The problem is that when the mouse exits the window, the glutPassiveMotionFunc() don't seems to be called and with no dx and dy, I can't continue my camera rotation as well as I can't rotate 360 degrees on myself.

Can anyone gives me some hint on a possible Glut implementation or on an other possible approach ??

Thanks

tayo
11-29-2003, 02:24 AM
this is normal, you can't have mouse events when the mouse is not in your window!
actually, you can do it if you use DirectInput on Windows. but that is not the problem, you cannot turn 360 with one mouse movement (look at all the FPS games).

Rog
11-29-2003, 08:39 AM
If you're using Windows, you can do SetCapture() on mouse-down and ReleaseCapture() on mouse-up. Then you'll still get mouse messages even when the cursor is outside your window.

Qbic
11-29-2003, 08:46 AM
HUmmm I just found an answer to my question. I just call glutWarpPointer() to bring my cursor back to the center when it gets too close to an window's edge.

Thanks anyway for your help guys

Mike !!