/* Rotation using Quaternion*/ int rotate(GLfloat x, GLfloat y, GLfloat z, GLfloat angle) { GLfloat pmatrix[16]; Quaternion quaternion; quaternion.CreateFromAxisAngle(x,y,z,angle); quaternion.CreateMatrix(pmatrix); glMultMatrixf(pmatrix); return 0; }
void GLEngine::SetPerpective() { Quaternion m_qPitch, m_qHeading; m_qPitch.CreateFromAxisAngle(1.0f, 0.0f, 0.0f, m_camera.pitch); m_qHeading.CreateFromAxisAngle(0.0f, 1.0f, 0.0f, m_camera.heading); Quaternion q; q = m_qPitch * m_qHeading; float Matrix[16]; q.CreateMatrix(Matrix); glMultMatrixf(Matrix); m_qPitch.CreateMatrix(Matrix); m_camera.diry = Matrix[9]; q = m_qHeading*m_qPitch; q.CreateMatrix(Matrix); m_camera.dirx = Matrix[8]; m_camera.dirz = Matrix[10]; m_camera.dirLx = -m_camera.dirz; m_camera.dirLz = m_camera.dirx; }