I don’t know how many quaternion equations/algorithms I coded up before I got one that worked for me, but I finally coded one that works. It is listed below. But I would like to do a slightly different version with a new step 3. The new step 3 doesn’t work and I’m not sure if something is fundamentally wrong with this approach so I thought I’d ask.
// Given:
// 1) user input xRot, yRot, zRot
// 2) current quaternion of 3d object
//
// Problem:
// 1) rotate object to new orientation
//
// step 1:
EulerToQuatenion(xRot, yRot, zRot, quaternionInput);
// step 2:
vector4 result;
QuaternionMultiply(quaternion, quaternionInput, result);
Vector4Copy(result, quaternion);
// step 3:
GetAxisAngleRotationFromQuaternion(quaternion, axis, angle);
glTranslatef(loc.x, loc.y, loc.z);
glRotatef(angle, axis.x, axis.y, axis.z);
The above code works just great. Now if I changed step 3 to be:
// new step 3:
matrix4 modelview;
CreateModelViewMatrixFromQuaternion(quaternion, modelView);
glTranslatef(loc.x, loc.y, loc.z);
glMultMatrixf(modelView);
This doesn’t work for some reason.
Any suggestions?
[This message has been edited by Junkstyle (edited 07-15-2002).]