Class GorgonAnimationController<T>
Base class for applying animations to an object.
Inheritance
Inherited Members
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 SourceCurrentAnimation
Property to return the currently playing animation.
Declaration
public IGorgonAnimation CurrentAnimation { get; }
Property Value
Type | Description |
---|---|
IGorgonAnimation |
See Also
| Edit this page View SourceRegisteredTracks
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
| Edit this page View SourceState
Property to return the current state of the animation on the controller.
Declaration
public AnimationState State { get; }
Property Value
Type | Description |
---|---|
AnimationState |
See Also
| Edit this page View SourceTime
Property to set or return the current time index.
Declaration
public float Time { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
Methods
| Edit this page View SourceOnColorUpdate(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
| Edit this page View SourceOnQuaternionValueUpdate(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
| Edit this page View SourceOnRectangleUpdate(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
| Edit this page View SourceOnSingleValueUpdate(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
| Edit this page View SourceOnTexture2DUpdate(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
| Edit this page View SourceOnVector2ValueUpdate(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
| Edit this page View SourceOnVector3ValueUpdate(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
| Edit this page View SourceOnVector4ValueUpdate(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
| Edit this page View SourcePause()
Function to pause the currently executing animation.
Declaration
public void Pause()
See Also
| Edit this page View SourcePlay(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 |
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
| Edit this page View SourceRefresh()
Function to refresh the state of the object that is being animated with the current Time.
Declaration
public void Refresh()
See Also
| Edit this page View SourceRegisterTrack(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 |
NotSupportedException | Thrown when the |
See Also
| Edit this page View SourceReset()
Function to reset the currently playing animation back to the start of the animation.
Declaration
public void Reset()
See Also
| Edit this page View SourceResume()
Function to resume a paused animation.
Declaration
public void Resume()
See Also
| Edit this page View SourceStop()
Function to stop the currently playing animation.
Declaration
public void Stop()
See Also
| Edit this page View SourceUpdate(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.