transformation matrix and camera

If I have a matrix( m[16] ) that contains the transformations on a scene, is it possible to find the direction the camera is facing in that scene? TIA.

-Drew

Hi !

Take a normalized vector that is pointing along the Z axis (same as the camera), muiltiply it with the matrix and you have the direction the camera is facing.

Mikael

Alright, that makes sense. Now I have this matrix:
m[0] m[4] m[8] m[12]
m[1] m[5] m[9] m[13]
m[2] m[6] m[10] m[14]
m[3] m[7] m[11] m[15]

( m[2], m[6], m[10] ) makes up the z-axis, ( m[1], m[5], m[9] ) makes up the y-axis, relative to the camera.

I would assume then that ( m[0], m[4], m[8] ) makes the x axis, relative to the camera.

Why then, in my code, when I try and print out the axis do the z, and y axis appear correctly, but the x axis seams to attempt to stay with the local coordinate system. Why does what I would assume is the x axis relative to the camera, appear to change magnitude( I am ploting a normalized vector from the origen) and direction when I rotate the local axis, but the other two remain where I believe they should be?

-Drew

mikael_aronsson is incorrect. To get the camera’s direction vector in world space, you want to find what -Z is when it is transformed back into world space – you multiply (0,0,-1) by the inverse of the view matrix.

Fortunately, that’s the same as this vector: ( -m[2], -m[6], -m[10] ).