My issue is that when the camera pitches above the horizon line, the camera will roll right when turning/yawing right and roll left when turning left. Below the horizon line, the camera will roll left when turning right and right when turning left.
The overall effect is the camera following a cosine wave like pattern when the mouse is moving left or right. The amplitude of the wave pattern increases the further above/below the horizon the camera is pointing.
I’m trying to simulate a plane so I need local control of Roll, Yaw, and Pitch and without gimbal lock so I can’t use some other workaround I’ve found online.
Is there a simple issue I’m overseeing in my code or this there a bigger problem with my implementation? Any help would be greatly appreciated! I’ve spent literally half the day on this stinking issue!
My code is as follows:
Pitch and Yaw and Roll are just a flat increment/decrement adjusted for delta time while Orientation is a quaternion that holds the current camera orientation.
void updateCameraVectors()
{
glm::quat rotation = glm::quat(glm::vec3(Pitch, Yaw, Roll));
Orientation = rotation * Orientation;
Orientation = glm::normalize(Orientation);
glm::mat4 OrientMat = glm::mat4_cast(Orientation);
glm::mat4 viewMatrix = OrientMat;
viewMatrix = glm::transpose(viewMatrix);
Front = glm::vec3(viewMatrix[2]);
Up = glm::vec3(viewMatrix[1]);
Right = glm::vec3(viewMatrix[0]);
Pitch = Yaw = Roll = 0;
}