Getting positions and rotations for a limb?

Pseudo code below:

glPushMatrix();
glRotatef(100,1,0,0);;
glRotatef(50,0,1,0);
glRotatef(100,1,0,0);
glTranslatef(x0,y0,z0);
glCallList(dl0);

glPushMatrix();
glRotatef(50,1,0,0);;
glRotatef(50,0,1,0);
glRotatef(50,1,0,0);
glTranslatef(x1,y1,z1);
glCallList(dl1);

glPushMatrix();
glRotatef(50,1,0,0);;
glRotatef(100,0,1,0);
glRotatef(50,1,0,0);
glTranslatef(x2,y2,z2);
glCallList(dl2);

Relative to 0, how would I determine the translation and rotation value for the last Display List in this series, if I were exporting it like a scene? If there were no rotations, I would just add all of the translations up, but when a rotation is performed, it is a different story. Is there a quick and simple way to get that translation value relative to the origin and the rotation value that I need to use so it is also rotated the same way as when called this way? Like if I were editing the vertex data of something to be rotated and placed just like in the OpenGL window after the pushes, rotations, and translations? Thank you!

[QUOTE=Flotonic;1248336]Pseudo code below:

...how would I determine the translation and rotation value for the last Display List in this series, if I were exporting it like a scene?[/QUOTE]

Do the transforms with the matrix stack, then query back the matrix.  The translation is in the last column.  The upper-left 3x3 are the rotation matrix (orthonormal basis vectors).  Decompose into whatever form you want to represent the rotation transform in.

Thank you so much for your response, Dark Photon! It is now getting the correct translations, but rotations are another thing. I am getting the matrix with the following code:

GLint matrix[16]; glGetIntegerv(GL_MODELVIEW_MATRIX,matrix);

I have been searching for hours but have still yet to find a function that decomposes the matrix to X, Y, Z Euler angles. Do you happen to have any code from a project of yours that happens to do this that you can share, or is there a way to get the final rotation by doing some sort of calculations with the previous rotations? Thanks again!

GLint matrix[16]???

Think you mean GLfloat matrix[16] and glGetFloatv().

Thanks! It is now a little closer! Some of the rotations are correct while others are wrong. Do you think it may have something to do with axis ordering?

GLfloat matrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX,matrix);
float xR, yR, zR;
EulerAnglesFromMatrix(&xR,&yR,&zR,matrix);
#define RADTODEG (M_PI/180)
xR/=RADTODEG;
yR/=RADTODEG;
zR/=RADTODEG;

Function:

void EulerAnglesFromMatrix(float *attitude, float *heading, float *bank, GLfloat *mat) {
     if ( mat[6] > 0.998 || mat[6] < -0.998 ) {
         *heading = atan2( -mat[8], mat[0] );
         bank = 0;
     } else {
         *heading = atan2( mat[2], mat[10] );
         *bank = atan2( mat[4], mat[5] );
     }     *attitude = asin( mat[6] );
}