PDA

View Full Version : QMatrix4x4 to glTranslatef and glRotatef Values



andreoq
25th June 2011, 14:07
Hi,

I used QMatrix4x4 to save my transformation. I could also translate my OpenGL Matrix with ;


qreal *data = m.data();
glTranslatef(data[12], data[13], data[14]);


but i cant calculate rotation degrees from QMatrix4x4 for glRotatef simply! With complex math's would be calculable but than no sin to use QMatrix.

Thanks

Cruz
26th June 2011, 22:20
You could use glMultMatrixd() with the entire Matrix to apply your transformation in OpenGL instead of using glTranslatef() and glRotatef().
But what you really want is the Frame object from libQGLViewer (http://www.libqglviewer.com). You can apply translations and rotations to it or any transformations composed from a vector and an angle and it has a method to output the GLdouble* matrix for OpenGL directly.