I’m curious if anyone out there has some example code they wouldn’t mine sharing of a 6 DOF camera as used in a flight / space sim, or more appropriately a game like Descent.

Most of the examples I’m finding simply use base.camera.setHpr() to control the camera, but as I understand it, for a true 6 DOF camera you shouldn’t be using Euler angles, you should be multiplying Quaternions to get your new camera rotation.

I can’t believe how easy this is. I just got started with panda, and I only have a basic understanding of quaternions and vector math, and I got it working with the task below.

def update_player(self, task):
""" handles player movement"""
pointer = base.win.getPointer(0)
x = pointer.getX()
y = pointer.getY()
#Reset pointer position
if base.win.movePointer(0, 300, 300):
#get amount cursor moved
x = x - 300
y = y - 300
quat = base.camera.getQuat()
upQ = copy.copy(quat)
rightQ = copy.copy(quat)
#forwardQ = copy.copy(quat)
up = quat.getUp()
right = quat.getRight()
forward = quat.getForward()
up.normalize()
right.normalize()
forward.normalize()
upQ.setFromAxisAngle((x * self.MOUSESENSITIVITY * -1), up)
rightQ.setFromAxisAngle(y * self.MOUSESENSITIVITY, right)
#forwardQ.setFromAxisAngle(45, right)
base.camera.setQuat(quat.multiply(upQ.multiply(rightQ)))
return task.cont

As I understand it if you do your rotation like that you get what’s called Gimbal Lock. It’s the difference between rotating with 3 fixed points (HPR) and rotating freely in 3d space.

For a regular FPS, the 3 gimbals are good enough, because your horizon is always fixed.