So I've got an object I'm trying to rotate according to a Yaw, Pitch and Roll scheme, relative to the object's own local axes rather than the global space's axes. According to this, I need to perform the rotations in that order. I've interpreted that to mean this:
glRotatef(m_Rotation.y, 0.0, 1.0, 0.0);
glRotatef(m_Rotation.z, 0.0, 0.0, 1.0);
glRotatef(m_Rotation.x, 1.0, 0.0, 0.0);
However, rotation around the Y and Z axes don't work. Rotation around the Y axis is always relative to the global space, and rotation around the z axis works of the rotation around the X axis is 0, but otherwise messes up.
Just to be sure, I tried the reverse order as well, but that doesn't work either. I think I've tried all the other orders as well, so the problem must be something else. might it be?
This is how I obtain the rotations:
///ROTATIONS
sf::Vector3<float> Rotation;
Rotation.x = 0;
Rotation.y = 0;
Rotation.z = 0;
//ROLL
if (m_pApp->GetInput().IsKeyDown(sf::Key::Up) == true)
{
Rotation.x -= TurnSpeed;
}
if (m_pApp->GetInput().IsKeyDown(sf::Key::Down) == true)
{
Rotation.x += TurnSpeed;
}
//YAW
if (m_pApp->GetInput().IsKeyDown(sf::Key::Left) == true)
{
Rotation.y -= TurnSpeed;
}
if (m_pApp->GetInput().IsKeyDown(sf::Key::Right) == true)
{
Rotation.y += TurnSpeed;
}
//PITCH
if (m_pApp->GetInput().IsKeyDown(sf::Key::Q) == true)
{
Rotation.z -= TurnSpeed;
}
if (m_pApp->GetInput().IsKeyDown(sf::Key::E) == true)
{
Rotation.z += TurnSpeed;
}
They are then added to m_Rotation as such:
//Rotation
m_Rotation.x += Angle.x;
m_Rotation.y += Angle.y;
m_Rotation.z += Angle.z;
(They are passed to a function internal to the thing being moved around, but nothing else is done with them).
Thoughts? Is there something else I should call to make sure all the axes being rotated around are local axes?