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
Changing the order of rotation and translation makes for two different transformations … reasonably with two different z-vectors in the output transformation-matrix.
deshan,
have you checked the visual differences between the two transformations?
If you do two nodes, one with each transformation … you’ll see why you may not be able to match up the two ‘forward’ vectors.
A ‘forward’ vector is not an inherent quality of a matrix … it may fit the z-vector for the camera, but did you make your node in coordinates, where the z-vector is ‘forward’?