Gorilla.Animation Unit Reference
Overview
The Gorilla.Animation unit provides a comprehensive animation system for Gorilla3D, supporting skeletal/joint animation, vertex (mesh) animation, and property-based keyframe animation. It extends FireMonkey's animation framework with 3D-specific functionality and synchronization mechanisms.
Architecture
The animation system is built on a hierarchical structure:
TGorillaAnimationManager clip registry, playback, crossfade
└─ TGorillaAnimation one clip ("Walk", "c-run.dae")
└─ Skeleton : TSkeletonKeyAnimation clock + tick for all interpolators
└─ Interpolators : TPropertyKeyAnimation (abstract base)
├─ TPoint3DKeyAnimation
├─ TVector3DKeyAnimation
├─ TQuaternion3DKeyAnimation
├─ TTransformationKeyAnimation
└─ TCoordinateKeyAnimation
TGorillaRenderClock (Delphi 13+) drives scene animations from the renderer
TPoint3DAnimation simple start/stop TPoint3D animation
Class inheritance:
TCustomPropertyAnimation (FMX)
├─ TPropertyKeyAnimation
│ ├─ TPoint3DKeyAnimation / TVector3DKeyAnimation / TQuaternion3DKeyAnimation
│ ├─ TTransformationKeyAnimation / TCoordinateKeyAnimation
│ └─ TSkeletonKeyAnimation
└─ TPoint3DAnimation
TFmxObject → TGorillaAnimation
TComponent → TGorillaAnimationManager
Core Classes
TPropertyKeyAnimation
Abstract base class for all keyframe-based animations in Gorilla3D.
Inheritance: TCustomPropertyAnimation → TPropertyKeyAnimation
Platforms: All Gorilla3D supported platforms
Interfaces: IDuplicatable
Public Properties
| Property | Type | Description |
|---|---|---|
| QualifiedName | String | Qualified identifier from definition import. |
| Elements | TReferencedComponentList | Hashmap of linked components. |
| Def | TObject | Linked Gorilla3D definition structure. |
| TransitionTime | Single | Latest computed normalized time (read-only). |
Published Properties
| Property | Type | Default | Description |
|---|---|---|---|
| Keys | TKeys | - | Collection of keyframes. |
| StartFromCurrent | Boolean | False | Start animation from current property value. |
| AnimationType | TAnimationType | In | Easing type: In, Out, InOut. |
| AutoReverse | Boolean | False | Reverse playback at end. |
| Enabled | Boolean | False | Enable/disable animation. |
| Delay | Single | 0.0 | Delay before starting (seconds). |
| Duration | Single | - | Total animation duration (required). |
| Interpolation | TInterpolationType | Linear | Interpolation algorithm. |
| Inverse | Boolean | False | Start from end to beginning. |
| Loop | Boolean | False | Repeat animation continuously. |
| PropertyName | String | - | Target property name (supports dot notation). |
| Trigger / TriggerInverse | String | - | Standard FMX trigger expressions. |
Published Events
| Event | Type | Description |
|---|---|---|
| OnProcess | TNotifyEvent | Fired on every processed animation step. |
| OnFinish | TNotifyEvent | Fired when a non-looping animation reaches its end. |
Public Methods
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
procedure Stop(); override;
Stops the animation and clears internal caches.
procedure AddElements(const AElements: TReferencedComponentList);
Applies animation to multiple components.
Parameters:
AElements- List of components to animate
Example:
var
Elements: TReferencedComponentList;
begin
Elements := TReferencedComponentList.Create();
Elements.AddOrSetValue(Cube1, True);
Elements.AddOrSetValue(Sphere1, True);
Animation.AddElements(Elements);
end;
procedure AddElement(const AElement: TComponent; const AValue: Boolean);
Applies animation to a single component.
Parameters:
AElement- Component to animateAValue- Enable flag (typically True)
Example:
Animation.AddElement(Cube1, True);
procedure LoadFromInterpolatorDef(ADef: TCustomDef); virtual; abstract;
Loads animation from a definition structure. Must be implemented by derived classes.
Parameters:
ADef- Definition object (TPoint3DInterpolatorDef, TVector3DInterpolatorDef, etc.)
procedure ResetCaching();
Resets animation values manipulated during caching.
procedure ProcessCachingTick(time, deltaTime: Single);
Processes animation tick during caching operations.
Parameters:
time- Current animation timedeltaTime- Time since last tick
procedure Transform(const AMat: TMatrix3D); virtual; abstract;
Transforms all keyframe data by a matrix (e.g., for mirroring).
Parameters:
AMat- Transformation matrix to apply
Example:
var
MirrorMatrix: TMatrix3D;
begin
MirrorMatrix := TMatrix3D.CreateScaling(Point3D(-1, 1, 1));
Animation.Transform(MirrorMatrix);
end;
procedure CaptureBlendSnapshot(const ABlendList: TGorillaBlendList); virtual;
Captures the current property values of all targets into ABlendList. Used by
TGorillaAnimationManager to take the "from-pose" when a crossfade starts. The base
implementation does nothing; TPoint3DKeyAnimation, TVector3DKeyAnimation,
TQuaternion3DKeyAnimation and TTransformationKeyAnimation override it.
TCoordinateKeyAnimation (vertex animation) does not take part in crossfading.
TPoint3DKeyAnimation
Keyframe animation for TPoint3D properties (Position, Rotation, Scale).
Inheritance: TPropertyKeyAnimation → TPoint3DKeyAnimation
Platforms: All Gorilla3D supported platforms
Public Methods
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
procedure LoadFromInterpolatorDef(ADef: TCustomDef); override;
Loads from TPoint3DInterpolatorDef.
procedure Transform(const AMat: TMatrix3D); override;
Transforms all keyframe points by matrix.
Usage Example
var
Anim: TPoint3DKeyAnimation;
Key: TPoint3DKey;
begin
Anim := TPoint3DKeyAnimation.Create(Self);
Anim.PropertyName := 'Position.Point';
Anim.Duration := 2.0;
Anim.Loop := True;
Anim.AddElement(Cube1, True);
Key := TPoint3DKey(Anim.Keys.Add);
Key.Time := 0.0;
Key.Value[Cube1] := Point3D(0, 0, 0);
Key := TPoint3DKey(Anim.Keys.Add);
Key.Time := 1.0;
Key.Value[Cube1] := Point3D(10, 5, 0);
Anim.Start();
end;
TVector3DKeyAnimation
Keyframe animation for TVector3D properties.
Inheritance: TPropertyKeyAnimation → TVector3DKeyAnimation
Platforms: All Gorilla3D supported platforms
Public Methods
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
procedure LoadFromInterpolatorDef(ADef: TCustomDef); override;
Loads from TVector3DInterpolatorDef.
procedure Transform(const AMat: TMatrix3D); override;
Transforms all keyframe vectors by matrix.
TQuaternion3DKeyAnimation
Keyframe animation for quaternion-based rotations.
Inheritance: TPropertyKeyAnimation → TQuaternion3DKeyAnimation
Platforms: All Gorilla3D supported platforms
Features:
- Smooth rotation interpolation (SLERP)
- No gimbal lock
- Efficient for complex rotations
Public Methods
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
procedure LoadFromInterpolatorDef(ADef: TCustomDef); override;
Loads from TQuaternion3DInterpolatorDef.
procedure Transform(const AMat: TMatrix3D); override;
Transforms all keyframe quaternions by matrix.
Usage Example
var
Anim: TQuaternion3DKeyAnimation;
Key: TQuaternion3DKey;
Quat: TQuaternion3D;
begin
Anim := TQuaternion3DKeyAnimation.Create(Self);
Anim.PropertyName := 'RotationAngle';
Anim.Duration := 3.0;
Anim.AddElement(Cube1, True);
Quat := TQuaternion3D.Create(Vector3D(0, 0, 0));
Key := TQuaternion3DKey(Anim.Keys.Add);
Key.Time := 0.0;
Key.Value[Cube1] := Quat;
Quat := TQuaternion3D.Create(Vector3D(0, 180, 0));
Key := TQuaternion3DKey(Anim.Keys.Add);
Key.Time := 1.0;
Key.Value[Cube1] := Quat;
Anim.Start();
end;
TTransformationKeyAnimation
Keyframe animation for TMatrix3D transformations (primarily skeletal animation).
Inheritance: TPropertyKeyAnimation → TTransformationKeyAnimation
Platforms: All Gorilla3D supported platforms
Use Cases:
- Joint/bone animation
- Complex combined transforms
- Skeletal rigs
Public Methods
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
procedure LoadFromInterpolatorDef(ADef: TCustomDef); override;
Loads from TTransformationInterpolatorDef.
procedure Transform(const AMat: TMatrix3D); override;
Transforms all keyframe matrices by matrix.
Usage Example
var
Anim: TTransformationKeyAnimation;
Key: TTransformationKey;
Matrix: TMatrix3D;
begin
Anim := TTransformationKeyAnimation.Create(Self);
Anim.PropertyName := 'LocalMatrix';
Anim.AddElement(Joint1, True);
Matrix := TMatrix3D.CreateTranslation(Point3D(0, 0, 0));
Key := TTransformationKey(Anim.Keys.Add);
Key.Time := 0.0;
Key.Value[Joint1] := Matrix;
Matrix := TMatrix3D.CreateTranslation(Point3D(0, 5, 0)) *
TMatrix3D.CreateRotationY(DegToRad(45));
Key := TTransformationKey(Anim.Keys.Add);
Key.Time := 1.0;
Key.Value[Joint1] := Matrix;
Anim.Start();
end;
TCoordinateKeyAnimation
Keyframe animation for vertex positions (mesh morphing).
Inheritance: TPropertyKeyAnimation → TCoordinateKeyAnimation
Platforms: All Gorilla3D supported platforms
Use Cases:
- Vertex animation
- Morph targets
- Facial animation
- Organic deformations
Public Methods
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
procedure LoadFromInterpolatorDef(ADef: TCustomDef); override;
Loads from TMeshInterpolatorDef.
procedure Transform(const AMat: TMatrix3D); override;
Transforms all keyframe vertices by matrix.
Usage Example
var
Anim: TCoordinateKeyAnimation;
Key: TCoordinateKey;
Vertices: TPoint3DDynArray;
begin
Anim := TCoordinateKeyAnimation.Create(Self);
Anim.PropertyName := 'Data.Vertices';
Anim.Duration := 2.0;
Anim.AddElement(CustomMesh1, True);
SetLength(Vertices, CustomMesh1.Data.VertexBuffer.Length);
// ... populate vertices array
Key := TCoordinateKey(Anim.Keys.Add);
Key.Time := 0.0;
Key.Vertices[CustomMesh1] := Vertices;
// ... add more keys
Anim.Start();
end;
TSkeletonKeyAnimation
Container for synchronized animation of multiple property key animations.
Inheritance: TPropertyKeyAnimation → TSkeletonKeyAnimation
Platforms: All Gorilla3D supported platforms
Purpose:
- Synchronize multiple joint animations
- Group related property animations
- Eliminate timing offsets between joints
- Centralized control of complex animations
Public Properties
| Property | Type | Description |
|---|---|---|
| Interpolators | TGorillaPropertyKeyAnimationList | Collection of grouped property animations (read-only). |
| Paused | Boolean | Pause/resume the skeleton. Delphi 13+ only - use it instead of the inherited Pause, which is occupied by TGorillaRenderClock. |
Published Properties
| Property | Type | Default | Description |
|---|---|---|---|
| AutoRepaint | Boolean | True | Automatically call Repaint() after each ProcessAnimation(). |
A new skeleton is created with Loop = True and Duration = 2. Its
LoadFromInterpolatorDef does nothing - the skeleton is only a grouping animation,
TGorillaAnimation.LoadFromAnimationDef fills it.
Public Methods
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
procedure LoadFromInterpolatorDef(ADef: TCustomDef); override;
Loads from animation definition.
procedure AddInterpolator(AInter: TPropertyKeyAnimation);
Adds and enables an interpolator.
Important: Use this method instead of Interpolators.Add() to properly initialize the interpolator.
Parameters:
AInter- Property key animation to add
Example:
var
SkeletonAnim: TSkeletonKeyAnimation;
JointAnim: TTransformationKeyAnimation;
begin
SkeletonAnim := TSkeletonKeyAnimation.Create(Self);
JointAnim := TTransformationKeyAnimation.Create(Self);
JointAnim.PropertyName := 'LocalMatrix';
JointAnim.AddElement(Joint1, True);
// ... configure JointAnim
SkeletonAnim.AddInterpolator(JointAnim);
SkeletonAnim.Start();
end;
procedure Reset();
Resets all child interpolators to starting position by calling ProcessTick(0, 0).
procedure SetSpeed(const ASpeed: Single);
Sets animation speed for all child interpolators.
Parameters:
ASpeed- Factor applied to the duration of every child interpolator
Important: The implementation is Duration := Duration * ASpeed on every interpolator.
It is therefore a duration factor (2.0 = twice as long = half speed), it is
relative and cumulative, and it does not change the skeleton's own Duration. See
Playback Speed for an absolute rate.
Example:
SkeletonAnim.SetSpeed(0.5); // interpolators take half as long
procedure Start(); override;
procedure Stop(); override;
Start/stop the skeleton. The child interpolators are not started themselves - the skeleton copies its own clock into each of them on every tick, which keeps all joints synchronous.
On Delphi 13+ Start hands a skeleton that actually started to TGorillaRenderClock
and Stop gives it back. A start that does not take (invisible parent control, zero
duration) is not handed over.
procedure SeekTo(const ATime: Single);
Puts the play head at ATime (seconds) without computing a pose. The evaluation is
left to the next ordinary tick, so jumping into a clip right after Start does not pay
for a second skeleton evaluation. A pending start delay is cleared as well, because the
delay branch of FMX TAnimation.ProcessTick would otherwise put the clock back to zero.
Parameters:
ATime- Absolute position in seconds,0 .. Duration
Example:
LAnim.Skeleton.SeekTo(0.5 * LAnim.Skeleton.Duration); // half way through the clip
See Seeking to an Exact Position.
procedure ProcessAnimationRemote(ATime, ADeltaTime: Single);
Manually process an animation tick (external control, caching, design-time previews).
It calls ProcessCachingTick on every interpolator and therefore also works on a
stopped or paused skeleton. The step is relative: each call advances by ADeltaTime
from where the interpolators currently are.
Parameters:
ATime- Current animation timeADeltaTime- Time delta since last tick
At design time the interpolators only advance while the global
GorillaDesignTimeAnimationEnabled is True.
procedure Transform(const AMat: TMatrix3D); override;
Transforms all child interpolators by matrix.
Parameters:
AMat- Transformation matrix
TGorillaAnimation
High-level animation instance representing a complete animation (e.g., "Walk", "Run").
Inheritance: TFmxObject → TGorillaAnimation
Platforms: All Gorilla3D supported platforms
Interfaces: IDuplicatable
Public Properties
| Property | Type | Description |
|---|---|---|
| Def | TAnimationDef | Associated animation definition (read-only). |
| Id | String | Registered animation identifier (read-only). |
| Skeleton | TSkeletonKeyAnimation | Skeleton helper interpolator holding sub-interpolators (read-only). |
| IsRunning | Boolean | True if animation is playing (read-only). |
| IsPaused | Boolean | True if animation is paused (read-only). Reads Skeleton.Paused on Delphi 13+, Skeleton.Pause before. |
| FrameCount | Integer | Number of frames of the cache grid, set by LoadFromAnimationDef (read-only). |
| FrameRate | Integer | Frames per second of the cache grid - a build constant, not the source clip's frame rate (read-only). |
| InPlace | Boolean | Removes the horizontal root motion from the clip, so the character animates on the spot. Acts on the definition, therefore on every instance sharing it. Assigning it discards cached frames without rebuilding them - see SetInPlace. |
| HasRootMotion | Boolean | True if the clip carries a measurable horizontal root motion. Valid before InPlace is set as well (read-only). |
Published Properties
| Property | Type | Description |
|---|---|---|
| UseTransform | Boolean | Enable/disable TransformMatrix application. |
| TransformMatrix | TMatrix3D | Transformation matrix for animated vertices. |
| Manager | TGorillaAnimationManager | Owner AnimationManager component. |
| Source | String | Animation file source path. |
Public Methods
constructor Create(AOwner: TComponent); override;
Standard constructor.
constructor CreateEx(const AManager: TGorillaAnimationManager); virtual;
Creates animation with linked manager.
Parameters:
AManager- Parent animation manager
destructor Destroy(); override;
procedure LoadFromAnimationDef(ADef: TAnimationDef); virtual;
Loads animation from definition structure.
Parameters:
ADef- Animation definition from model import
Example:
var
Animation: TGorillaAnimation;
begin
Animation := TGorillaAnimation.CreateEx(Manager);
Animation.LoadFromAnimationDef(ModelDef.Animations[0]);
end;
procedure Start(); virtual;
Enables the skeleton and makes this clip the manager's Current one. Does not
crossfade and does not stop the previously current clip - use
TGorillaAnimationManager.PlayAnimation for that.
procedure Stop(); virtual;
Disables the skeleton. FMX advances the clip to its final frame first.
procedure StopAtCurrent(); virtual;
Stops the animation without advancing it to its final frame - the joints keep the values of the last tick. The crossfade uses it to keep the visible pose as its "from-pose"; use it whenever a clip should freeze where it is.
procedure Reset(); virtual;
Ticks all interpolators at time 0 (see TSkeletonKeyAnimation.Reset).
procedure SetSpeed(const ASpeed: Single);
Delegates to TSkeletonKeyAnimation.SetSpeed.
Parameters:
ASpeed- Factor for the interpolator durations (> 1= slower, cumulative)
function HasCachedFrames(): Boolean;
True while this clip can be drawn from baked frames, i.e. its definition finished
caching (TAnimationDef.BufferingState = Ready).
procedure SetFixedCacheFrame(AFrameNr: Integer);
Sets a fixed frame number for cache debugging.
Parameters:
AFrameNr- Frame number to display
procedure UnsetFixedCacheFrame();
Deactivates fixed frame rendering.
function GetCurrentCachedFrame(const AMeshDef: TMeshDef): TMeshBufferObject;
Returns current mesh buffer object if caching is active.
Parameters:
AMeshDef- Mesh definition
Returns: Cached mesh buffer for current frame, or nil
The frame number is Round(FrameCount * Skeleton.TransitionTime), or the fixed frame
set by SetFixedCacheFrame.
procedure SetInPlace(const AValue: Boolean; const ARebuildCache: Boolean); overload;
Sets InPlace and, with ARebuildCache, bakes the clip again in the same call. Without
the rebuild a clip that was loaded with caching flags loses its baked frames and is drawn
from the mesh's static buffer - the character stands in its bind pose while the animation
reports IsRunning = True.
Parameters:
AValue- Take the horizontal root motion out of the clip (True) or put it back (False)ARebuildCache- Bake the clip again afterwards. Costs what the initial caching cost, which is why it is not what assigning theInPlaceproperty does. Does nothing for a clip that was never cached - an uncached clip is skinned live and shows the change immediately.
The frames are baked from the model this animation belongs to. Baking plays the clip once to sample it and stops it afterwards; a clip that was running is restarted through the manager.
Example:
var LAnim : TGorillaAnimation;
begin
LAnim := GorillaModel1.AnimationManager.GetAnimation('c-run.dae');
// model was loaded with caching flags
LAnim.SetInPlace(True, True);
// drive the character with the motion the clip no longer applies
LOffset := LAnim.RootMotionAt(LAnim.Skeleton.NormalizedTime);
end;
function RootMotionAt(const ANormTime: Single): TPointF;
The horizontal motion InPlace took out, at a normalised position 0..1 of the clip,
relative to its first frame and in model units. X is the world X component, Y the
world Z one.
function RootMotionTotal(): TPointF;
function RootMotionPeak(): Single;
Total motion from the first to the last frame, and the largest distance from the start reached anywhere in the clip.
TGorillaAnimationManager
Central manager for all animations associated with a 3D model or character.
Inheritance: TComponent → TGorillaAnimationManager
Platforms: All Gorilla3D supported platforms
Interfaces: IDuplicatable
A TGorillaModel creates its manager automatically. When you create one yourself, the
owner passed to the constructor must be a TGorillaMesh (or a descendant such as
TGorillaModel) - the constructor casts it and assigns it to Mesh.
The manager owns its animations: removing an entry from Animations or calling
Clear frees the TGorillaAnimation instance.
Public Properties
| Property | Type | Description |
|---|---|---|
| Mesh | TObject | Associated mesh/model object (the owner). |
| Animations | TGorillaAnimationMap | Hashmap of id-to-animation relationships (read-only). Enumerating it yields the hash order - use GetAnimationNames / GetSortedAnimations for a stable order. |
| Current | TGorillaAnimation | Currently active animation instance. Reading it while none is set returns (and stores) GetFirstAnimation. Assigning a different one stops the previous clip without crossfading. |
| BlendActive | Boolean | True while a crossfade is in progress (read-only). |
Published Properties
| Property | Type | Default | Description |
|---|---|---|---|
| CurrentAnimationName | String | - | Id of the current animation. Assigning calls PlayAnimation(Value). |
| BlendEnabled | Boolean | True | Master switch for crossfading in PlayAnimation. |
| BlendDuration | Single | 0.25 | Base crossfade length in seconds; 0 disables blending. |
| BlendUseSmoothStep | Boolean | True | Smoothstep easing instead of a linear ramp. |
| BlendAdaptive | Boolean | True | Scale the fade by the largest angular distance between both poses, clamped to [BlendDuration, BlendMaxDuration]. |
| BlendMaxDuration | Single | 0.6 | Upper bound for the adaptive duration in seconds. |
See Crossfading Between Animations.
Public Methods
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
procedure Clear(); virtual;
Cancels a running crossfade, resets Current and removes (and frees) all animations.
function GetAnimationNames(): TArray<String>;
Returns the ids of all animations, sorted in natural order: runs of digits are compared by their numeric value, everything else case-insensitively.
Returns: Sorted snapshot of the ids. A dynamic array - nothing to free. Empty if the manager holds no animations.
Ordering rules:
Walk2beforeWalk10(digit runs compared numerically, any length, no overflow)idleandIdlesort together (case-insensitive); ids that differ in case only are ordered case-sensitively, so the result is always deterministic2before02(equal value: fewer leading zeros first)- at the same position numbers sort before text, and a prefix before the longer id
Example:
var LName : String;
begin
ComboBox1.Clear();
for LName in GorillaModel1.AnimationManager.GetAnimationNames() do
ComboBox1.Items.Add(LName);
end;
function GetSortedAnimations(): TArray<TGorillaAnimation>;
Returns all animation instances in the same natural order as GetAnimationNames.
Returns: Sorted snapshot. The array needs no freeing; the instances are still owned by the manager - do not free them.
Example:
var LAnim : TGorillaAnimation;
begin
for LAnim in GorillaModel1.AnimationManager.GetSortedAnimations() do
Memo1.Lines.Add(Format('%s: %.2f s', [LAnim.Id, LAnim.Skeleton.Duration]));
end;
function GetFirstAnimation(): TGorillaAnimation;
Returns the first animation in natural id order (see GetAnimationNames) - not
necessarily the first one that was added.
Returns: First animation or nil
function GetLastAnimation(): TGorillaAnimation;
Returns the last animation in natural id order (see GetAnimationNames) - not
necessarily the last one that was added.
Returns: Last animation or nil
function GetAnimation(const AId: String = ''): TGorillaAnimation; overload;
Returns animation by identifier.
Parameters:
AId- Animation identifier (exact, case-sensitive key =TGorillaAnimation.Id, f.e. the file namearcher.dae)
Returns: Animation instance or nil. An empty AId is looked up like any other key
and normally returns nil - use Current for the current animation.
Fallback: If no animation has this id, the component name of the animation
(TGorillaAnimation.Name) is compared, case-insensitive. Component names can not contain
dots or dashes, so the animation with the id archer-idle.dae is named archer_idle_dae -
both strings find it. AddAnimation checks the exact id only.
Prefer
IdoverName: when you fill a list (f.e. a combobox) to play animations from, useTGorillaAnimation.IdorGetAnimationNames().Idis the key the manager stores,Nameis only the derived component name.
Example:
var
WalkAnim: TGorillaAnimation;
begin
WalkAnim := Manager.GetAnimation('Walk');
if Assigned(WalkAnim) then
WalkAnim.Start();
end;
function GetAnimation(const ADef: TAnimationDef): TGorillaAnimation; overload;
Returns animation by definition.
Parameters:
ADef- Animation definition
Returns: Animation instance or nil
function AddAnimation(const AId: String; const AAnimation: TGorillaAnimation): TGorillaAnimation;
Adds animation to manager.
Parameters:
AId- Unique identifierAAnimation- Animation instance
Returns: Added animation, or existing animation if AId already exists
Example:
var
Animation: TGorillaAnimation;
begin
Animation := TGorillaAnimation.CreateEx(Manager);
Animation.LoadFromAnimationDef(AnimDef);
Manager.AddAnimation('Walk', Animation);
end;
function PlayAnimation(const AId: String): TGorillaAnimation; overload;
Plays animation by identifier.
Parameters:
AId- Animation identifier, resolved likeGetAnimation(AId)- the component name works as fallback
Returns: Playing animation or nil if not found
Behavior:
- If already current: restarts it if it is not running, otherwise leaves it alone
- If different: switches to the new clip. While the old clip is running and
BlendEnabledis set withBlendDuration > 0, the current pose is captured, the old clip is stopped withStopAtCurrentand the new one fades in. Otherwise the old clip is stopped and the new one started (hard switch). - A crossfade still in progress is cancelled first; its blended pose becomes the new starting point
- If not found: returns nil, the current clip keeps playing
Example:
Manager.PlayAnimation('Run');
function PlayAnimation(const AAnim: TGorillaAnimation): TGorillaAnimation; overload;
Plays specific animation instance.
Parameters:
AAnim- Animation instance
Returns: Playing animation, nil if AAnim is nil
Same switching and crossfade behaviour as the id overload.
function PlayNextAnimation(): TGorillaAnimation;
Plays the animation that follows the current one in natural id order
(see GetAnimationNames). Goes through PlayAnimation, so it crossfades.
Returns:
- the next animation; after the last one it wraps around to the first
- the first animation if no animation is current
- nil if the manager is empty
function PlayPreviousAnimation(): TGorillaAnimation;
Plays the animation that precedes the current one in natural id order, through
PlayAnimation.
Returns:
- the previous animation; before the first one it wraps around to the last
- the last animation if no animation is current
- nil if the manager is empty
Example:
// registered ids: 'Walk10', 'Idle', 'Walk2'
Manager.PlayAnimation('Idle');
Manager.PlayNextAnimation(); // Walk2
Manager.PlayNextAnimation(); // Walk10
Manager.PlayNextAnimation(); // Idle (wrap-around)
Manager.PlayPreviousAnimation(); // Walk10
Changed behaviour: earlier builds walked the
Animationshashmap, i.e. an unpredictable order that could change whenever animations were added. All navigation routines (GetFirstAnimation,GetLastAnimation,PlayNextAnimation,PlayPreviousAnimation) and theCurrentfallback now follow the naturally sorted ids.
procedure ResetToBindPose(); virtual;
Stops all animations and returns the model to its bind pose (the unanimated pose).
Stop leaves the last pose of the clip and Reset jumps to the first frame of the clip -
neither is the bind pose.
- Every node an animation of this manager writes to (joints and animated sub-meshes) gets the transformation of its definition back, meshes with vertex (morph) animations their original positions. The armatures then skin their meshes once more with that pose, also for a cached clip - its baked frames are only drawn while it runs.
- Nodes no animation touches are left alone, and so is the model itself, so a position the application gave it is kept.
Currentstays assigned;PlayAnimationstarts from the bind pose afterwards.
Also available as TGorillaModel.ResetToBindPose().
procedure CancelBlend();
Aborts a running crossfade. The joints keep their current values, the new animation continues normally.
procedure ApplyBlendIfActive();
Mixes the captured from-pose into the values the running clip just wrote. Called by
TSkeletonKeyAnimation on every tick while BlendActive is set - no need to call it
yourself.
class function ForceStep(AMinDeltaTime: Double = 0.01): Boolean;
Forces animation update outside FMX message loop.
Parameters:
AMinDeltaTime- Minimum time since last update (default: 0.01 seconds)
Returns: True if step was forced, False if skipped
Delphi 13+: FMX no longer has an animation thread to step. ForceStep only answers
whether AMinDeltaTime has passed and records the time - it does not advance anything.
Scene animations are advanced by TGorillaRenderClock at the start of each rendered
frame instead. Using the result as a rate gate keeps working unchanged.
Example:
// In rendering loop or timer
if TGorillaAnimationManager.ForceStep(0.01) then
Viewport.EndUpdate()
else
Viewport.EndUpdateWithoutInvalidate();
TPoint3DAnimation
Simple property animation for TPoint3D without keyframes.
Inheritance: TCustomPropertyAnimation → TPoint3DAnimation
Platforms: All Gorilla3D supported platforms
Published Properties
| Property | Type | Default | Description |
|---|---|---|---|
| StartValue | TPosition3D | - | Starting point. |
| StopValue | TPosition3D | - | Ending point. |
| StartFromCurrent | Boolean | False | Start from current property value. |
| AnimationType | TAnimationType | In | Easing type. |
| AutoReverse | Boolean | False | Reverse at end. |
| Enabled | Boolean | False | Enable/disable. |
| Delay | Single | 0.0 | Start delay. |
| Duration | Single | 0.2 | Animation duration. |
| Interpolation | TInterpolationType | Linear | Interpolation type. |
| Inverse | Boolean | False | Reverse direction. |
| Loop | Boolean | False | Loop playback. |
| PropertyName | String | - | Target property. |
| Trigger / TriggerInverse | String | - | Standard FMX triggers. |
| OnProcess / OnFinish | TNotifyEvent | - | Standard FMX animation events. |
On Delphi 13+ Start / Stop hand the animation to and from TGorillaRenderClock,
because it moves scene content.
Usage Example
var
Anim: TPoint3DAnimation;
begin
Anim := TPoint3DAnimation.Create(Self);
Anim.Parent := Cube1;
Anim.PropertyName := 'Position.Point';
Anim.StartValue.Point := Point3D(0, 0, 0);
Anim.StopValue.Point := Point3D(10, 5, 0);
Anim.Duration := 2.0;
Anim.Loop := True;
Anim.Start();
end;
TGorillaRenderClock
Delphi 13+ only (CompilerVersion >= 37.0).
Keeps the animations that drive scene content on the renderer's clock instead of FMX's display link.
Why: Delphi 13 replaced the FMX animation thread with IFMXDisplayLinkService, and
that service drops a tick whenever a paint is still pending. With a busy renderer
(switching on global illumination is enough) a paint is pending almost always, so poses
advanced in irregular lumps while the image advanced evenly - walk cycles stuttered.
Up to Delphi 12 ForceStep avoided this; on Delphi 13 the clock is put at the frame
instead.
How: TSkeletonKeyAnimation.Start and TPoint3DAnimation.Start hand a running
animation over. The clock holds the FMX Pause flag for it, so the display link leaves
it alone, and drops the flag for exactly one ProcessTick per rendered frame. Delay,
loop, auto-reverse and OnFinish therefore behave as before. A single step is capped at
0.25 s, so one long frame (loading, resize, breakpoint) does not teleport animations.
Because Pause is occupied, the pause state lives in the clock - use
TSkeletonKeyAnimation.Paused / TGorillaAnimation.IsPaused, not Skeleton.Pause.
2D interface animations are not affected and stay with FMX.
Class Methods
| Method | Description |
|---|---|
TakeOver(AAnim) |
Put a running animation under the render clock. |
Release(AAnim) |
Give it back to FMX, restoring its own pause state. Called on Stop and on destruction; Tick also releases animations that stopped otherwise (StopAtCurrent, Enabled := False, a finished clip). |
IsPaused(AAnim) |
Pause state of an animation (falls back to Pause if it is not under the clock). |
SetPaused(AAnim, AValue) |
Pause or resume an animation. |
Tick(): Boolean |
Advance all animations by the elapsed time. Called by TGorillaViewport at the start of each rendered frame - do not call it yourself. |
Data Structures
TPoint3DKey
Single keyframe for TPoint3D animation.
Inheritance: TKey → TPoint3DKey
Properties
| Property | Type | Description |
|---|---|---|
| Value[Index: TComponent] | TPoint3D | Point value for specific component. |
Methods
procedure SetDefaultValue(AValue: TPoint3D);
function GetDefaultValue(): TPoint3D;
TVector3DKey
Single keyframe for TVector3D animation.
Inheritance: TKey → TVector3DKey
Properties
| Property | Type | Description |
|---|---|---|
| Value[Index: TComponent] | TVector3D | Vector value for specific component. |
TQuaternion3DKey
Single keyframe for quaternion animation.
Inheritance: TKey → TQuaternion3DKey
Properties
| Property | Type | Description |
|---|---|---|
| Value[Index: TComponent] | TQuaternion3D | Quaternion value for specific component. |
TTransformationKey
Single keyframe for matrix transformation.
Inheritance: TKey → TTransformationKey
Properties
| Property | Type | Description |
|---|---|---|
| Value[Index: TComponent] | TMatrix3D | Matrix value for specific component. |
TCoordinateKey
Single keyframe for vertex positions.
Inheritance: TKey → TCoordinateKey
Properties
| Property | Type | Description |
|---|---|---|
| Vertices[Index: TComponent] | TPoint3DDynArray | Vertex array for specific component. |
Type Definitions
TGorillaInterpolatorList
TGorillaInterpolatorList = TDictionary<String, TPropertyKeyAnimation>;
Hashmap of identifier-to-animation pairs.
TGorillaAnimationMap
TGorillaAnimationMap = TDictionary<String, TGorillaAnimation>;
Hashmap of identifier-to-TGorillaAnimation pairs.
TElementPoints
TElementPoints = TDictionary<TComponent, TPoint3D>;
Component-to-Point3D hashmap for keys.
TElementVectors
TElementVectors = TDictionary<TComponent, TVector3D>;
Component-to-Vector3D hashmap for keys.
TElementQuaternions
TElementQuaternions = TDictionary<TComponent, TQuaternion3D>;
Component-to-Quaternion3D hashmap for keys.
TElementMatrices
TElementMatrices = TDictionary<TComponent, TMatrix3D>;
Component-to-Matrix3D hashmap for keys.
TGorillaPropertyKeyAnimationList
TGorillaPropertyKeyAnimationList = TObjectList<TPropertyKeyAnimation>;
Type of TSkeletonKeyAnimation.Interpolators (created without item ownership).
TElementVertices
TElementVertices = class(TDictionary<TComponent, TVertexDataMap>);
Component-to-vertex-data hashmap.
TGorillaBlendEntryKind / TGorillaBlendEntry / TGorillaBlendList
TGorillaBlendEntryKind = (bekPoint3D, bekVector3D, bekQuaternion3D, bekMatrix3D);
TGorillaBlendList = TObjectList<TGorillaBlendEntry>;
Crossfade structures. A TGorillaBlendEntry holds one captured property value
(component, instance, RTTI property, kind, snapshot value and the offset that is decayed
over the blend). IsEulerRotation marks Euler rotations in degrees, which are blended
along the shortest arc. The list owns its entries.
TElementCoordinates
TElementCoordinates = TDictionary<TComponent, TPoint3DDynArray>;
Component-to-vertex-array hashmap for keys.
Global Variables
| Variable | Default | Description |
|---|---|---|
GorillaDesignTimeAnimationEnabled |
False | Lets ProcessCachingTick advance animations of components in design state. Set it only while driving a design-time preview through ProcessAnimationRemote. |
GorillaSkipJointsWhenCached |
False | Skips the per-joint evaluation while a clip is drawn from baked frames. Saves CPU for crowds, but joint transforms, attachments, IK, joint-based bounds and the crossfade freeze at the last full evaluation. |
gOneInterpolator |
False | Internal debugging switch. |
Important Notes
-
Synchronization: Use
TSkeletonKeyAnimationto group related animations for synchronized playback without timing offsets. -
Performance: Up to Delphi 12, use
ForceStep()in rendering loops to avoid FMX timer jitter. From Delphi 13 on,TGorillaRenderClockkeeps poses and frames in step automatically. -
Caching: Complex vertex animations benefit from frame caching to reduce CPU load.
-
Property Names: Supports dot notation for nested properties (e.g., "Position.Point.X").
-
Multiple Elements: Single animation can control multiple components with different values per keyframe.
-
Interpolation: All animations support standard FireMonkey interpolation types (Linear, Quadratic, Cubic, etc.).
-
Transform Matrices: Animations can be transformed (mirrored, scaled) by applying matrices to all keyframes.
-
AutoRepaint: Disable
AutoRepaintonTSkeletonKeyAnimationfor manual viewport control and better performance. -
Memory Management: Always properly stop and free animations to prevent memory leaks.
-
Thread Safety: Animation updates occur on the main thread - via the FMX animation timer up to Delphi 12, via
TGorillaRenderClockand the display link from Delphi 13 on. -
Order of Animations:
Animationsis a hashmap without a defined order. Everything that needs an order -GetFirstAnimation,GetLastAnimation,PlayNextAnimation,PlayPreviousAnimation- uses the natural id order ofGetAnimationNames. -
Crossfading: Only
PlayAnimation(and thereforeCurrentAnimationName,PlayNextAnimationandPlayPreviousAnimation) crossfades.Start()on an animation and assigningCurrentswitch hard.
See Also
- Animation User Guide
- Animation Playback Control - Speed, seeking, crossfading, root motion
- Models User Guide
- Gorilla.DefTypes Unit