PDA

View Full Version : Trouble with transformations ...



fuxiulian
12-13-2003, 08:06 AM
Hello !

I wonder why I get different results with these 2 parts of code:




VECTOR4D v(0,0,1,1);

MATRIX4X4 m;
m = projMat * viewMat;
v = m * v;

glColor4f(1, 1, 0, 1);

glBegin(GL_POINTS);
glVertex3fv(v);
glEnd();


and





VECTOR4D v(0,0,1,1);

glMultMatrixf(projMat);
glMultMatrixf(viewMat);

glColor4f(1, 1, 0, 1);

glBegin(GL_POINTS);
glVertex3fv(v);
glEnd();


Shouldn't the transformations be the same ?

[This message has been edited by fuxiulian (edited 12-13-2003).]

fuxiulian
12-13-2003, 08:09 PM
I have found the answer.

The problem was the w coordinate which I neglect during the rendering.

To solve that there are 2 methods:

use glVertex4f{v} ...or multiply x, y, z by 1/w

I have lost 1 day to figure this out. I thought I was going crazy... http://www.opengl.org/discussion_boards/ubb/wink.gif