er… yes… and the code to rasterise that polygon for a VGA card is as follows… ;>
hmm. suppose you have a vertex you know is at [1,2,3], and you do some arbitary transformations to it, and you want to know the world coordinates of the vertex after these transformations so you can save it to your file. Here’s some code to do it. It’s not neccessarily the BEST way of doing this, and it’s written off the top of my head, but here goes.
gldouble modelview[16], vprime[4], v[4]={1.0, 2.0, 3.0, 1.0};
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(1.0, 2.0, 3.0, 4.0);
glTranslatef(5.0, 6.0, 7.0);
/* now we have the transformation matrix T… */
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
/* now we have to transform the point… */
int i, j;
for(i=0; i<4; i++) {
vprime[i]=0.0;
for(j=0; j<4; j++) {
vprime[i]+=modelview[j*4+i]*v[i];
}
}
/* convert the transformed pt from homogeneous to cartisian pt */
for(i=0; i<3; i++)
vprime[i]/=vprime[3];
and now our transformed point v[] is in vprime[]. veeeeery laborious, but you should get the idea…
hope this helps!
cheers,
John
i THINK the matrix is column major… but i could be wrong.