I have a 3d object in the scene and I’m trying do pitch, yaw and roll. To avoid Gimbal lock, quaternions are used. It looks like I’m missing something fundamental about the implementation. I’m still getting Gimbal lock. Ideally, there should be an axis around which I should be doing the rotation, but I am not sure how to update the object’s orientation/axis.
glm::quat rotP = glm::angleAxis(glm::radians(doPitch), glm::vec3(1.0f, 0.0f, 0.0f)); //i believe the glm::vec3 should be updated with the new orientation, but not sure how glm::quat rotY = glm::angleAxis(glm::radians(doYaw), glm::vec3(0.0f, 1.0f, 0.0f)); glm::quat rotR = glm::angleAxis(glm::radians(doRoll), glm::vec3(0.0f, 0.0f, 1.0f)); model = glm::mat4_cast(rotR) * glm::mat4_cast(rotY) * glm::mat4_cast(rotP) ;
doPitch, doYaw and doRoll are updated incrementally using keyboard.
I need to find a way to update the orientation after i do pitch, yaw or roll. Could someone help please?