GlsAnimation Library  1.0.5
Provides classes and functions to support animating GL Studio objects programmatically or with script files
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
disti::GlsAnimationJuggler Class Reference

A class used to schedule and manage multiple animations. More...

#include <gls_animation_juggler.h>

Public Types

enum  LoopBehavior { PLAY_ONCE, LOOP, PING_PONG }
 Specifies looping behaviors for animations. More...
 
typedef stdortr1::shared_ptr< GlsAnimationJugglerPtr
 Alias for easier reading.
 
typedef GlsKeyframeCurveBase::Key Key
 Alias for easier reading.
 
typedef Detail::ID ID
 Animation ID used to cancel animations.
 

Public Member Functions

 GlsAnimationJuggler (Key currentTime=0)
 
 ~GlsAnimationJuggler ()
 Destructor.
 
template<class Animation >
ID Schedule (Animation animation, DisplayFrame *displayFrame=0, LoopBehavior loop=PLAY_ONCE, double playbackSpeed=1, Key delayKey=0, Key startKey=Detail::g_nan, Key endKey=Detail::g_nan)
 
template<class Animation , class Observer >
ID Schedule (Animation animation, Observer observer, DisplayFrame *displayFrame=0, LoopBehavior loop=PLAY_ONCE, double playbackSpeed=1, Key delayKey=0, Key startKey=Detail::g_nan, Key endKey=Detail::g_nan, typename Detail::enable_if< !Detail::is_convertible< Observer, DisplayFrame * >::value >::type *=0)
 
void Advance (Key dt)
 
void SetKey (Key key)
 
void Cancel (ID id)
 
void CancelAllAnimations ()
 Cancels all scheduled animations. No animation complete notifications are sent.
 
Key GetKey (ID id) const
 

Static Public Member Functions

static ID GetInvalidID ()
 Gets the sentinel value for when scheduling fails.
 

Detailed Description

A class used to schedule and manage multiple animations.

Member Enumeration Documentation

Specifies looping behaviors for animations.

Enumerator
PLAY_ONCE 

Plays the animation from its starting value to its ending value, and then removes the animation.

LOOP 

Plays the animation from its starting value to its ending value, and then wraps around to the starting value and repeats the cycle forever.

PING_PONG 

Plays the animation from its starting value to its ending value, and then from its ending value to its starting value, and repeats the cycle forever.

Constructor & Destructor Documentation

disti::GlsAnimationJuggler::GlsAnimationJuggler ( Key  currentTime = 0)

Constructor

Parameters
currentTimeThe key (usually calculation time) when the juggler is created.

Member Function Documentation

void disti::GlsAnimationJuggler::Advance ( Key  dt)

Triggers the juggler to advance each animations by dt * animationData.playbackSpeed seconds. This should be called from the application's Calculate() function.

Parameters
dtThe delta to advance from the last key set.
Note
Any OnCompleteCallbacks associated with completed animations are called during this function call.
void disti::GlsAnimationJuggler::Cancel ( ID  id)

Cancels the corresponding animation. No animation complete notifications are sent.

Parameters
idThe animation ID to cancel. If it is not found, this call has no effect.
GlsAnimationJuggler::Key disti::GlsAnimationJuggler::GetKey ( ID  id) const

Gets the current key (relative to the start of the animation) for specified animation.

Parameters
idThe animation ID whose key will be fetched.
template<class Animation >
ID disti::GlsAnimationJuggler::Schedule ( Animation  animation,
DisplayFrame *  displayFrame = 0,
LoopBehavior  loop = PLAY_ONCE,
double  playbackSpeed = 1,
Key  delayKey = 0,
Key  startKey = Detail::g_nan,
Key  endKey = Detail::g_nan 
)
inline

Schedule a new animation.

Parameters
animationThe animation object, which must be convertible to GlsAnimation::Ptr. The juggler takes ownership of the animation (shared ownership if it is itself a shared_ptr).
displayFrameThe displayFrame that contains the GL Studio objects to operate on. The juggler sets this as the display frame for the given animation. If null, the animation must have a display frame already set.
loopThe loop behavior for this animation.
playbackSpeedThe speed multiplier for this animation applied when Advance() or SetKey() is called. Can be negative.
delayKeyDelay the start of this animation by this many key values.
startKeyThe key value to use as the start of this animation (endKey can be smaller than startKey)
endKeyThe key value to end up at at the end of this animation (endKey can be smaller than startKey)
Returns
The id of the animation, for use in canceling. If equal to GetInvalidID(), then the scheduling operation failed and nothing was scheduled.
Precondition
animation != 0 && (displayFrame != 0 || animation->IsReadyToAnimate())
template<class Animation , class Observer >
ID disti::GlsAnimationJuggler::Schedule ( Animation  animation,
Observer  observer,
DisplayFrame *  displayFrame = 0,
LoopBehavior  loop = PLAY_ONCE,
double  playbackSpeed = 1,
Key  delayKey = 0,
Key  startKey = Detail::g_nan,
Key  endKey = Detail::g_nan,
typename Detail::enable_if< !Detail::is_convertible< Observer, DisplayFrame * >::value >::type *  = 0 
)
inline

Schedule a new animation with an animation observer.

Parameters
animationThe animation object, which must be convertible to GlsAnimation::Ptr. The juggler takes ownership of the animation (shared ownership if it is itself a shared_ptr).
observerAn observer class that receives a callback when the animation starts, updates, or completes. Must be convertible to GlsAnimationObserverBase::Ptr and not convertible to a DisplayFrame*. The juggler takes ownership of this object (shared ownership if it is itself a shared_ptr). See CreateOnCompletedCallback(), GlsAnimationObserver, etc. for more on creating callbacks. (Note: Cancelling an animation does not trigger a callback.).
displayFrameThe display frame that contains the GL Studio objects to operate on, usually the pointer to an application or component. The juggler sets this as the display frame for the given animation. If null, the animation must have a display frame already set.
loopThe loop behavior for this animation.
playbackSpeedThe speed multiplier for this animation applied when Advance() or SetKey() is called.
delayKeyDelay the start of this animation by this many key values.
startKeyThe key value to use as the start of this animation (endKey can be smaller than startKey)
endKeyThe key value to end up at at the end of this animation (endKey can be smaller than startKey)
Returns
The id of the animation, for use in canceling. If equal to GetInvalidID(), then the scheduling operation failed and nothing was scheduled.
Precondition
animation != 0 && (displayFrame != 0 || animation->IsReadyToAnimate())
void disti::GlsAnimationJuggler::SetKey ( Key  key)

Triggers the juggler to advance all animations by (key-lastKey) * GetPlaybackSpeed() seconds. This should be called from the application's Calculate() function.

Parameters
keyThe absolute key value to be applied, accounting for animation's starting key.
Note
Any OnCompleteCallbacks associated with completed animations are called during this function call.

The documentation for this class was generated from the following files: