Reposition the camera during an base.enableMouse() operation

Hi Guys!

This seems like a stupid problem but I’ve been able to find a fix for it. I want my application to switch between automatic ( controlled by the application ) and manual ( control by the mouse ) control of the camera. So I map key events to base.disableMouse() and base.enableMouse() commands to enable this. The problems is that when the camera is switched back to manual ( base.enableMouse() ) a reposition of the camera is needed. I then get the actual position of the camera with* methods, and then apply those values again with base.mouseInterfaceNode.set*. But guess what?, Those values don’t work, it seems that a transformation is needed or something.

Any Ideas?


You only need to apply the inverse matrix of the camera :


Actually, setting the inverse matrix also solves the problem –[HERE]–, but that’s different situation.
I’ve added it to the manual :

One interjection: in order to avoid modifying the camera node itself, and causing havoc on Panda’s internal cache tables, you need to get a copy of the camera’s transform before you modify it:



Oops. I thought it would be fine since the mouse is enabled, so in the next frame, the camera would be affected by mouseInterface and the applied matrix would be the one before inverted.

Thanks guys. Your solution worked like charm.