So I’m trying to implement a rotation system similar to Daedalus where you move the mouse and the camera rotates. Although, I need to find out what the rotation of my OrthographicCamera is. Is there any way to do this?
Simple: rotate the entire world based on the horizontal movements of the mouse. +dx = -rotation, -dx = +rotation
I am doing that already to rotate my character, but how to I get the actual camera rotation value? I can rotate with [icode]camera.rotate()[/icode], but I need something like this [icode]camera.getRotation()[/icode]
You store the rotation variable yourself. Modify that rotation variable with the Mouse’s delta-x, and call rotate(rot…)
Thank you. I thought I might have to do this but I thought I could ask.
Out of curiosity, is there a specific reason why LibGdx doesn’t have a method like this where you can get the rotation along any axis?
Well the camera stores the transformations in a 4x4 matrix as usual, with the vec3 in the first, second, and third columns being the X, Y, and Z rotations respectively. The vec3 in the fourth column is the translation. You could probably get the angle from those…somehow.
A visual example:
However, you shouldn’t be doing transformations cumulatively. You should be rebuilding the matrix from identity every frame, requiring you to store your own rotations and translations. This is to avoid accumulating rounding errors.
Thank you. I’ll look into using the camera matrix to acquire the camera rotation.