I've read multiple tutorials, but I still can't understand how do I properly rotate an object in 3D space on all 3 axis at once. For example, I'd like to give the object a pitch of 60 degrees, yaw of 20 degrees and roll of 70 degrees. How can I properly do this in OpenGL, preferrably using GLM?

  • 1
    $\begingroup$ "I'd like to give the object a pitch of 60 degrees, yaw of 20 degrees and roll of 70 degrees." Why? Why do you want to do this thing? $\endgroup$ – Nicol Bolas Jun 17 at 5:36
  • $\begingroup$ OpenGL has nothing to do with that. GLM might very well regarding the implementation (but in turns has nothing to do with OpenGL either). But ultimately that's a purely mathematic problem, the practical implementation of which depends on a lot more things than if you're using GLM. And even the mathematical theory of which depends on a few other unclarities, e.g. what "pitch", "yaw" and "roll" even mean in your context and what exactly you want your object to behave like. $\endgroup$ – Chris says Reinstate Monica Jun 17 at 11:17
  • $\begingroup$ @Nicol Bolas Because those are all the three rotation values that an object can take at a time. Such thing is needed for example, in games with planes and helicopters, since they can turn around these 3 axis all at the same time. $\endgroup$ – John Jun 17 at 14:27
  • $\begingroup$ @Nicol Bolas Nevermind, I just realised that the answer is simpler than I first thought. I think that simply creating a rotation matrix for each axis and then multiplying them would do the trick. $\endgroup$ – John Jun 17 at 17:37
  • 1
    $\begingroup$ And then you'll be back tomorrow asking about Gimbal Lock or other similar Euler angle problems. $\endgroup$ – Nicol Bolas Jun 17 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.