I was looking around, and I don’t see any obvious way to have Panda capture my mouse. I want to have mouse movements move the camera around, and I don’t want to have my mouse controlling a pointer.
It looks like I can hide the pointer, and use base.win.movePointer() to keep it from getting out of the window, which should give me all I need, but this seems a lot more clunky than most of the features I’ve used thus far in panda. Is there a better way to do this?
Also, I’ve seen a GraphicsWindowInputDevice class mentioned in comments and it sounds like it might have what I want, but I can’t find the actual module to import for this.
donwload the Yet another Roaming ralph example here it has good codeing for this type of camera although this code is a little advanced and maybe had to understand some of it but there is alot of info in the posts!
Yes. The better (more stable, less hacky, less jitter) way to do it would be to put the mouse into MRelative mode and not reset the mouse anymore.
This doesn’t work well on every platform, though.
A unified mouselook system has been planned for a future release.
I’m confused by your MRelative comment, or maybe this just doesn’t work well on my platform (Dell Inspiron 1420 run Ubuntu Gutsy Gibbon with a GeForce 8 Series card… and completely outdated drivers).
Specifically, I don’t understand what you mean by “not reset the mouse anymore” When I set the mouse to MRelative, I still need to move it back to the center of the screen. It doesn’t appear to save me any work at all, aside from not needing to subtract out the screen center position. And the code is almost identical, so I don’t see how it’s less hacky or more stable. I still need to keep track of the actual window size to recenter the pointer, and now I also need to correct for the screensize when I move the mouse (since no matter how big the screen is or what the width/height ratio is, I get a (-1,1) position)
Both methods look just as jittery to me. I’m planning to try and fix the jitter by not parenting the camera directly to the NodePath that I’m rotating with the mouse. Instead I’ll parent it to another NodePath that will smoothly rotate to the position of the first NodePath over 1/20 a second.
Actually, with relative mouse mode you can’t really talk about a ‘cursor’ anymore, as the mouse is really not on the screen anymore. Panda just receives relative mouse information from the driver then, meaning that you won’t lose the subpixel accuracy that is lost when resetting the mouse to the center.
Note that relative mouse mode on Linux is only supported in 1.7.0 (or the CVS head) and requires the X11 extension Xxf86dga to be installed.
If you’re on Linux, MRelative mouse mode should do the trick. If not, you just need to reposition the cursor to the center of the window (or any other place, but that’s the most natural) in every frame.