Click or drag to resize
DigitalRuneIAnimationValueTraitsT Interface
Describes the properties of an animation value and defines operations that can be applied to animation values.

Namespace: DigitalRune.Animation.Traits
Assembly: DigitalRune.Animation (in DigitalRune.Animation.dll) Version: 1.4.0.0 (1.4.1.14427)
Syntax
public interface IAnimationValueTraits<T>

Type Parameters

T
The type of the animation value.

The IAnimationValueTraitsT type exposes the following members.

Methods
  NameDescription
Public methodAdd
Adds the given animation values.
Public methodBeginBlend
Begins the interpolation of n animation values.
Public methodBlendNext
Blends the given animation value to the current value.
Public methodCopy
Copies the specified animation value.
Public methodCreate
Creates an animation value. (If the animation value is a heap object, then method reuses any previously recycled instance or allocates a new instance if necessary.)
Public methodEndBlend
Finalizes the interpolation of n animation values.
Public methodInterpolate
Performs a linear interpolation between two animation values.
Public methodInvert
Gets the inverse of an animation value.
Public methodMultiply
Multiplies an animation value by a given factor.
Public methodRecycle
Recycles an animation value.
Public methodReset
Public methodSet
Public methodSetIdentity
Gets the identity.
Top
Remarks

The IAnimationValueTraitsT describe the operations that can be performed on a certain type of animation value. This abstraction is necessary in order to treat different types of animations with the same code.

The interface IAnimationValueTraitsT and its implementing classes are used only internally in DigitalRune Animation. It is safe to ignore these types. (The following information is only relevant for users who plan to implement new types of animation values and want to reuse the existing animation classes.)

Reference Types vs. Value Types: Animation values can be reference types as well as value types, which makes the task a little complicated. Most method parameters need to be passed by reference to efficiently handle both cases.

Create, Recycle and Copy: The methods Create(T, T) and Recycle(T) can be used to create and recycle animation values. (Create(T, T) returns a previously recycled instance, if any is available. It is recommended to recycle and reuse animation values if they allocate memory on the managed heap.)

Set and Reset: The method Set(T, IAnimatablePropertyT) is called when the animation system sets an animation value to an IAnimatablePropertyT; Reset(IAnimatablePropertyT) is called when all animations are removed from an IAnimatablePropertyT.

The method Copy(T, T) copies that data of one animation value to another.

Add, Identity, Invert and Multiply: In order to handle all types of animation with the same code we need to apply some math: The animation values form an algebraic group. The group has a group operation (see Add(T, T, T)) that represents the application of an animation value to a given value, an identity element (see SetIdentity(T)) and a function that computes the inverse of an animation value (see Invert(T, T)). For efficiency, there is also a function Multiply(T, Int32, T) that computes the repeated application of the same value. For example, if + represents the group operation then Multiply(x,3) = x + x + x.

Group Operation: The group operation depends on the type of animation value. Here are some examples: If the animation value is a real number the group operation is a simple addition. The group operation of a n-dimensional vector is a vector addition. If the animation value is a unit quaternion that represents a rotation, the group operation is a quaternion product (because two quaternions are combined using the quaternion product). Etc.

Note that, in general the group operations are not a commutative, meaning that the order of the operands is important! For example, the quaternion product is not commutative.

Identity Element: Every group has an identity element regarding the group operation. For example, the identity element of a scalar addition is 0. The identity of the vector addition is the zero vector. The identity of the quaternion product is the identity quaternion. Etc.

Inverse: Every value of the group has an inverse. For example, the inverse element of a real number r is -r. The inverse of an n-dimensional vector v is -v. The inverse of a unit quaternion q is q-1. Etc.

Interpolation: Another important part of animation is interpolation ("animation blending"). The interpolation of animation values is in most cases a weighted combination of the animation values. Animation values need to support two types of interpolation:

Optimizations: In order to improve performance - in particular on the Xbox 360 - most parameters are passed by reference. All operation happen in-place, i.e. no new objects are allocated.

See Also