Advertisement Jump to content
Sign in to follow this  

Frame Position

This topic is 4376 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 guys, my X files animation consists of 30 frames ( from 3D Max ) , programatically is it possible to know how many frames i have in an x file and what is the frame number that the animation is currenty playing ? [Edited by - jad_salloum on January 29, 2007 12:59:09 PM]

Share this post

Link to post
Share on other sites
Hey - this is what I came up with. I assume you mean that you want to know which two keys DX is currently interpolating between.

You can get how many keys an animation has by doing something like:

ID3DXAnimationSet* set;
ID3DXKeyframedAnimationSet* keyset;

controller->GetAnimationSet(0, &set);
set->QueryInterface(IID_ID3DXKeyframedAnimationSet, (void**)&keyset);
UINT numKeys = keyset->GetNumRotationKeys(0);

DOUBLE ticks = keyset->GetSourceTicksPerSecond();

keyset->GetRotationKeys(0, quats);


This assumes you have one animation set with one animation, and the same number of rotation keys as position/scale keys etc. I get the number of keys, the ticks/second and the keys themselves. The keys have a Time value that is the tick the key is set on.

While animating, you can get the current position in seconds and convert it to ticks. Then look in the array of keys to see which two keys you are between.

ID3DXAnimationSet* set;
DOUDLE curTick = set->GetPeriodicPosition(d.Position) * ticks;
// look up keys with curTick

Note this code is quick and dirty. Hope that helps at all.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!