I have a vec3 to represent my object's orientation/rotation but the glm::rotate method expects a quaternion. If I just convert it to a quaternion like this:
glm::quat rot = rotation;
The W value will just be zero, right? And then there won't be any changes in rotation.
In my code I just want to be able to do rotation.x += 5.0f; in the update method of an object.
This is the method I'm using for my transformations:
glm::mat4 GameObject::Transform(glm::mat4 model, glm::vec3 position, glm::vec3 scale, glm::quat angleAxis)
{
model = glm::translate(model, position);
if (angleAxis.w > 360.0f)
{
angleAxis.w -= 360.0f;
}
else if (angleAxis.w < 0.0f)
{
angleAxis.w += 360.0f;
}
model = glm::rotate(model, angleAxis.w * toRadians, glm::vec3(angleAxis.x, angleAxis.y, angleAxis.z));
model = glm::scale(model, scale);
return model;
}
Currently I'm just passing on that rotation vec3 to that angleAxis quaternion parameter but that obviously doesn't work.
This is how i currently calculate my front, up, and right vectors:
void GameObject::calculateCameraView()
{
front.x = cos(glm::radians(rotation.x)) * cos(glm::radians(rotation.y));
front.y = sin(glm::radians(rotation.y));
front.z = sin(glm::radians(rotation.x)) * cos(glm::radians(rotation.y));
front = glm::normalize(front);
right = glm::normalize(glm::cross(front, worldUp));
up = glm::normalize(glm::cross(right, front));
front.y = invertMouse ? front.y * -1 : front.y;
}