Gorgon
Show / Hide Table of Contents

Class GorgonAnimationController<T>

Base class for applying animations to an object.

Inheritance
object
GorgonAnimationController<T>
GorgonPolySpriteAnimationController
GorgonSpriteAnimationController
GorgonTextSpriteAnimationController
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Gorgon.Animation
Assembly: Gorgon.Animation.dll
Syntax
public abstract class GorgonAnimationController<T> where T : class
Type Parameters
Name Description
T

The type of object that this controller will use. The type passed in must be a reference type (i.e. a class).

Remarks

A controller will update the object properties over a certain time frame (or continuously if looped) using a IGorgonAnimation.

This controller will advance the time for an animation, and coordinate the changes from interpolation (if supported) between IGorgonKeyFrame items on a IGorgonAnimationTrack<T>. The values from the animation will then by applied to the object properties.

Applications can force the playing animation to jump to a specific Time, or increment the time step smoothly using the Update(float?) method. Typically, the Update(float?) method should be called once per frame in the idle loop of the application.

This controller type is an abstract object, so developers must implement their own implementation of a controller to define how to animate their objects. This is typically very straight forward since the controller uses several abstract methods that update the object properties with a value. More often than not, these methods typically contain object.AnimatedProperty = value and nothing else.

The controller uses animation tracks to indicate which property on the object (specified by T) it will update over time. These tracks are determined by a track registry contained within the controller. These tracks are registered via the RegisterTrack(GorgonTrackRegistration) method which should be called in the constructor of the controller when implementing a custom animation controller.

Registered tracks use an object called GorgonTrackRegistration to define metadata for the track such as the type of values stored within a tracks IGorgonKeyFrame items. The metadata also contains a TrackName property which is used for identifying a track when building an animation and determining which property to update on the animated object via the On(Type Name)Update methods.

Applications can query the tracks registered with the controller via the RegisteredTracks property.

important

Please note that this is an abstract class. Applications will provide specific controllers for specific types.

information

Because this is a base class, not all controllers will support all track types, or even components of a track key frame.

Properties

| Edit this page View Source

CurrentAnimation

Property to return the currently playing animation.

Declaration
public IGorgonAnimation CurrentAnimation { get; }
Property Value
Type Description
IGorgonAnimation
See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

RegisteredTracks

Property to return the list of available tracks used by this controller.

Declaration
public IReadOnlyList<GorgonTrackRegistration> RegisteredTracks { get; }
Property Value
Type Description
IReadOnlyList<GorgonTrackRegistration>
See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

State

Property to return the current state of the animation on the controller.

Declaration
public AnimationState State { get; }
Property Value
Type Description
AnimationState
See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

Time

Property to set or return the current time index.

Declaration
public float Time { get; set; }
Property Value
Type Description
float
See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>

Methods

| Edit this page View Source

OnColorUpdate(GorgonTrackRegistration, T, GorgonColor)

Function called when a GorgonColor value needs to be updated on the animated object.

Declaration
protected abstract void OnColorUpdate(GorgonTrackRegistration track, T animObject, GorgonColor value)
Parameters
Type Name Description
GorgonTrackRegistration track

The track currently being processed.

T animObject

The object to update.

GorgonColor value

The value to apply.

See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

OnQuaternionValueUpdate(GorgonTrackRegistration, T, Quaternion)

Function called when a Quaternion value needs to be updated on the animated object.

Declaration
protected abstract void OnQuaternionValueUpdate(GorgonTrackRegistration track, T animObject, Quaternion value)
Parameters
Type Name Description
GorgonTrackRegistration track

The track currently being processed.

T animObject

The object to update.

Quaternion value

The value to apply.

See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

OnRectangleUpdate(GorgonTrackRegistration, T, RectangleF)

Function called when a SharpDX RectangleF value needs to be updated on the animated object.

Declaration
protected abstract void OnRectangleUpdate(GorgonTrackRegistration track, T animObject, RectangleF value)
Parameters
Type Name Description
GorgonTrackRegistration track

The track currently being processed.

T animObject

The object to update.

RectangleF value

The value to apply.

See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

OnSingleValueUpdate(GorgonTrackRegistration, T, float)

Function called when a single floating point value needs to be updated on the animated object.

Declaration
protected abstract void OnSingleValueUpdate(GorgonTrackRegistration track, T animObject, float value)
Parameters
Type Name Description
GorgonTrackRegistration track

The track currently being processed.

T animObject

The object to update.

float value

The value to apply.

See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

OnTexture2DUpdate(GorgonTrackRegistration, T, GorgonTexture2DView, RectangleF, int)

Function called when a texture needs to be updated on the object.

Declaration
protected abstract void OnTexture2DUpdate(GorgonTrackRegistration track, T animObject, GorgonTexture2DView texture, RectangleF textureCoordinates, int textureArrayIndex)
Parameters
Type Name Description
GorgonTrackRegistration track

The track currently being processed.

T animObject

The object to update.

GorgonTexture2DView texture

The texture to switch to.

RectangleF textureCoordinates

The new texture coordinates to apply.

int textureArrayIndex

The texture array index.

See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

OnVector2ValueUpdate(GorgonTrackRegistration, T, Vector2)

Function called when a 2D vector value needs to be updated on the animated object.

Declaration
protected abstract void OnVector2ValueUpdate(GorgonTrackRegistration track, T animObject, Vector2 value)
Parameters
Type Name Description
GorgonTrackRegistration track

The track currently being processed.

T animObject

The object to update.

Vector2 value

The value to apply.

See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

OnVector3ValueUpdate(GorgonTrackRegistration, T, Vector3)

Function called when a 3D vector value needs to be updated on the animated object.

Declaration
protected abstract void OnVector3ValueUpdate(GorgonTrackRegistration track, T animObject, Vector3 value)
Parameters
Type Name Description
GorgonTrackRegistration track

The track currently being processed.

T animObject

The object to update.

Vector3 value

The value to apply.

See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

OnVector4ValueUpdate(GorgonTrackRegistration, T, Vector4)

Function called when a 4D vector value needs to be updated on the animated object.

Declaration
protected abstract void OnVector4ValueUpdate(GorgonTrackRegistration track, T animObject, Vector4 value)
Parameters
Type Name Description
GorgonTrackRegistration track

The track currently being processed.

T animObject

The object to update.

Vector4 value

The value to apply.

See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

Pause()

Function to pause the currently executing animation.

Declaration
public void Pause()
See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

Play(T, IGorgonAnimation)

Function to set an animation playing on an object.

Declaration
public void Play(T animatedObject, IGorgonAnimation animation)
Parameters
Type Name Description
T animatedObject

The object to apply the animation onto.

IGorgonAnimation animation

The IGorgonAnimation to play.

Remarks

Applications should call this method to start an animation for an object. Otherwise, no animation will play when Update(float?) is called.

Exceptions
Type Condition
ArgumentNullException

Thrown when the animation or animatedObject parameters are null.

KeyNotFoundException

Thrown when the animation could not be found in the collection.

NotSupportedException

Thrown if a track in the animation has a mismatch for the SupportedInterpolation in the track registration.

See Also
GorgonTrackRegistration
| Edit this page View Source

Refresh()

Function to refresh the state of the object that is being animated with the current Time.

Declaration
public void Refresh()
See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

RegisterTrack(GorgonTrackRegistration)

Function to register a track with the controller.

Declaration
protected void RegisterTrack(GorgonTrackRegistration registration)
Parameters
Type Name Description
GorgonTrackRegistration registration

The data used to register the track.

Exceptions
Type Condition
ArgumentException

Thrown when the track registration data is already registered.

NotSupportedException

Thrown when the registration KeyType parameter does not have an equivalent supported track key frame data type.

See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

Reset()

Function to reset the currently playing animation back to the start of the animation.

Declaration
public void Reset()
See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

Resume()

Function to resume a paused animation.

Declaration
public void Resume()
See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

Stop()

Function to stop the currently playing animation.

Declaration
public void Stop()
See Also
IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
| Edit this page View Source

Update(float?)

Function to update the currently playing animation time and bound properties.

Declaration
public void Update(float? timingDelta = null)
Parameters
Type Name Description
float? timingDelta

[Optional] The delta time for a frame to be rendered.

Remarks

If the timingDelta is not null, then the value passed will represent the amount of time it takes the GPU to render a frame. This is useful for fixed timestep animations. If it is left as null, then Delta on the GorgonTiming class is used for variable timestep.

Users should call this method once per frame in order to update the current state of the playing (by calling Play(T, IGorgonAnimation) animation. If no animation is playing, then this method will do nothing.

See Also
GorgonTiming

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)

See Also

IGorgonAnimation
GorgonTrackRegistration
IGorgonKeyFrame
IGorgonAnimationTrack<T>
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author