Sign in to follow this  
Jacob Jingle

X File Transforms

Recommended Posts

I thought I had this down...But now I'm getting characters that look like their from the movie 'The Thing' or a Salvador Dali Painting, all stretched and deformed. Anyone know what's wrong with my transforms?
struct sBone
		D3DXMATRIX identity;
		m_frameTransform = m_toRoot = m_skinWeightOffset = m_Anim = m_finalTransform = identity;
	void ToRoot(D3DXMATRIX parent)
		m_toRoot = parent * m_frameTransform;
		for_each(m_vChildBones.begin(), m_vChildBones.end(), [&](std::tr1::shared_ptr<sBone> bone){ bone->ToRoot(m_toRoot);});
	void FinalTransform(D3DXMATRIX parent)
		m_finalTransform = m_skinWeightOffset * m_Anim * m_toRoot;
		for_each(m_vChildBones.begin(), m_vChildBones.end(), [&](std::tr1::shared_ptr<sBone> bone){ bone->FinalTransform(m_finalTransform);});
	std::string m_name;
	D3DXMATRIX  m_frameTransform;
	D3DXMATRIX  m_toRoot;
	D3DXMATRIX  m_skinWeightOffset;
	D3DXMATRIX  m_Anim;
	D3DXMATRIX  m_finalTransform;
        std::vector<std::tr1::shared_ptr<sBone>> m_vChildBones;

m_frameTransform = Frame::FrameTransformMatrix m_skinWeightOffset = SkinWeights::Offset m_Anim = AnimationSet::Animation matrix [Edited by - Jacob Jingle on March 11, 2010 3:15:01 PM]

Share this post

Link to post
Share on other sites
I'm not sure how you're calculating the animation matrix, but normally:

Each frame-

m_frameTransform = animTransform( time t );

where animTransform = lerp/slerp_local_anim(time t);

m_toRoot = m_frameTransform * parentToRoot; //NOTE THE ORDER!

final = skinOffset * m_toRoot;

The skinOffset moves the vertices from rest pose to bone space. The final transform moves the vertices from bone space to animation world space.

In words, finalTransform = (move from world rest pose to bone space) * (move from bone space to animated world).

If, for whatever reason, you want to preserve the FrameTransformMatrix, then:

m_toRoot = animTransform * parentToRoot;

Share this post

Link to post
Share on other sites

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