Jump to content
  • Advertisement
Sign in to follow this  
jad_salloum

Frame Position

This topic is 4133 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
Advertisement
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);
set->Release();
UINT numKeys = keyset->GetNumRotationKeys(0);

DOUBLE ticks = keyset->GetSourceTicksPerSecond();

D3DXKEY_QUATERNION* quats = (D3DXKEY_QUATERNION*)malloc(sizeof(D3DXKEY_QUATERNION) * numKeys);
keyset->GetRotationKeys(0, quats);

keyset->Release();


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.


D3DXTRACK_DESC d;
ID3DXAnimationSet* set;
controller->GetAnimationSet(0,&set);
controller->GetTrackDesc(0,&d);
DOUDLE curTick = set->GetPeriodicPosition(d.Position) * ticks;
// look up keys with curTick
set->Release();


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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!