quaternions for rotate
Hi i'm having problems implementing quaternions for the rotation of a trackball. i'll admit i'm a pretty horibble programmer, but i am getting frustrated. i commented the glRotatef part which is what i'm tryin to not use and use quaternions instead. the result is that the rotation is going super fast, but it appears that it is working. thanks for any help.
//callback functions
void callback_display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
/* view transform */
if (trackballMove) {
length = sqrt(axis[0]*axis[0] + axis[1]*axis[1] + axis[2]*axis[2]);
axis[0] = axis[0]/length;
axis[1] = axis[1]/length;
axis[2] = axis[2]/length;
xz[0] = cos (angle/2);
xz[1] = axis[0] * sin (angle/2);
xz[2] = axis[1] * sin (angle/2);
xz[3] = axis[2] * sin (angle/2);
cm(xz);
glMultMatrixf(q2m);
// glRotatef(angle, axis[0], axis[1], axis[2]);
}
glmDraw(model, GLM_SMOOTH);
glutSwapBuffers();
}
[Edited by - satjo7 on November 7, 2006 10:37:05 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement