FPS camera twist problem

Howdy,

How do I rotate a quaternion based on mouse’s delta X, Y so it mimicks the basic FPS viewing method seen in Quake and such games?

Right now I am experiencing some weird twist along the camera’s local Z axis. I can’t find any obvious math error in my code for doing things like quaternion-to-matrix, quaternion * vector or quaternion constructed from axis-and-angle.

I’ve come to the conclusion my method must be flawed. Could someone point me to the correct procedure to do this given the input of mouse delta X and Y and current orientation Q?

// ville

Using quaternions for that type of viewing scheme is probably overkill. You don’t want the camera to roll in most cases in a FPS, so why not just use heading and pitch?

I have a baseclass that describes a transformation and holds its orientation as a quaternion. I was wishing my FPS camera controller would be able to work with this class as the camera class inherits from it.

// ville

If you really want, you can incrementally update a quaternion to represent your viewers orientation. (I don’t think quaternions suffer from numerical degradation over time like matrices do.) But if you do it that way, you will have to constantly correct for the roll that creeps in. It really is much simpler to store a heading and a pitch and just create a new matrix from scratch each frame.

You could also create a quaternion from scratch each frame, but it will have to be converted to a matrix to feed it into OpenGL anway.

And that’s exactly what I am having the problem with. How to get the delta Quaternion from the mouse delta X and Y so it doesn’t induce a roll around camera’s local Z axis?

// ville

I am having the same problem.

My camera class stores its rotation in a quaternion. When I use the mouse to look in X and Y simultaneously, I get a rotate in Z.

Has anyone found a solution to this problem?