• Create Account

## time units in ID3DXAnimationSet/Controller

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1anders211  Members

Posted 28 September 2012 - 03:47 PM

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() - ?????? )

### #2Steve_Segreto  Members

Posted 02 October 2012 - 03:30 PM

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).


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;

}

}



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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.