Quaternion / Transformation question

Started by
0 comments, last by Shag 22 years, 9 months ago
OK ... i''m using quaternions to represent my rotations (in a space sim). how do i use these in conjuction with forward momentum to obtain a new tranformation? i guess i translate everything from my position, and apply the rotation, to obtain the final modelview matrix. it''s the transformations i''m having trouble with!
Advertisement
Matrix multiplications of the different transformations translations rotations etc... can all be combined into one step.

It is good programming style to have the matrix on top of the stack as the identity matrix. I.e. you should have

glLoadIdentity()

// always in the beginning of a program.

glPushMatrix()

// to save the identity on the stack, faster than reloading it.

glMultiMatrixf(T)
glMultiMatrixf(R)
glMultiMatrixf(S)

// this will multiply the translation matrix with the identity to give simply a translation matrix.
// then multiply the rotation matrix with the translation matrix to give a matrix that translates then rotates (in one go)
// and finally a scaling matrix.

// draw object here

glPopMatrix()

// restore the identity matrix

NOTE : the order of the matrix multiplications REALLY matters.
remember to pop the matrix off the stack to restore the indetity at the end.

This topic is closed to new replies.

Advertisement