Jump to content
• Advertisement

# How to calculate a bones offset matrix

This topic is 3150 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

##### Share on other sites
Advertisement
Quote:
 Original post by jmgunn87building 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].matrix.data()[12], mesh->bones[mesh->bones[bone].childen].matrix.data()[13], mesh->bones[mesh->bones[bone].childen].matrix.data()[14] );			E_PROP::SetMatrices( mesh->bones[bone].childen, 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

##### Share on other sites
am i inversing the local or combined transformation matrix?
Thanks.

#### Share this post

##### Share on other sites
Quote:
 Original post by jmgunn87am 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

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 14
• 9
• 10
• 12
• 17
• ### Forum Statistics

• Total Topics
632909
• Total Posts
3009172
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!