Quaternion Camera

Let’s say I have an orientation Quaternion and a positon Vector, that presents the real camera position in the world.
How do I apply these things correctly to the glMatrix before drawing the scene?

So that it moves real inverse. Like I would sit in that camera and fly around. And the thing is I don’t want a fixed world coordinate, which I transform and move with the quaternion, I just want real camera position and orientation, just in the scene drawing it should get inverted to make the right thing for moving the world.

I tryed all different things without success.

I have maths for inverting a quaternion and for transforming vectors with quaternions, multibly quats, etc.

and a QuaternionToMatrix function, that should do the rest.

But how to do things before drawing the scene?
How can I apply this?

glMultMatrix QuatToMatrix(cam.orientation.inverse)

/Draw sky box

gltranslate ??


the above seems correct to me. But what about the translation? Thanks for help! I would be really glad, I am searching around since weeks already, tried 100 different combinations and so on. All without success!
Hope you can help!

Baboon (Silk)

Your method is right. Here is my camera code:

void Camera::Look() const

// // Get the frame and invert it (because, in reality, the camera remains
// // at the origin and the world is transformed), transpose for OpenGL and
// // multiply.
// Matrix44d r = m_Frame.GetTransformation();
// r.Invert();
// r.Transpose(); // Reorder elements for OpenGL
// glMultMatrixd( &r.m_M[0][0] );
// Yuck this is slow…try a faster way

// Rotate and translate
// Note the transformation is inverted (because, in reality, the camera
// remains at the origin and world space is transformed), also the order
// of rotation and translation is reversed.

// Get the rotation and invert it, transpose for OpenGL and
// multiply.
// Note: the invert and transpose cancel so neither are needed

Matrix44d const r = m_Frame.GetRotation().GetRotationMatrix44d();
glMultMatrixd( &r.m_M[0][0] );

// Translate (and as before, invert it)

Vector3f const t = m_Frame.GetTranslation();
glTranslatef( -t.m_X, -t.m_Y, -t.m_Z );

Hmm… could you explain what are doing? Especially where to get the the vector for the glTransformation from?

I always get wrong results.

It would be nice to explain it in pseudo code. (it is important that the camera works right for me, because I need sorta source compatibility for for Quesa based Rb projects)

so I do:

RotateMatrix Camera.orientation.invere


Translate Matrix (but how, that’s the main pint)


Could you discribe in pseudo code what you exactly translate? Thanks, that really would help! I am experimenting since weeks, without success.


The culprit may very well be the inverted quaternion. AFAIK there should be two types of quaternion inversion, one for addition, one for multiplication. I don’t know whether either one is correct, maybe you should just build your rotation quaternion with the inverted angles, then do a straight Matrix_thingy=quaternion_thingy; //conversion