Jump to content
  • Advertisement
Sign in to follow this  
Funkiemonkey

Problems with .x animations and timer bars

This topic is 4337 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

Heya Heres a challenge for all you Direct X ledgends! I've implemented a few .x animation classes using the approach found on toymaker.info (http://www.toymaker.info/Games/html/load_x_hierarchy.html) which involves the use of D3DXLoadMeshHierarchyFromX(). This works fine and the animation runs. I can also speed up and slow down the animation by calling AdvanceTime() which takes a float containing the elapsed time. The problem I have is that I cannot find a way of implementing a timer bar to keep track of how far through the animation is (rather like media players do). Originally I assumed the animation would played by rendering each frame (as in 3ds max frame) sequentially which would meant I knew how many frames (3ds max frames) was in the animation and consequently I could set the timer bar maximum and minimum. However, it seems that what the animation controler in direct x renders by using linear interpolation inbetween frames which means it renders the frames created in 3ds max no longer exist. The question is, how can I tell how long the animation is (frames, elapsed time duration or otherwise)? I've looked through the animation controler functions for something like GetDurationOfAnimation() but all I could find was functions relating to animation sets and track placement. I've probably not explained this very well, but any help would be appreciated! :) Thanks in advanced Andy

Share this post


Link to post
Share on other sites
Advertisement
Wow, what bad english, maybe I should proof read next time! :)

When I wrote

"which means it renders the frames created in 3ds max no longer exist"

I actually meant

"which means the frames created in 3ds max no longer exist"

Share this post


Link to post
Share on other sites
Is this what you're looking for?


ID3DXCompressedAnimationSet::GetSourceTicksPerSecond
Gets the number of animation key frame ticks that occur per second.

DOUBLE GetSourceTicksPerSecond();
Parameters
None.

Return Values
Number of animation key frame ticks that occur per second.

Requirements
Header: Declared in D3dx9anim.h.

Get time from keys, not sure if there's another way:
ID3DXKeyframedAnimationSet::GetScaleKeys
ID3DXKeyframedAnimationSet::GetRotationKeys
ID3DXKeyframedAnimationSet::GetTranslationKeys


So, let's say you have TICKS/SEC. Convert this into FRAMES/SEC or fps.
And to get the total length of animation, multiply the total time of animation by fps:
(total_time in SEC) * (FRAMES/SEC) = TOTAL_FRAMES

Basic math, the SECs cancel out, leaving you with frames.

[Edited by - JakeM on January 30, 2007 3:12:52 PM]

Share this post


Link to post
Share on other sites
Yeah, that might work, thanks.

I've also found ID3DXKeyframedAnimationSet::GetPeriod()

From MSDN:

-----

Syntax

DOUBLE GetPeriod(VOID);
Return Value

Period of the animation set.

Remarks

The period is the range of time that the animation key frames are valid. For looping animations, this is the period of the loop. The time units that the key frames are specified in (for example, seconds) is determined by the application.

-----

I guess this would tell me the duration of the animation? Guess I'll just have to have a play around in me program.

Andy

Share this post


Link to post
Share on other sites
Yeah, GetPeriod() returns the duration of the animation which is what I needed :) Only one problem now tho: I can advance time and play the animation fowards using AdvanceTime() but how would you go about playing the animation backwards, effectively rewinding it?

I tried supplying a negitive value to AdvanceTime() but it doesn't work and the documentation says it doesn't allow it!

Its just one problem after another! :D lol

Thanks again in advance!

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.

GameDev.net 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!