Skip to content

Commit

Permalink
Merge pull request Circular-Studios#193 from Circular-Studios/feature…
Browse files Browse the repository at this point in the history
…/AnimationSystem

Feature: Animation System
  • Loading branch information
ColdenCullen committed May 16, 2014
2 parents e9e4e3a + 31c24b5 commit ba2b93c
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions source/components/animation.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ private:
/// If the gameobject should be animating
bool _animating;

/// Animation to return to if _animateOnce is true
int _returnAnimation;
/// If the animation is animating once, then returning to _returnAnimation
bool _animateOnce;

public:
/// Bone transforms for the current pose (Passed to the shader)
mixin( Property!_currBoneTransforms );

/**
* Create animation object based on asset animation
*/
Expand All @@ -37,10 +46,6 @@ private:
_animating = true;
}

public:
/// Bone transforms for the current pose (Passed to the shader)
mixin( Property!_currBoneTransforms );

/**
* Updates the animation, updating time and getting a pose based on time
*/
Expand All @@ -51,9 +56,15 @@ public:
// Update currentanimtime based on deltatime and animations fps
_currentAnimTime += Time.deltaTime * 24.0f;

if( _currentAnimTime >= 95.0f )
if( _currentAnimTime >= _animationData.animationSet[ _currentAnim ].duration * 24 - 1 )
{
_currentAnimTime = 0.0f;

if( _animateOnce )
{
_animateOnce = false;
_currentAnim = _returnAnimation;
}
}
}

Expand Down Expand Up @@ -84,8 +95,8 @@ public:
_currentAnimTime = 0.0f;
}
/**
* Switches the current animation
*/
* Switches the current animation
*/
void changeAnimation( int animNumber, int startAnimTime )
{
if( animNumber < _animationData.animationSet.length )
Expand All @@ -96,6 +107,21 @@ public:
else
logWarning( "Could not change to new animation, the animation did not exist." );
}
/**
* Runs an animation once, then returns
*/
void runAnimationOnce( int animNumber, int returnAnimNumber )
{
if( animNumber < _animationData.animationSet.length )
{
_animateOnce = true;
_currentAnim = animNumber;
_returnAnimation = returnAnimNumber;
_currentAnimTime = 0;
}
else
logWarning( "Could not change to new animation, the animation did not exist." );
}

/**
* Shutdown the gameobjects animation data
Expand Down

0 comments on commit ba2b93c

Please sign in to comment.