Sign in to follow this  

(SOLVED) Reading Animation Keysets from x file

Recommended Posts

im writing a animationcontroller and fail to load animations using quaternions.
When i import the animation with matrixes it works fine.

So the reason have to be the quatertions..

This is the file:
|+ ID: 218 AnimationSet-Nr.: 3 'Animation_Run'
||+ ID: 219 Animation-Nr.: 39 controlls Bone 'Scene_Root'
|||- ID: 220 AnimationKeySet-Nr.: 115 TransformTyp=0 KeyFrameCount=96'
|||- ID: 221 AnimationKeySet-Nr.: 116 TransformTyp=1 KeyFrameCount=96'
|||- ID: 222 AnimationKeySet-Nr.: 117 TransformTyp=2 KeyFrameCount=96'
||+ ID: 223 Animation-Nr.: 40 controlls Bone 'root'
|||- ID: 224 AnimationKeySet-Nr.: 118 TransformTyp=0 KeyFrameCount=96'
|||- ID: 225 AnimationKeySet-Nr.: 119 TransformTyp=1 KeyFrameCount=96'
|||- ID: 226 AnimationKeySet-Nr.: 120 TransformTyp=2 KeyFrameCount=96'


AnimationKey {

In my code i map this file to a quatertion like this:

pKeyData == 0;4;1.000000,0.000000,0.000000,0.000000;;,
qResult.v.x = ((float*)(pKeyData + sizeof(DWORD)*2))[1];
qResult.v.y = ((float*)(pKeyData + sizeof(DWORD)*2))[2];
qResult.v.z = ((float*)(pKeyData + sizeof(DWORD)*2))[3];
qResult.a = ((float*)(pKeyData + sizeof(DWORD)*2))[0];

then i apply the matrices in orginal order like:

for (DWORD dw1=1;dw1<pAnimation->dwCountKeySets;dw1++)
matResult = matQuatertion[dw1]*matResult;
matBoneMatrix = matResult;

I just cant get it running :((

I wonder if i assign the data correct to the quatertion ?

[Edited by - KanTeH on December 6, 2010 1:43:08 PM]

Share this post

Link to post
Share on other sites
Are you parsing the x-file yourself, or loading it using a D3DX call?

In any case, it appears you're trying to load pKeyData. However, this code is incorrect:

pKeyData == 0;4;1.000000,0.000000,0.000000,0.000000;;,
qResult.v.x = ((float*)(pKeyData + sizeof(DWORD)*2))[1];

Do you mean something like:

pKeyData = { 0, 4, 1.0f, 0, 0, 0 };

It appears you need to learn how to step through your code in a debugger and check values as you go to ensure your code does what you want it to.

Share this post

Link to post
Share on other sites
ye sorry it was pseudocode.

I think i found the problem,
i jsut ignored the Typ of the Keyset and thought
it were always quatertions.

But only Typ 0 is a rotationquatertion
the others are scaling and translation Vectors.

Share this post

Link to post
Share on other sites
its solved :=)

the only thing im wondering about is that i have to apply the orginale bonematrix to it like:


but works as goos as matrixkeys now :)

Share this post

Link to post
Share on other sites
i have to apply the orginale bonematrix to it

That's how animation works. The "original" bone transform moves the vertex (which is in world-space) in the rest pose to bone space. The animation transform moves the vertex from bone space to world-space (animated position).

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