Represents an instance of an animation timeline.

Namespace: DigitalRune.Animation
Assembly: DigitalRune.Animation (in DigitalRune.Animation.dll) Version: 1.1.0.0 (1.1.0.9503)

Syntax

C#
public class AnimationInstance : IAnimatableObject, 
	INamedObject, IRecyclable
Visual Basic
Public Class AnimationInstance _
	Implements IAnimatableObject, INamedObject, IRecyclable
Visual C++
public ref class AnimationInstance : IAnimatableObject, 
	INamedObject, IRecyclable

Remarks

Animation instances are used to play back animations. They maintain the runtime-state of an animation.

Animation instances are automatically created and managed by the animation system when a new animation is started using one of the StartAnimation-methods or when an animation controller is created using one of the CreateController-methods (see IAnimationService).

Animation Value: An animation usually produces a value as the output. The base class AnimationInstance manages the timeline of the animation. The derived class AnimationInstance<(Of <(<'T>)>)> manages the animation value. The animation system automatically applies the output values to the properties that are being animated (see IAnimatableProperty<(Of <(<'T>)>)>).

Animation State and Timing: The property State returns the current state of the animation. The animation can be Delayed, Playing, Filling or Stopped. But the state does not indicate whether the animation timing is active. The property IsPaused indicates whether the animation timing is active or paused.

Active animations are managed by the AnimationManager. The animation system automatically advances and updates the animations.

The current state of an animation is computed once per frame (in Update(TimeSpan)) and cached until the next frame. The animation instance does not monitor the animation for changes. I.e. when the animation is modified the animation instance needs to be notified by calling Invalidate()()()(). Otherwise, it can return an invalid state in the current frame. For example, an animation instance plays a certain TimelineClip. During playback the user changes the Delay of the animation. Now, when the user reads State in the same frame the instance might return the wrong value. The user needs to call Invalidate()()()() to get the correct, up-to-date value. (It is not necessary to call Invalidate()()()() if the animations are updated using Update(TimeSpan). Update(TimeSpan) automatically computes the new values.)

Animation Tree: Animation instances can have children. For example, when a TimelineGroup is started it creates a root instance that has several children - one animation instance per animation in the timeline group. A timeline group might contain other timeline groups. The animation instances are organized in a tree structure.

Only the root instance of a tree can be controlled interactively (using an AnimationController).

Speed Ratio: The playback speed of the animation tree can be controlled by changing the property Speed. The speed ratio defines the rate at which time progresses. The default value is 1. A value of, for example, 2 means that the animation runs twice as fast. A value of 0.5 causes the animation to run in slow-motion at half speed.

Note that the only the speed ratio of the root instance in the animation tree can be controlled. (Changing the speed ratio of other nodes in the animation tree has no effect.)

Animation Weights: Each animation instance has a weight (see Weight) that defines the intensity of the animation. It is a factor that is applied to the animation output. The animation weight is in particular relevant when multiple animations should be combined. Each animation combines its output with the output of the previous stage in the animation composition chain. (If the animation is the first animation of a composition chain it combines its value with the base value of the property that is being animated.)

The default value is 1, which means that 100% of the animation is returned overriding any previous stage in an animation composition chain. A value of of 0.75 means that result is weighted combination of the previous stage (25%) and the output of the current animation (75%). A value of 0 basically disables the output of the current stage.

Changing the animation weight of an instance affects the entire subtree: The current animation instance and all children. The effective animation weight is the product of all weights from the root instance to the current animation instance.

Secondary Animations: An animation instance itself is an IAnimatableObject, which means that it has properties which can be animated. The properties that can be animated are Speed and Weight. Secondary animation can be used, for example, to fade-in an animation by letting the animation weight go from 0 to 1 over time.

Inheritance Hierarchy

System..::..Object
  DigitalRune.Animation..::..AnimationInstance
    DigitalRune.Animation..::..AnimationInstance<(Of <(<'T>)>)>

See Also