How to calculate a bones offset matrix

Started by
2 comments, last by JackOfAllTrades 14 years, 1 month ago
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
Advertisement
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].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.
am i inversing the local or combined transformation matrix?
Thanks.
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"?

This topic is closed to new replies.

Advertisement