Sign in to follow this  
DXnut

Creating DirectX Animations - SOLVED

Recommended Posts

I have gotten to the point where I have created an animation set in my code and can animate myself using a CSliderCtl. When I try to convert it all over to DirectX and run the animation set, things get really wacky. All of the bones end up at the origin, taking the vertices they influence along with them. My animated cylinder ends up looking like it got into a major traffic accident. So, when I do the animations I create the SRT keys based on the concept that these will be added to the TransformationMatrix in each bone's D3DXFRAME. So, to animate it, I will interpolate the current SRT values and then do this: TransformationMatrix *= SRT_Matrix; It seems though that DirectX is doing it differently, and thus my question here. In looking at the Tiny_4anim.x file, it looks as if the SRT keys for each bone determine what the TransformationMatrix will be set to. It looks like they do it as: TransformationMatrix = SRT_Matrix; So they keys themselves actually have the translation component that moves the bone from the origin (it gets put there by the OffsetMatrix in the ID3DXSkinInfo interface) back out into its current animated position. Is this correct, or am I seeing things here? This just doesn't jive with what I have been reading about doing animations. I have Advanced Animation With DirectX, by Jim Adams, that only covers how to load animations from an XFile, not create them, and another book that covers it from a non DX viewpoint. Should I create a keyframe, for each bone that is to be animated, at time 0 with the decomposition of its TransformationMatrix and then base the subsequest changes on the SRT values on it? I just want to be sure before I make all those changes. Thanks. [Edited by - DXnut on May 4, 2006 5:56:02 PM]

Share this post


Link to post
Share on other sites
Well, I tried it, but no go. Now the cylinder disappears completely when I try to animate it with DirectX. I am not creating all three SRT keys for each frame though. Does anyone understand how you must register the keys with an animation set?

Share this post


Link to post
Share on other sites
I finally got it to work. It disappeared because of a bug where I copied the translate keys over the scale ones (DOH!).

I found that each keyframe can have S, R, and/or T keys, but it must have at least one of each at time 0 to set the initial pose of each bone. So, even if you don't plan to create animations where the translation changes, you must register a translation key at time 0 that puts the bone in its model space position. After that you can create keys at specific times that just have rotations, scale changes, and/or translation changes. This is unlike the Tiny_4anim.x file where they created the same number of S, R, and T keys at each time frame for each bone that is to be animated in that animation set. So the DX animation knows how to interpolate the S, R, and T values independently of each other before setting the TransformationMatrix for that bone at that time.

To create the keys for time 0 I decomposed the matrix that determines where the bone is in its model space and registered the S, R, and T values from it.

So, when you call the ID3DXAnimationController::AdvanceTime function it will set each D3DXFRAME's TransformationMatrix from the interpolated S * R * T values. Thus the keys have to include all of the info needed to place the bone in its position at that time.

For a looping animation you want the final keyframe to put it back into its starting position or it just goes back into that position from where ever you left it when it starts at time 0 again, and does not look smooth.

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