I want to turn my car 90 degrees to the left in the game that I have.
When I use this code:
glm::quat rot(info.Rotation.w,info.Rotation.x,info.Rotation.y,info.Rotation.z); glm::quat done(glm::rotate(rot,glm::eulerAngles(rot)+glm::vec3(90.0f,0.0,0.0))); info.Rotation.x = done.x; info.Rotation.y = done.y; info.Rotation.z = done.z; info.Rotation.w = done.w;
The car gets a weird spin.
However, the following codes do not change the rotation of cars at all (just what I expected, just to be sure that GLM is compatible with quats from the game):
glm::quat rot(info.Rotation.w,info.Rotation.x,info.Rotation.y,info.Rotation.z); glm::quat done(rot); info.Rotation.x = done.x; info.Rotation.y = done.y; info.Rotation.z = done.z; info.Rotation.w = done.w;
and whenever I try to check if the rotation has changed with it:
glm::quat rot(info.Rotation.w,info.Rotation.x,info.Rotation.y,info.Rotation.z); glm::quat done(glm::rotate(rot,vec3(0.0,0.0,0.0))); info.Rotation.x = done.x; info.Rotation.y = done.y; info.Rotation.z = done.z; info.Rotation.w = done.w;
the rotation of the cars is simply set to 0,0,0,0 revolutions in the game. I expected the rotations to remain untouched with this code, because I expected the following code to rotate the car 90 degrees to the left:
glm::quat rot(info.Rotation.w,info.Rotation.x,info.Rotation.y,info.Rotation.z); glm::quat done(glm::rotate(rot,vec3(90.0,0.0,0.0))); info.Rotation.x = done.x; info.Rotation.y = done.y; info.Rotation.z = done.z; info.Rotation.w = done.w;
but it doesnβt work the way I want. It simply sets the rotation, not adds it to the "rot".
What am I doing wrong?