# How to take a combined matrix back to bone space?

This topic is 741 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

If I have calculated the combined matrix for every bone,
How do I convert it back into local matrices in bone space.
Do I just multiply the combined matrix with the inverse of the offset matrix of the bone?
I can't get it to work?
Thanks
Jack

##### Share on other sites
Are you trying to convert between two different bones? If so: inverse(combinedMatrix2) * combinedMatrix1

If you're trying to get the local matrix of a bone in the same bone's space, that's pointless: It's always going to be the identity matrix.

(edit: checked multiplication order and fixed) Edited by Nypyren

##### Share on other sites

Hello,

What I am playing with is after my bvh component has finished calculating all the bones combined matrices,

I actually want to blend them with other stuff like the IK and rest of the animations.... shaking hands,

sitting down whatever,  I actually want to render the bvh data into the animation controller, so the mixing can be realized, but the bvh component is actually outputting combined matrix, my initial project was based on the bvh rendering directly into the rendering pipeline, Now some change is needed.

Thanks

Jack

##### Share on other sites

OK, I solved it

Actually, after resolving the combined matrix from the animation controller

I just add on to bvh

bvhMat += matCombined;


Then IK

Thanks

Jack

##### Share on other sites

I am wondering what this does?
What do you mean by "convert between two different bones"?
Do I move the first bone space to another, so that two bone spaces are in the same
space?

inverse(combinedMatrix2) * combinedMatrix1
Edited by lucky6969b

##### Share on other sites

I am wondering what this does?
What do you mean by "convert between two different bones"?
Do I move the first bone space to another, so that two bone spaces are in the same
space?

inverse(combinedMatrix2) * combinedMatrix1

That's for making a matrix representing bone1's combined transform, but in bone2's local space instead of whatever space the combined transforms are in (world space?).

I don't know if you need that or not. I'm confused by your posts :) Edited by Nypyren

##### Share on other sites

Hello,
From the pseudocode underneath,
Then I multiply with the parent's transformation matrix
to get frame.ToRoot?
Then I multiply the mesh offset matrix with the inverse of this frame.ToRoot Matrix?
Thanks
Jack

function CalcToRootMatrix( Frame frame, Matrix parentMatrix )
{
// transform from frame-space to root-frame-space through the parent's ToRoot matrix
frame.ToRoot = frame.ToParent * parentMatrix;

for each Child in frame: CalcToRootMatrix( Child, frame.ToRoot );
}

// Note: MeshFrame.ToRoot is the transform for moving the mesh into root-frame space.
function CalculateOffsetMatrix( Index boneIndex )
{
string boneName = SkinInfo.GetBoneName( boneIndex );
Frame boneFrame = FindFrame( root_frame, boneName );
// error check for boneFrame == NULL if desired
offsetMatrix[ boneIndex ] = MeshFrame.ToRoot * MatrixInverse( boneFrame.ToRoot );
}


BTW, if I want to take the combined matrix to transformation matrix.

That is the matrix that has an offset to the parent and some rotation elements around the root?

Do I multiply the combined matrix with the inverse of the offset matrix? or with the frame.ToRoot

matrix?

Edited by lucky6969b

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634046
• Total Posts
3015219
×