Skip to main content
gamedev.net
🔒 Locked

debugging animations...

Started by charpi Apr 24, 2009 at 8:47 PM 3 replies 900+ views
Original Post
charpi
charpi
Hi all, I've got a problem with animations in my program - the animations are not working out correctly. Much as I want to post the exact problem, I doubt I could video it down or something and upload it somewhere (as compared to skinning problems etc where I could just take a screenshot and host it somewhere) so I'm just asking for tips which could make my animation go wrong. Some info, I'm using directx .x file but I'm writing my own loader to load it, no directX API is used at all I'm using matrix keyframed animations I'm using bones and skeletal animation So all I'm asking for is some common errors which are normally faced when writing your own animation loader. Since my code compiles and runs well this is probably not a runtime error, more likely a logic error. I can post the code too if you need it. Thanks for all your help, great community!!
RDragon1
RDragon1
I think we need more clues besides "the animations are not working out correctly".
charpi
charpi
haha, that would be hard besides saying that everything could go wrong did go wrong...but i'll try my best to describe...

firstly, just by doing keyframed animations the program works, meaning that the model is at the correct positions at keyframe 1, 31, 61, 91 etc etc, without it being animated.

I understand that animations between keyframes would require the use of interpolation. Since I'm using skeletal animation and directX matrices, I doubt it is possible to directly interpolate matrices.

Thus, I wrote/lifted some functions which allows me to convert the matrices to quaternions with a direction vector, interpolate quaternions, and convert them back into matrices. I have individually tested each of the functions with quite a number of values and they all seem to work out fine. (I tested them against online calculators).

Maybe if I describe how my code goes it might me a better clue, first off, I have these few variables

keyframeArray -an array consisting of arrays which contains one keyframe value, one animation transform matrix and the corresponding bone name that it is transforming.

EG.
{//start of keyframeArray{//start of first array1, //keyframe 1001, // bone name is 0011,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1 // the animation matrix for that bone for at keyframe}{//start of second array1, //keyframe 1001, // bone name is 0021,1.234,0,0,0,1,0,-0.44543,0,0,1,0,-0.1223,0,0,1 // the animation matrix for that bone for at keyframe}...{//start of last array151, //keyframe 151001, // bone name is 0011,0,0,0,0,1,0,0,0,0,1,2.154,0,0,0,1 // the animation matrix for that bone for at keyframe}}


localBoneTransformMatrix - an array which contains matrices of bones found in FrameTransformMatrix (in a directX file)
localBoneTransformName - an array which contains bone name which corresponds to the index to localBoneTransformMatrix (mostly for comparison purposes)

so...heres my algo/description of how the code works

FOR every entry in keyframeArrayGET the keyframe valueCOMPARE currentKeyframe with the keyframe valueIF currentframe IS A keyframe{GET bone name from keyframeArrayGET animation matrix from keyframeArrayusing COMPARISONS with bone name from keyframeArray and bone name from localBoneTransformNameREPLACE the matrix at the index of the bone name with the animation matrix//since they are all local matrices...USE parentMatrix = parentMatrix X childMatrix // to find the world transform matrixskin model, apply transform matrix to vectors etc etc etc}ELSE // if currentframe is NOT a keyframeFIND previousKeyframe and nextKeyframeFOR every boneGET the transformation matrix of previousKeyframe and nextKeyframeconvert both matrices to two quaternions and a axis vector //since they are of the same bone, the axis of rotation should remain the same right?interpolate them to get one resultant quaternionconvert the quaternion and the axis vector back to one matrixUSE parentMatrix = parentMatrix X childMatrix // to find the world transform matrixskin model, apply transform matrix to vectors etc etc etc}


yep, thats about it, if you guys need more information just specify, I'm terribly grateful for all the help I've gotten from this community. And since this is my last hurdle to clear before I can start (simple) game making, i'm naturally DESPERATE to learn how to do animations as fast as possible.

Once again, thanks alot for your help =)

staticVoid2
staticVoid2
Quote:


I doubt it is possible to directly interpolate matrices



yep, you can, it looks ok aswell and means you don't have to use quaternions, just interpolate all 16 values of the matrix directly. but you don't need to do this.

I think you will need to be a bit more specific as to whats actually going wrong with your code, the solution you provided looks ok.

So, is the mesh in the correct position at frames in-between keyframes?
RDragon1
RDragon1
Can you show us screenshots / video of the problem, or better describe what looks wrong?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.