05-23-2004, 09:31 AM
Ok, so the vertex v' that is passed into the clip matrix is given by...
v'=PMv
...where v is the current vertex, P is the projection matrix and M is the modelview matrix. Correct?
Now assume that we perform some transformations on the modelview matrix, as we often do, then the transformation becomes:
v'=P(MAB)v
...where A and B are the transformation matrices we multiply by. Now if the modelview matrix originates in identity form, then the transformation is:
v'=P(IAB)v=P(AB)v
...but what if we want to move the transformations A and B into the projection matrix? If we say that they are being applied to the projection matrix, we can say this:
v'=PMv=P(MAB)v=P(IAB)v=P(AB)v=P(AB)Iv=(PAB)Iv
[For the last 2 expressions, assume we simply keep the modelview matrix in identity form (hence the new I that appears), now the transformations apply directly to the projection matrix.]
So instead of:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glDoOtherMatrixStuffARB();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMultMatrixd(MatrixA);
glMultMatrixd(MatrixB);We do:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glDoOtherMatrixStuffARB();
glMultMatrixd(MatrixA);
glMultMatrixd(MatrixB);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();The math seems to work out, but the results are very different! Why is this?
v'=PMv
...where v is the current vertex, P is the projection matrix and M is the modelview matrix. Correct?
Now assume that we perform some transformations on the modelview matrix, as we often do, then the transformation becomes:
v'=P(MAB)v
...where A and B are the transformation matrices we multiply by. Now if the modelview matrix originates in identity form, then the transformation is:
v'=P(IAB)v=P(AB)v
...but what if we want to move the transformations A and B into the projection matrix? If we say that they are being applied to the projection matrix, we can say this:
v'=PMv=P(MAB)v=P(IAB)v=P(AB)v=P(AB)Iv=(PAB)Iv
[For the last 2 expressions, assume we simply keep the modelview matrix in identity form (hence the new I that appears), now the transformations apply directly to the projection matrix.]
So instead of:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glDoOtherMatrixStuffARB();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMultMatrixd(MatrixA);
glMultMatrixd(MatrixB);We do:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glDoOtherMatrixStuffARB();
glMultMatrixd(MatrixA);
glMultMatrixd(MatrixB);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();The math seems to work out, but the results are very different! Why is this?