Followers 0

# Issue combining matrix components

## 3 posts in this topic

Previously I was multiplying 2 matrices together to do my bone transformations, but now I've broken the matrices down into scale, rotation, translation components. My goal is to work with the component parts so I can perform proper lerping and then combine the final result into a matrix to send off to the GPU. I'm having a problem combining things in this form though.

This is what I did previously: C = A * B. Where those are all matrices. That worked fine. Now what I'm doing is:

C.rotation = A.rotation * B.rotation;
C.translation = A.translation + B.translation;
C.scale = A.scale * B.scale;


Rotation is a quaternion, translation and scale are vector3s. When I combine these 3 components of C into a matrix again: Matrix.Scaling(Scale) * Matrix.RotationQuaternion(Rotation) * Matrix.Translation(Translation) the result is wrong, and my model looks like a collapsed blob.

I'm not sure if this matters, but the original info coming from the model file is a matrix, so I have to decompose the matrix into the 3 component parts on load, which I then store and use for these calculations.

Anyone know what I'm doing wrong here?
1

##### Share on other sites

It is just a matter of interpretation. Keeping the components isolated for bone animation to use slerp for the rotation is common. The interpretation of the 3 components should be: I have a bone at position X(=translation) which point in the direction of Y (=rotation) of size Z(=scale). This way you need to combine the matricies like this

// Order: first scale, then rotate, then move, applying from right to left:
final = translation * rotation * scale;



If you need the inverse, you need to reverse the order too:

// Order: first scale, then rotate, then move, applying from right to left:
inv(final)
= inv(translation * rotation * scale)
= inv(scale) * inv(rotation) * inv(translation)


Edited by Ashaman73
1

##### Share on other sites
Ah ok, so basically I need to keep them separate for the interpolation and then after that's done, build the matrix and then do the hierarchy multiplication. I've got it working now, thanks for the help guys.
0

## Create an account

Register a new account