• ### Popular Now

• 12
• 10
• 10
• 13
• 10

#### Archived

This topic is now archived and is closed to further replies.

# Problem with Advanced Animation book

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

## Recommended Posts

I''m trying to learn the skeletal animation system as described by Jim Adams in his book Advanced Animation... The demo program in chapter 5 SkeletalAnim works reasonably well, but there are small artifacts in the rendering of the tiny.x model when compared to Microsoft''s original SkinnedMesh sample (also using tiny.x). It is evident on both my systems and I wonder if others also have noticed this? The real problem however comes when trying out SkeletalAnim with other skinned meshes (in this case exported from CharacterFX). The models and textures appear correct, but the animations are very weird, as if the bones are transformed in the wrong way. Again everything works fine in the SkinnedMesh sample. If there is a solution or fix to this, please let me know! I would much rather use Jim''s codebase than having to delve into Microsoft''s hellish (but working) code.

##### Share on other sites
would it be possible for you to email(andrewqq@msn.com) or post the code for that?

Im trying to learn skeletal animation too, but there is a lack of tutorials on it!

##### Share on other sites
I found that when using models from TrueSpace or Milkshape I needed to add in the following templates to get the models to load correctly: XSkinMeshHeader, VertexDuplicationIndices, and SkinWeights. I should not have needed to add them, but it works with them in and I have not bothered with finding out why yet. I have not seen any artifacts that I do not see in the DX MeshViewer. Tiny''s shirt poking out of the jacket. My models and converted Milkshape ones work fine animation and all. JohnnyBravo, do yourself a favor and buy the book it explains the code and you might learn something.

##### Share on other sites
Well, happy to hear somebody got it working! I have those templates and my ''custom'' animations look perfect both in the MeshView utility and the SkinnedMesh sample. But in Jim''s sample the bones move in the opposite direction that they should or is plain wrong. Has nobody else used the book and seen this?

Perhaps there is something wrong with CharacterFXs exporter but then it should be wrong in MeshView also, and not only SkeletalAnim? Confused.

Also to johnnyBravo - the book is rather involved with several chapters building on the concepts, and it would be smarter to buy it.

##### Share on other sites
Cuculain,
I''m the one that posted about getting the code to work. I forgot that I had to add an UpdateMeshes function similar to Jim''s DrawMeshes function. I made a bunch of other changes to his common code too. But the UpdateMeshes should get it to work for you. If not can you post your model?

##### Share on other sites
This is exactly the same problem that I have been struggling with for a few days! I posted a request for help before spotting this thread, sorry. Here is my thread, which includes a link to a .zip with a very basic model that illustrates the problem.

http://www.gamedev.net/community/forums/topic.asp?topic_id=192548

Cuculain, if you resolved this issue, could you please post how?

dmorton, could you take a look at my model file and see if you can remember which bits of code you had to change to make the chapter 5 demo work?

Anyone else got any ideas?

*beg*

Atlay

##### Share on other sites
Hi, Cuculain!
I think I know where the problem lies. If you look carefully at your x.file code, the rotation is recorded in quaternion. The description of quaternion as stated in DirectX documentation is that the rotation is done counter-clockwise. That is to say, if you are rotating by using rotation matrix, then you need to take care of the direction of rotation because matrix rotation is carried in clockwise manner along its axis of rotation, unlike quaternion rotation which is done in counter-clockwise manner. Simply put, if you read in the quaternion and then convert it to rotation matrix, just remember to do this, (2 * PI) - rotational angle. Hope this helps!
[Edited]Oops! I was actually looking at Atlay x.file. Anyway, I believe the problem could be similar for you too.

[edited by - QueSerraSerraBoY on November 22, 2003 9:34:05 PM]

##### Share on other sites
I had a problem were my animations were all messed up similar to what you are describing. I'm not sure if it's the exact same problem, but here is the solution to the problem I had:

In the update animation function, change this:

// slerp rotation valuesD3DXQUATERNION quatRotation;D3DXQuaternionSlerp(&quatRotation,&Anim->m_RotationKeys[Key1].m_quatKey,&Anim->m_RotationKeys[Key2].m_quatKey,Scalar);

To this:

D3DXQUATERNION quatRotation, q1,q2;q1.x = -Anim->m_RotationKeys[Key1].m_quatKey.x;q1.y = -Anim->m_RotationKeys[Key1].m_quatKey.y;q1.z = -Anim->m_RotationKeys[Key1].m_quatKey.z;q1.w = Anim->m_RotationKeys[Key1].m_quatKey.w;q2.x = -Anim->m_RotationKeys[Key2].m_quatKey.x;q2.y = -Anim->m_RotationKeys[Key2].m_quatKey.y;q2.z = -Anim->m_RotationKeys[Key2].m_quatKey.z;q2.w = Anim->m_RotationKeys[Key2].m_quatKey.w;D3DXQuaternionSlerp(&quatRotation, &q1, &q2, Scalar);

See if that works.

[edited by - MagTDK on November 23, 2003 1:27:30 AM]

##### Share on other sites
Haven''t worked with this in a bit so I don''t recall the details. But I seem to remember that the problem wasn''t in the sample code but in the X-file itself, possibly with some templates. Microsofts apps might be more forgiving/backwardly compatible than the sample.

Anyway, your provided X-file uses an older x-file version I think. Try replacing everything in the beginning before Frame ... (also Header I think) with:

xof 0303txt 0032

// DirectX - from CharacterFX

{
<3CF169CE-FF7C-44AB-93C0-F78F62D172E2>
WORD nMaxSkinWeightsPerVertex;
WORD nMaxSkinWeightsPerFace;
WORD nBones;
}

template VertexDuplicationIndices
{

DWORD nIndices;
DWORD nOriginalVertices;
array DWORD indices[nIndices];
}

template SkinWeights
{
CSTRING transformNodeName;
DWORD nWeights;
array DWORD vertexIndices[nWeights];
array FLOAT weights[nWeights];
Matrix4x4 matrixOffset;
}

Tell me if that doesn''t work. At least I solved it somehow (simple) and I don''t think it was math-related.

##### Share on other sites
Would any of you who are having problems with this sample code still recommend the book? Or maybe suggest an alternative as I am currently looking into it for my game Parp! Cheers in advance.

http://www.jeremypardon.com