//Rotate camera glMultMatrixf( m_PlayerCamera.GetInvertedMatrix() ); //Translate camera sf::Vector3<float> CameraPos = m_PlayerCamera.GetPosition(); glTranslatef(CameraPos.x, CameraPos.y, CameraPos.z);
Where GetInvertedMatrix() looks like this:
GLfloat* Camera::GetInvertedMatrix()
{
//Get a new quaternion, the inverse of the Orientation
Quaternion InvertedOrientation = m_Orientation;
InvertedOrientation.Invert();
//Fill the matrix with the orientation
InvertedOrientation.RotationMatrix(m_RotationMatrix);
//Return that matrix
return m_RotationMatrix;
}
Once I do this, everything works as intended.
In case anybody in the future is looking for the way to Invert() a quaternion, here's my code:
void Quaternion::Invert()
{
float Length = 1.0 / (x*x + y*y + z*z + w*w);
x *= -Length;
y *= -Length;
z *= -Length;
w *= Length;
}

Find content
Not Telling