Archived

This topic is now archived and is closed to further replies.

Shag

Quaternion / Transformation question

Recommended Posts

Shag    122
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!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites