Jump to content
  • Advertisement
Sign in to follow this  
anders211

time units in ID3DXAnimationSet/Controller

This topic is 2114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,
As everybody knows there is a big mess with time units in all of ID3DXAnimation methods. At least I lost, that I cannot for example calculate how to get to know how many ms is till AnimationSet loop end and start from the beginning. So could You help me fill up the below. This is some kind of summary of time units.

Summary of time units in DirectX:
1.) .X file

AnimationKey {
4;
92;
0;16;0.999995,-0.000000, ...
160;16; ...
320;16; ...
480;16; ..
640;16; ...
...
1200 (all animation key frame ticks)
}
I suppose this what is bold is called in english "animation key frame ticks". When I began to learn I thought that those are [ms]:), but now I now that those aren't [ms].


2.)
ID3DXAnimationController - methods KeyTrackEnable/Speed/etc. take times in [s] unit
ID3DXAnimationController - method AdvanceTime take also time in [s] unit
ID3DXAnimationController - ID3DXTRACK_DESC { float Speed, ..} what is the time unit of Speed variable?
ID3DXAnimationController - KeyTrackPosition - probably also time in [s]



3.)
ID3DXAnimationSet GetSourceTicksPerSecond() - returns the number of animation key frame ticks per second, in most cases the value is equal to 480. (in one book I read that it tells how many times the interpolation is done per second, in other words tell how many AdvanceTime() is invoked per second, but I am not sure if it is true because when I increase time in AdvanceTime() method the animationSet is executed much faster, so this was boolshit in the book I suppose)

ID3DXAnimationSet - GetPeriod() returns the number which is equal to "all animation key frame ticks" / GetSourceTicksPerSecond(), so in other words it tells how many seconds the AnimationSet loop lasts.
ID3DXAnimationSet - double GetPeriodicPosition(double position) - I completely don't understand from the documentation what is the argument and return value

As far as my problem is concerned how to get to know how much ms is till animationSet will reach the end of loop?

LPD3DXANIMATIONSET set;
mAnimCtrl->GetAnimationSet(mCurrentAnimationSet, &set); //in my case this returns to me the same as mAnimCtrl->GetTrackAnimationSet)(mCurrentTrack, &set);
float lastTime = static_cast<float>(set->GetPeriod() - ?????? )


Thanks in advance for help

Share this post


Link to post
Share on other sites
Advertisement
GetPeriodicPosition takes a float Position as a parameter and if the playback mode is D3DXPLAY_ONCE then the return value is pretty much the same as the input parameter (in general the returned position is the input position clamped inside the loop length of the animation).

[source]
if (D3DXPLAY_LOOP == m_Playback)
{
Position = fmod(Position, m_dLoopLength);
if (Position < 0.0)
{
Position += m_dLoopLength;
}
}
else if (D3DXPLAY_ONCE == m_Playback)
{
Position =
max( 0.0, min(Position, m_dLoopLength) );
}
else if (D3DXPLAY_PINGPONG == m_Playback)
{
Position = fmod(Position,
2.0 * m_dLoopLength);
if (Position < 0.0)
{
Position += 2.0 * m_dLoopLength;
}
}
[/source]

Animations have reached end when current animation controller time equal or greater than startTime + set->GetPeriod() and playback is D3DXPLAY_ONCE.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!