View Full Version : ransformation: object to eye coordinates

08-11-2011, 04:29 AM
Hi all,

I'm in trouble with a transformation. I have to transform a vertex with the actual matrix. Here ist the codefragment:

GLdouble mat[16];

glTranslated(dx, dy, dz);
glGetDoublev(GL_MODELVIEW_MATRIX, mat);

at this point I should have the matrix use by OpenGl to transform vertizees according to the actual translate, rotate and stretch values saved in the array mat.

glVertex3d(v0.x, v0.y, v0.z);

the following calculation should have the same result vor v0

xEye = mat[0]*v0.x + mat[4]*v0.y + mat[8]*v0.z + mat[12];
yEye = mat[1]*v0.x + mat[5]*v0.y + mat[9]*v0.z + mat[13];
zEye = mat[2]*v0.x + mat[6]*v0.y + mat[10]*v0.z + mat[14];

Is this correct?
Is there a better way to do this calculation, probably any openGl function?

Thank you all for your help!

08-11-2011, 10:07 AM
Open GL does not include vector matrix multiplication.
You will need to implement your own matrix class to handle that.
Looks like you have started that process already.