# Synchronizing Animation Speed

This topic is 4860 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 match the frame rate that 3D Studio Max is showing to the frame rate DirectX is playing animation. Our human animation is playing much faster than what we see in Max. Unfortunately, AnimationSets are one of the least documented objects in DirectX 9. After some debugging and number crunching, I have come to the conclusion that we aren't seeing consistant results across different .x objects. First, the time codes in the .X File's AnimationKey do not correspond to the time codes used in Max. For our Animation 1 example, there are two key frames at 0 and at 120. These correlate to Max frames 0 and 60. The next key frame is 2640, that correlates to Max frame 215. While the first time code can be interpolated as 2:1, the next time code is actually 44:1. The last frame is 28.8:1. The animation plays correctly, so I suppose frames do not correlate to these key frame positions that I'll refer to as Units. Next, DirectX plays this animation using seconds. When debugging, I watch a variable called AnimationSet.Period that reports the period of the entire Animation. I assume that since the advance animation method takes seconds, this is reporting seconds. Where this number comes from is not documented. There does not seem to be a way to modify it in any way. We're using PolyTrans to save .X files from Max, so if you know any tunable parameters in that can help us get to a What-You-See-Is-What-You-Get animation speed, I would appreciate it. The following is some math that I put together to get the actual frames per second that these animations are playing in DirectX.

Animation 1 : Vehicle motion
*************************************

Max Settings:
30 Fps
# Frames: 250

DirectX Debug:
AnimationSet.Period: 7.5 (undocumented value, assuming seconds)

7200 Units    1 period      250 frames
---------- x ----------- x ------------  = 33.33333 Frames per second
1 period     7.5 seconds   7200 Units

AnimationKey {
0;  // Rotation
11;
0;4;0.500000,-0.500000,0.500000,-0.500000;;
120;4;0.473529,-0.525138,0.525139,-0.473529;;
2640;4;-0.242811,-0.664111,0.664111,0.242811;;
3360;4;-0.433716,-0.558472,0.558472,0.433716;;
3720;4;-0.514684,-0.484872,0.484872,0.514684;;
6240;4;-0.669249,0.228266,-0.228266,0.669249;;
6720;4;-0.608217,0.360655,-0.360655,0.608217;;
6840;4;-0.588793,0.391564,-0.391564,0.588794;;
6960;4;-0.567800,0.421429,-0.421429,0.567800;;
7080;4;-0.545294,0.450172,-0.450172,0.545294;;
7200;4;-0.521334,0.477714,-0.477714,0.521334;;
}

Animation 2 : Human animation
*************************************

Max Settings:
30 Fps
# Frames: 24

DirectX Debug:
AnimationSet.Period: .6 (assuming seconds)

2880 Units    1 period      24 frames
---------- x ----------- x ------------  = 40.0000 Frames per second
1 period     .6 seconds     2880 Units

AnimationKey {
0;  // Rotation
2;
0;4;-0.984808,0.000000,0.173648,0.000000;;
2880;4;-0.984808,0.000000,0.173648,0.000000;;
}



ping

##### Share on other sites
What exactly is the question? I'm not sure I see how you are correlating frame rate in DirectX to frame rate in Max. Knowing the frame rate of the character in DirectX won't help you, because it's not based on purely rendering that character...it's based on everything that is to be rendered (unless you are only going to be rendering that character and nothing else). Also, if an animation runs for 5 seconds in Max, it will run for 5 seconds in DirectX. It may have 120 frames between those 5 seconds in Max and only 16 frames in DirectX if you're having a severe slow down, but it will still get to the end of the animation. Sorry if I'm misunderstanding.

##### Share on other sites
What I am actually experiencing is an animation played from DX is faster than the one that is in Max. I can play the animation in Max side by side with the DirectX Viewer in order to see this.

My calculation translates the actual DX keyed animation into what Max's FPS would have to be set at in order to experience the same playback speed.

Has anyone else tried to measure actual animation timing using the XFile playback?

I guess I could sum up my diatribe with 3 questions:

First, in an .X file's AnimationKey, what units
do the Timed Float values have? Milliseconds? Psuedo Seconds?

can call ID3DXAnimationSet::GetPeriod()­. How is this value set? The
docs tell me it is "determined by the application". However, I don't
really see how I can manipulate this.

Third, how does the TimedFloat key relate to the Period?

Thanks!

##### Share on other sites
The best way would be to probably limit the render calls you do to the rendering of the specific animation/mesh. Limit the framerate which should be quite easy to do. Just keep track of the amount of frames per second and then when it hits that amount of frames per second you reset that variable, render and then start from the beginning. I think that max/maya renders animations at 30fps.

I stand corrected on this.

##### Share on other sites
Update:

It turns out that PolyTrans is resampling the key frames. What I thought were supposed to be 2 keys of many are now multiplied. Not only that, the conversion turns out to be 120 FloatKeys per frame of animation at 30 fps. This means that a max value of 7200 FloatKey is 60 frames of animation.

It looks like PolyTrans is doing the correct thing from Max's side. However, DirectX is still calculating the Period differently.

A look at the MeshViewer's docs at DX Help Url: "mk:@MSITStore:C:\Program%20Files\Microsoft%20DirectX%209.0%20SDK%20(June%202005)\Documentation\DirectX9\directx9_c.chm::/directx/directxsdk/tools/content/meshviewer.htm" shows that the viewer is playing back at 4800 FloatKeys per second [for 30 frames per second]. "Interpret the time value in the animation from a .x file as 4800 units per second."

So my answer is if I cannot tune the parameter to be 3600 FloatKeys per second, I must divide my time delta by 1 1/3.

[Edited by - mbelew on July 26, 2005 12:12:19 PM]

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633312
• Total Posts
3011310
• ### Who's Online (See full list)

There are no registered users currently online

×