deshan

12-05-2013, 02:27 AM

Hi all,

I am trying to extract the forward vector from 4x4 transformation matrix.

I have two forms of calculation one is for nodes in the scene graph and other is for camera.

This is how I calculate transformation matrix for node.

// Matrix44 is a float[16]

Matrix44 nodeTranslationMat; // translation matrix for node

Matrix44 nodeRotationMat; // rotation matrix for node

Matrix44 transformationMatrix= nodeTranslationMat* nodeRotationMat; // transformation matrix

And this is how I do it for camera

Matrix44 cameraTranslateMat; // translation matrix for camera

Matrix44 cameraRotationMat; // rotation matrix for camera

Matrix44 transformationMatrix= cameraRotationMat* cameraTranslateMat; // transformation matrix, note - multiplication order is different form node

And then for the camera forward vector I can extract using above transformation matrix like

Vector3f forwardVector = Vector3f(transformationMatrix[2], transformationMatrix[6], transformationMatrix[10]);

But If I do this above to find the forward vector for node it's not works.

Could you please help me to find it it?

I am trying to extract the forward vector from 4x4 transformation matrix.

I have two forms of calculation one is for nodes in the scene graph and other is for camera.

This is how I calculate transformation matrix for node.

// Matrix44 is a float[16]

Matrix44 nodeTranslationMat; // translation matrix for node

Matrix44 nodeRotationMat; // rotation matrix for node

Matrix44 transformationMatrix= nodeTranslationMat* nodeRotationMat; // transformation matrix

And this is how I do it for camera

Matrix44 cameraTranslateMat; // translation matrix for camera

Matrix44 cameraRotationMat; // rotation matrix for camera

Matrix44 transformationMatrix= cameraRotationMat* cameraTranslateMat; // transformation matrix, note - multiplication order is different form node

And then for the camera forward vector I can extract using above transformation matrix like

Vector3f forwardVector = Vector3f(transformationMatrix[2], transformationMatrix[6], transformationMatrix[10]);

But If I do this above to find the forward vector for node it's not works.

Could you please help me to find it it?