Getting the Absolute Rotation Angles

I figured out a way to rotate the Model matrix against the screen X and Y axis by rotating against an Identity matrix then multiplying my matrix against the rotated Identity matrix. This way my model rotates on an axis perpendicular to the mouse cursor vector.

But this uses incremental values from the mouse so I need a way of getting the absolute XYZ rotation angles. I posted the code that does the rotation below. Maybe someone has done this before and can help me out. I know all three angles are getting rotated,not just the X & Y. I just need a way to track or extract the current rotation angles.

m_worldRotMatrix is a 4x4 array set to an Identity matrix in CGLViews’ constructor.

//PAINT
void CGLView::OnPaint()
{
CProBotDoc* pDoc = GetDocument();
CPaintDC dc(this); // device context for painting

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();			//Load the Identity Matrix
glRotated(m_xRot,1,0,0);	//Incremental from MouseMove()
glRotated(m_yRot,0,1,0);	//Incremental from MouseMove()
m_xRot = 0;					//Keep scene from rotating on other Paint calls
m_yRot = 0;					//Keep scene from rotating on other Paint calls
glMultMatrixd((GLdouble *)m_worldRotMatrix); //Multiply Identity Matrix by current Worldview Matrix
glGetDoublev(GL_MODELVIEW_MATRIX, (GLdouble *)m_worldRotMatrix);//Store the new Worldview Matrix 
pDoc->Render();//Render the scene using the persistant Worldview Matrix

SwapBuffers(dc.m_ps.hdc);

}

This is wher I lose the angles because Im feeding glRotated() incremental angles.

//MOUSE MOVE
void CGLView::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_leftButtonDown)
{
//…
//…
//…

	//Rotate active
	if (m_rotate)
	{
		CSize rotate = m_MouseDownPos - point;
		m_xRot = -(GLdouble)rotate.cy/4;
		m_yRot = -(GLdouble)rotate.cx/4;
		m_MouseDownPos = point;
		InvalidateRect(NULL,FALSE);
	}

	//...
	//...
	//...
}

}

I use this if I want to SET the Absolute Rotation Angles. Like from Front, Right, Top etc tool buttons.

// SET ABSOLUTE WORLD ROTATION
void CGLView::SetWorldRotation(GLdouble x, GLdouble y, GLdouble z)
{
glPushMatrix();
glLoadIdentity();
glGetDoublev(GL_MODELVIEW_MATRIX, (GLdouble *)m_worldRotMatrix);
glRotated(x, 1, 0, 0);
glRotated(y, 0, 1, 0);
glRotated(-z, 0, 0, 1);
glMultMatrixd((GLdouble *)m_worldRotMatrix);
glGetDoublev(GL_MODELVIEW_MATRIX, (GLdouble *)m_worldRotMatrix);
glPopMatrix();
}

Thanks