Sign in to follow this  

Milkshape Format - Building Animated Skeleton Joints?

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

Hi All, this is a really simple problem, well I thought it was simple, but I can't solve it...basically, I've reading in some simple data from a milkshape file, just 3 joints, with a few test animation frames. Now I'm having a problem with the rotations and putting it together, and wanted to know if I'm doing it right, or if theres some hidden trap door in the ms3d format. Basically, we have the reference position/rotation for each joint. So first, I build up all the matrices down the joint. This seems okay. Then I have the keyframe joint rotations/positions, which I build up down the joints seperately. I'm doing it this way for testing. For each vertice, I perform the inverse matrix translation using the reference matrix. Then I do the keyframe rotation & position translation from the keyframe joint index. Then I multiply by the reference matrix (the on I multiplied by the inverse). Now from what I can work out, it seems okay when I don't do any rotations on each joint, the translation works okay...but the keyframe rotations just seem to scramble the data. I've tried doing a simplified model and following things along each joint...was wondering on any ideas on what I might be missing? Any tips of how to debug/fix this? Thanks, Ben

Share this post


Link to post
Share on other sites
Solved it! Thing my problem was in that I was doing a mismatched order of multiplying the reference/keyframe matrices.

Best way to solve it, I just got down to the simplest form I could, just 3 bones, and just expanded the matrix multiplications, and checked each result, once I was sure things where turning out as what they should be, I could start reimplementing the recursive tree of building the joint matrix hierarchies.

So for my simple 3 joint example I did:
( Use point 0,0,0, so I could determine if it would move the point to the position of the joint)
Later on I could do the inverse matrix multiplication, followed by the keyframe multiplication

D3DXMATRIX RR0 = body[0].matRefRot;
D3DXMATRIX RT0 = body[0].matRefTran;
D3DXMATRIX KR0 = body[0].matKeyFrameRot;
D3DXMATRIX KT0 = body[0].matKeyFrameTrans;

D3DXMATRIX RR1 = body[1].matRefRot;
D3DXMATRIX RT1 = body[1].matRefTran;;
D3DXMATRIX KR1 = body[1].matKeyFrameRot;
D3DXMATRIX KT1 = body[1].matKeyFrameTrans;

D3DXMATRIX RR2 = body[2].matRefRot;
D3DXMATRIX RT2 = body[2].matRefTran;;
D3DXMATRIX KR2 = body[2].matKeyFrameRot;
D3DXMATRIX KT2 = body[2].matKeyFrameTrans;

D3DXVECTOR3 v0 = D3DXVECTOR3(0,0,0);
D3DXMATRIX m0 = (RR1*RT1) * (RR0*RT0);
D3DXVec3TransformCoord(&v0,&v0, &m0);


D3DXVECTOR3 v1 = D3DXVECTOR3(0,0,0);
D3DXMATRIX m1 = KR1*(RR1*RT1) * KR0*(RR0*RT0);
D3DXVec3TransformCoord(&v1,&v1, &m1);

D3DXMATRIX mR2 = (RR2*RT2) * (RR1*RT1) * (RR0*RT0);

D3DXVECTOR3 v2 = D3DXVECTOR3(0,0,0);
D3DXMATRIX m2 = KR2*(RR2*RT2) * KR1*(RR1*RT1) * KR0*(RR0*RT0);
D3DXVec3TransformCoord(&v2,&v2, &m2);


Thanks,

Ben

Share this post


Link to post
Share on other sites

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