Sign in to follow this  

How to calculate a bones offset matrix

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

building my own math and animation library at the moment and would like to find out how i would go about calculating a bones offset matrix. I can't find much out about this other than the usual formulas using directx api. Cheers

Share this post


Link to post
Share on other sites
Quote:
Original post by jmgunn87
building my own math and animation library at the moment and would like to find out how i would go about calculating a bones offset matrix. I can't find much out about this other than the usual formulas using directx api.
Cheers


I did this awhile ago, not sure if my code will help but I'll post it anyway:


void SetMatrices( int bone, cml::matrix44f_r matrix )
{
cml::matrix44f_r inv_matrix, inv_mesh_bone, tmatrix;
bones[bone]->get_global_pose().getColumnMajor44( matrices[bone].data() );
inv_mesh_bone = cml::inverse(mesh->bones[bone].matrix);
matrices[bone] = inv_mesh_bone * matrices[bone];
inv_matrix = cml::inverse(matrix);
tmatrix = matrices[bone] * inv_matrix;
for (UINT i = 0; i < mesh->bones[bone].childen.size(); i++)
{
cml::matrix44f_r child;
cml::matrix_translation(child, mesh->bones[mesh->bones[bone].childen[i]].matrix.data()[12], mesh->bones[mesh->bones[bone].childen[i]].matrix.data()[13], mesh->bones[mesh->bones[bone].childen[i]].matrix.data()[14] );
E_PROP::SetMatrices( mesh->bones[bone].childen[i], child * tmatrix * matrix );
}
}



Notice how it uses a function that calls it's self to process each child bone which then does the same for the child's child bones and so on.

Share this post


Link to post
Share on other sites
Quote:
Original post by jmgunn87
am i inversing the local or combined transformation matrix?
Thanks.


local... I think... It's been awhile since I've even looked at this code...

It's basically taking the difference from the bones original position and it's current position then passing it down to the child bones...

Wait I think this code converts the the physic engine's actor positions to matrices that a shader can use to do skinning.

What do you mean by "calculate a bones offset matrix"?

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this