Mouselook

Hi im trying to make a game with mouselook and therefore i need to find the location of the mousepointer. I now use mouseWatcherNode.getMouse() to find the point where the mouse is, but i need to reset the mouse in each loop to find relative movement, so i can move indefenetly to the left or right. Anyone know how to reset mouse, or is there another way to implement MouseLook?

Some code here…

discourse.panda3d.org/viewtopic.php?t=581

Also see the Airblade source code, which does exactly this.

Basically you can call:


base.win.movePointer(0, x, y)

to reset the mouse pointer.

David

Thanks a lot to both of you for responding so quickly, it helped a lot :slight_smile:

How do you prevent the mouse from leaving the window? I tried base.win.movePointer() as suggested, but if I jerk the mouse fast enough it still escapes the window before the movePointer() happens. For what it is worth, the Airblade game has the same problem.

Is there some sort of “capture mouse” option?

I’m afraid David’s out for the month, so I’m trying to handle his messages. But I’m afraid I don’t know of a simple solution to this one.

One possibility is to use raw mouse events. To do that, use getPointer(1) instead of getPointer(0). However, be warned - this is not yet implemented under Linux.

But here’s a question - is your program intended for a windowed environment, or a fullscreen environment? If fullscreen, this can’t happen, so it’s not a problem in the long run. If that’s the case, I wouldn’t use the nonportable code.

Portability is pretty important to me (linux is my main OS). I’d like to leave the windowed / fullscreen choice to the user. That said, it takes a pretty hard jerk on the mouse to get out of a small (640x480) window so I’m not too worried about this.