Skip to main content
gamedev.net
🔒 Locked

Frame Position

Started by jad_salloum 1 reply 1.3k views
Original Post
jad_salloum
jad_salloum
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]
madox
madox
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.