jkj2000

11-11-2007, 03:47 PM

I'm looking at a code snippet and I can't understand what the point of the series of transformations is. Could someone help me?

libMatrix M;

libMatrix FinalMatrix;

glPushMatrix();

glLoadIdentity();

glMultMatrixf(node->matrix[0][0]);

glTranslatef(-(node->center->pivot[0]), -(node->center->pivot[1]), -(node->center->pivot[2]));

lib_Matrix_Copy(M, node->matrix); //make "M" the inverse

lib_Matrix_Inverse(M);

glMultMatrixf(&M[0][0]);

glGetFloatv(GL_MODELVIEW_MATRIX, FinalMatrix);

glPopMatrix();

FinalMatrix is then used in various transformations down the line.

I understand the individual steps involved but I can't put together the goal of this sequence. What's the point of transforming the modelview matrix, then translating to the center of the object, then applying the inverse of the original matrix? When would you do this?

libMatrix M;

libMatrix FinalMatrix;

glPushMatrix();

glLoadIdentity();

glMultMatrixf(node->matrix[0][0]);

glTranslatef(-(node->center->pivot[0]), -(node->center->pivot[1]), -(node->center->pivot[2]));

lib_Matrix_Copy(M, node->matrix); //make "M" the inverse

lib_Matrix_Inverse(M);

glMultMatrixf(&M[0][0]);

glGetFloatv(GL_MODELVIEW_MATRIX, FinalMatrix);

glPopMatrix();

FinalMatrix is then used in various transformations down the line.

I understand the individual steps involved but I can't put together the goal of this sequence. What's the point of transforming the modelview matrix, then translating to the center of the object, then applying the inverse of the original matrix? When would you do this?