Hello,
I am hoping someone expert at matrix transformations can help me. I have an openGL app where I have a scene set up, and I allow the user to ‘twist’ rotate around a certain point in the scene. I use these calls to do it:
glPushMatrix();
glLoadMatrixf((GLfloat *)currentRotationMatrix);
glScalef(defaultWorldScale,defaultWorldScale,defaultWorldScale);
glScalef(drawScale,drawScale,drawScale);
glTranslatef(xTrans, yTrans, zTrans);
glTranslatef(twistx, twisty, twistz);
glGetFloatv(GL_MODELVIEW_MATRIX, TempRotationMatrix);
glRotatef(-zr, ((float *)TempRotationMatrix)[2], ((float *)TempRotationMatrix)[6], ((float *)TempRotationMatrix)[10]);
glTranslatef(-twistx, -twisty, -twistz);
glTranslatef(-xTrans, -yTrans, -zTrans);
glScalef(1.0/drawScale,1.0/drawScale,1.0/drawScale);
glScalef(1.0/defaultWorldScale,1.0/defaultWorldScale,1.0/defaultWorldScale);
glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *)currentRotationMatrix); // save for later
glPopMatrix();
So, I have a currentRotationMatrix and then the other transforms are to get it out to a point in space where I want to do the twist. Then I do it and reverse my setup transformations.
This works, but what I end up with is a rotationMatrix that has been dirtied with extra translation values. I want to keep my rotationMatrix as only rotations. Is there any way to take the translation values that appear in my final matrix and incorporate them into my translation values xTrans yTrans zTrans? I have experimented but cannot figure out how to do it.
I hope this question makes sense – basically I try to compose my scene from xyz translation variables and XYZ euler rotation variables. But when I interactively make changes, I don’t quite know how to separate them back out.
Thanks for any advice
Bob