I have this script to get an entity's MVP, all in glm. I want the object to rotate according to it's orientation value that I use for movement, but visually, the object rotates about a hundred times slower. This would have to be accurate, to represent direction properly, visually. But I'm no expert, still just learning and trying to get my head around it, so once again, hoping the wise ones can help me out? :)
void Entity::turnRight()
{
m_Orientation += m_TurnSpeed;
}
turn speed is 0.02 by default
then get mvp:
m_Direction[0] = cos(0.0f) * sin(m_Orientation);
m_Direction[1] = sin(0.0f);
m_Direction[2] = cos(0.0f) * cos(m_Orientation);
glm::mat4 projectionMatrix = glm::perspective(90.0f, (GLfloat)640 / (GLfloat)480, 0.001f, 60.0f);
glm::mat4 translationMatrix = glm::translate(glm::mat4(), glm::vec3(m_Position[0], m_Position[1], m_Position[2]));
glm::mat4 Rotation = glm::rotate(glm::mat4(), (m_Orientation / m_TurnSpeed), glm::vec3(0, 1, 0));
m_MVP = (projectionMatrix * viewMatrix * glm::mat4() * translationMatrix * Rotation);
This is all there is to it really... the player rotates and translates properly but visually, it's off, like it turns way less than the actual orientation value (m_Orientation)
What am I not calculating in there?
Thanks in advance!
I think you are using an older version of GLM that uses degrees instead of radians. This is an unfortunate design flaw in older versions of GLM.
You can probably use a preprocessor macro to fix things:
#define GLM_FORCE_RADIANS
#include <glm/...>
#include <glm/...>
However, it might be better to upgrade to a more recent version of GLM. Versions 0.9.6 and newer use radians by default.