(SOLVED) Reading Animation Keysets from x file

Started by
4 comments, last by KanTeH 13 years, 5 months ago
Hi,
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'
..
..
[/qoute]


Quote:
AnimationKey {
0;
96;
0;4;1.000000,0.000000,0.000000,0.000000;;,
1;4;1.000000,0.000000,0.000000,0.000000;;,
2;4;1.000000,0.000000,0.000000,0.000000;;,
3;4;1.000000,0.000000,0.000000,0.000000;;,



In my code i map this file to a quatertion like this:
Quote:
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:
Quote:
matResult.SET_Identify();
for (DWORD dw1=1;dw1<pAnimation->dwCountKeySets;dw1++)
{
GetMatrixFromKeySet(matQuatertion[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]
Advertisement
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.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

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.


its solved :=)

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

TransformMatrix*ScaleMatrix*RotationMatrixFromQuatertion*OrgianlBoneMatrix

but works as goos as matrixkeys now :)
Quote: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).

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

yep ur right, but u forget the offsetmatrix.

I was wondering because if u get matrixes from the animationdata u dont have to add the framematrix.

This topic is closed to new replies.

Advertisement