View Full Version : Frames of reference, how to go from one to another

03-18-2009, 03:25 PM
I'm working on a program that shoots particles from the camera's point of view. Thing is, the camera's X, Y and Z axes, and its origin O, are currently given to me in world coordinates.

If I do the following the particles will shoot correctly, down the camera's Z axis. What I don't understand is why this works:

//modelview matrix is set elsewhere

float matrix[16] = {
X.x, X.y, X.z, 0,
Y.x, Y.y, Y.z, 0,
Z.x, Z.y, Z.z, 0,
O.x, O.y, O.z, 1


//call glVertex() etc from here

Can someone explain to me why it is that multiplying the current modelview matrix with this one puts subsequent glVertex() and other such calls in the camera's frame of reference?

I understand the idea behind the modelview matrix and transformations in general, but going from one frame of reference to another (world to camera, for instance) is still tough for me to apply in practice.

Thanks for your help!