Search code examples
openglrotationmodel-view

Derive euler rotation from model view matrix


I'm implementing a widget tool kit wich requires some symbols to be aligned with the Y axis.

These symbols are drawn using the model view matrix of the parent objects, causing them to be rotated as well.

The solution would be to apply a counter-rotation before rendering those symbols, but I have to keep track of every rotation (in my case only on Z axis), in order to apply the correct counter-rotation. Sadly, every rotation "out of control" will cause a misalignment between the real model view matrix rotation and the "global" rotation kept.

How would it possible to derive eurler rotation angles directly from the model view matrix?


Solution

  • Just clear the rotational part (the upper left 3x3) of the modelview matrix to identity. This removes any rotation, yet retains the translation.