# Skeletal model display/calculatation problems

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

## Recommended Posts

Hi, I am at the moment testing rendering a skeleton from an SMD file, but things aren't going so smoothly. The following is my code which sets up (or attempts to) the matrices for each bone -

for(Count = 0; Count < NumBones; Count++) {
D3DXMatrixIdentity(&Matrices[Count]);

D3DXMatrixRotationYawPitchRoll(&TempMatrix, RotX, RotY, RotZ);
Matrices[Count] *= TempMatrix;

D3DXMatrixTranslation(&TempMatrix, PosX, PosY, PosZ);
Matrices[Count] *= TempMatrix;

if(Bones[Count].Parent > -1) {
Matrices[Count] *= Matrices[Bones[Count].Parent];
};
};


The following information is written in the SMD specification - <PosX> <PosY> <PosZ> is the position in world units (good to 6 significant digits). <RotX> <RotY> <RotZ> are local Euler rotations in radians. Bones which are not children of the world report their position and rotations in their parent's local space. I have tried re-arranging virtually everything I can think of (as my matrix maths isnt too good trial and error gets a good look in) and i have gone from results that look like a complete mess to some that have looked to be close, but with the odd joint or 2 pointing off in the wrong direction giving the skeleton a deformed look. Is there any obvious mistake in the above code, or have I not taken something into account from the spec? Here is a screenshot of mine (on the outsides) versus milkshape 3D (on the inside) to illustrate - Skeleton Thanks Zak

##### Share on other sites
Are you sure the application that generated the SMD file applies the euler angles in the same order as D3DXMatrixRotationYawPitchRoll in order to construct the rotation matrix? You can try generating each euler rotation manually by calling D3DXMatrixRotation[X,Y,Z] and then multiplying those 3 matrices in the correct order.
Also, yaw is rotation around the Y axis and pitch around the X axis, so you should probably switch the RotX and RotY parameters to D3DXMatrixRotationYawPitchRoll.

1. 1
Rutin
24
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 46
• 41
• 23
• 13
• ### Forum Statistics

• Total Topics
631746
• Total Posts
3002023
×