Hi all !
In my program, you use a FPS-like movement to move around. It works (and it works well) but there is a tiny bug left. I activate the mouse-guided rotation of the camera by right clicking, and depending on where this right click is done, I see the camera rotating although the mouse is not moving at all. I suspect there is a rounding error, but I can’t find a way to make it disappear.
Here is the code I use :
# init
props = base.win.getProperties()
self.windowSizeX = props.getXSize()
self.windowSizeY = props.getYSize()
self.windowCenterX = self.windowSizeX / 2
self.windowCenterY = self.windowSizeY / 2
self.rotationSpeed = 40
# getting current cursor position
mouseX = base.mouseWatcherNode.getMouseX()
mouseY = base.mouseWatcherNode.getMouseY()
dtheta = (self.oldMouseX - mouseX) * self.rotationSpeed
dphi = (mouseY - self.oldMouseY) * self.rotationSpeed
# replacing the cursor at its stored position
# when I right click, self.oldMouseX and self.oldMouseY take values contained in base.mouseWatcherNode.getMouseX/Y
base.win.movePointer(0,int(self.windowCenterX * (1+self.oldMouseX)),int(self.windowCenterY * (1 - self.oldMouseY)))
# updating camera position
theta = base.camera.getH()
phi = base.camera.getP()
base.camera.setHpr(theta + dtheta,phi + dphi,0)
Any idea ?