Gorilla.Animation
Unit Gorilla.Animation.pasClasses
- TElementVertices = class ( {System.Generics.Collections}TDictionary<System.Classes.TComponent,System.Generics.Collections.TDictionary<System.Word,Gorilla.DefTypes.TVertexData>> )
- TPropertyKeyAnimation = class ( TCustomPropertyAnimation , IDuplicatable )
- TPoint3DKey = class ( TKey )
- TPoint3DKeyAnimation = class ( TPropertyKeyAnimation )
- TVector3DKey = class ( TKey )
- TVector3DKeyAnimation = class ( TPropertyKeyAnimation )
- TQuaternion3DKey = class ( TKey )
- TQuaternion3DKeyAnimation = class ( TPropertyKeyAnimation )
- TTransformationKey = class ( TKey )
- TTransformationKeyAnimation = class ( TPropertyKeyAnimation )
- TCoordinateKey = class ( TKey )
- TCoordinateKeyAnimation = class ( TPropertyKeyAnimation )
- TSkeletonKeyAnimation = class ( TPropertyKeyAnimation )
- TGorillaAnimation = class ( TFmxObject , IDuplicatable )
- TGorillaAnimationManager = class ( TComponent , IDuplicatable )
- TAnimationHack = class ( TFmxObject )
Records
- record TPropertyInstanceBuffer
TElementVertices
A hash map of component vertexdata pairs.
Ancestors
TPropertyKeyAnimation
The Gorilla3D specific property key animation as basis for TPoint3DKeyAnimation, TVector3DKeyAnimation, TTransformationKeyAnimation and TCoordinateKeyAnimation.
Ancestors
Implements Interfaces
- IDuplicatable
Members
Fields
- protected FQualifiedName :
string
- protected FElements :
TReferencedComponentList
- protected FDef :
TObject
- protected FKeys :
TKeys
- protected FStartFromCurrent :
Boolean
- protected FTransitionTime :
Single
- protected FCPIBuffer :
TComponentPropertyInstanceBuffer
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected function FindPropertyAndInstance ( const AComp : TComponent; out AProp : TRttiProperty; out AInstance : TObject ) : Boolean ;
- protected procedure DoDuplicate
(
ASource :
TComponent; ADuplicator :
TGorillaDuplicator
)
;
virtual;
Duplicates a TGorillaMesh/TGorillaModel and all of its submeshes. The method copies the complete memory structure and refreshes necessary lists and standalone components
- public procedure Stop ( ) ; override;
- public procedure AddElements
(
const
AElements :
TReferencedComponentList
)
;
Apply this specific key animation to a number of components.
- public procedure AddElement
(
const
AElement :
TComponent; const
AValue :
Boolean
)
;
Apply this specific key animation to a specific component.
- public procedure LoadFromInterpolatorDef
(
ADef :
TCustomDef
)
;
abstract virtual;
Loading a key animation from a specific TInterpolatorDef.
- public procedure ResetCaching
(
)
;
We need to reset the animation values we've manipulated while caching, to prevent access violations.
- public procedure ProcessCachingTick
(
time :
Single; deltaTime :
Single
)
;
We need a separated ProcessTick() method especially for caching, because some properties are not set while caching (f.e. IsRunning).
- public procedure Transform
(
const
AMat :
TMatrix3D
)
;
abstract virtual;
Use this method to translate, rotate or scale vertices of a mesh modified by a specific animation. This method can be used to mirror an animation.
Properties
- public QualifiedName : string
A defined qualified identifier taken from importing a key animation from definition structures by LoadFromInterpolatorDef().
read FQualifiedName
write FQualifiedName - public Elements : TDictionary<System.Classes.TComponent,System.Boolean>
- public Def : TObject
- public TransitionTime : Single
Returns the latest computed normalized time. This property is used for cached skeleton animation to keep humanoid animation and rendering synchronized. Otherwise cached frames would be rendered faster than humanoid joints are getting transformed.
read FTransitionTime - published Keys : TKeys
- published StartFromCurrent : Boolean
- published AnimationType : TAnimationType
- published AutoReverse : Boolean
- published Enabled : Boolean
- published Delay : Single
- published Duration : Single
- published Interpolation : TInterpolationType
- published Inverse : Boolean
- published Loop : Boolean
- published PropertyName : string
- published Trigger : TTrigger
- published TriggerInverse : TTrigger
TPoint3DKey
Single key structure stored a list of component-TPoint3D pairs.
Ancestors
Members
Fields
Methods
- public constructor Create ( Collection : TCollection ) ;
- public destructor Destroy ( ) ;
- private function GetValue ( AIndex : TComponent ) : TPoint3D ;
- private procedure SetValue ( AIndex : TComponent; const AValue : TPoint3D ) ;
- public procedure SetDefaultValue ( AValue : TPoint3D ) ;
- public function GetDefaultValue ( ) : TPoint3D ;
Properties
TPoint3DKeyAnimation
Defines a TPoint3D animation controlled by keys. Use this animation type for animating f.e. the position, scale or rotation of a specific FMX object, instead of creating a TFloatAnimation for each part of a TPoint3D property.
Ancestors
Members
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure ProcessAnimation ( ) ; override;
- protected procedure FirstFrame ( ) ; override;
- protected function PointsEqual ( const P1 : TPoint3D; const P2 : TPoint3D ) : Boolean ;
- protected function InterpolatePoint3D ( const Start : TPoint3D; const Stop : TPoint3D; T : Single ) : TPoint3D ;
- public procedure LoadFromInterpolatorDef ( ADef : TCustomDef ) ; override;
- public procedure Transform ( const AMat : TMatrix3D ) ; override;
TVector3DKey
Single key structure stored a list of component-TVector3D pairs.
Ancestors
Members
Fields
Methods
- public constructor Create ( Collection : TCollection ) ;
- public destructor Destroy ( ) ;
- private function GetValue ( AIndex : TComponent ) : TVector3D ;
- private procedure SetValue ( AIndex : TComponent; const AValue : TVector3D ) ;
- public procedure SetDefaultValue ( AValue : TVector3D ) ;
- public function GetDefaultValue ( ) : TVector3D ;
Properties
TVector3DKeyAnimation
Defines a TVector3D animation controlled by keys. Use this animation type for animating f.e. the position, scale or rotation of a specific FMX object, instead of creating a TFloatAnimation for each part of a TVector3D property.
Ancestors
Members
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure ProcessAnimation ( ) ; override;
- protected procedure FirstFrame ( ) ; override;
- protected function InterpolateVector3D ( const Start : TVector3D; const Stop : TVector3D; T : Single ) : TVector3D ;
- public procedure LoadFromInterpolatorDef ( ADef : TCustomDef ) ; override;
- public procedure Transform ( const AMat : TMatrix3D ) ; override;
TQuaternion3DKey
Single key structure stored a list of component-TQuaternion3D pairs.
Ancestors
Members
Fields
Methods
- public constructor Create ( Collection : TCollection ) ;
- public destructor Destroy ( ) ;
- private function GetValue ( AIndex : TComponent ) : TQuaternion3D ;
- private procedure SetValue ( AIndex : TComponent; const AValue : TQuaternion3D ) ;
- public procedure SetDefaultValue ( AValue : TQuaternion3D ) ;
- public function GetDefaultValue ( ) : TQuaternion3D ;
Properties
TQuaternion3DKeyAnimation
Defines a TVector3D animation controlled by keys. Use this animation type for animating f.e. the position, scale or rotation of a specific FMX object, instead of creating a TFloatAnimation for each part of a TVector3D property.
Ancestors
Members
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure ProcessAnimation ( ) ; override;
- protected procedure FirstFrame ( ) ; override;
- protected function InterpolateQuaternion3D ( const Start : TQuaternion3D; const Stop : TQuaternion3D; T : Single ) : TQuaternion3D ;
- public procedure LoadFromInterpolatorDef ( ADef : TCustomDef ) ; override;
- public procedure Transform ( const AMat : TMatrix3D ) ; override;
TTransformationKey
Single key structure stored a list of component-TMatrix3D pairs.
Ancestors
Members
Fields
Methods
- public constructor Create ( Collection : TCollection ) ;
- public destructor Destroy ( ) ;
- private function GetValue ( AIndex : TComponent ) : TMatrix3D ;
- private procedure SetValue ( AIndex : TComponent; const AValue : TMatrix3D ) ;
- public procedure SetDefaultValue ( AValue : TMatrix3D ) ;
- public function GetDefaultValue ( ) : TMatrix3D ;
Properties
TTransformationKeyAnimation
Defines a TMatrix3D animation controlled by keys. This animation type is especially used for manipulating joints of a skeleton or skin-animation. By this animation type you can easily manipulate Position, Scale and Rotation at once, instead of instanciating multiple animations for each part.
Ancestors
Members
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure ProcessAnimation ( ) ; override;
- protected procedure FirstFrame ( ) ; override;
- protected function InterpolateMatrix3D ( const Start : TMatrix3D; const Stop : TMatrix3D; T : Single ) : TMatrix3D ;
- public procedure LoadFromInterpolatorDef ( ADef : TCustomDef ) ; override;
- public procedure Transform ( const AMat : TMatrix3D ) ; override;
TCoordinateKey
Single key structure stored a list of component-TPoint3DDynArray pairs.
Ancestors
Members
Fields
Methods
- public constructor Create ( Collection : TCollection ) ;
- public destructor Destroy ( ) ;
- private function GetVertices ( AIndex : TComponent ) : TPoint3DDynArray ;
- private procedure SetVertices ( AIndex : TComponent; const AValue : TPoint3DDynArray ) ;
- public procedure SetDefaultValue ( AValue : TPoint3DDynArray ) ;
- public function GetDefaultValue ( ) : TPoint3DDynArray ;
Properties
- public Vertices[Index] : TPoint3DDynArray
Returns the key vertices for a specific component at the current key position.
read GetVertices
write SetVertices
TCoordinateKeyAnimation
Defines a Vertex animation controlled by keys. This animation type is used for vertex manipulation. Each key contains all mesh vertices and the animation interpolates between those keys.
Ancestors
Members
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure ProcessAnimation ( ) ; override;
- protected procedure FirstFrame ( ) ; override;
- protected function InterpolateCoordinates ( const Start : TPoint3DDynArray; const Stop : TPoint3DDynArray; T : Single ) : TPoint3DDynArray ;
- protected procedure Precalculate ( ) ;
- public procedure LoadFromInterpolatorDef ( ADef : TCustomDef ) ; override;
- public procedure Transform ( const AMat : TMatrix3D ) ; override;
TSkeletonKeyAnimation
The SkeletonKeyAnimation is Helper-Animation for skeleton- / skin-animations. Here often many joints come with an animation. Due to async handling of each interpolator (joint), there could be tiny offsets which lead to massive graphics disposition-effects.
Remarks
The SkeletonKeyAnimation instance holds a number of TPropertyKeyAnimation instances. None of those animations are really executed. The SkeletonKeyAnimation executes the ProcessTick() routine of each interpolator instead of the asynchronous animation thread.Ancestors
Members
Fields
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure ProcessAnimation
(
)
;
override;
Overrides the internal ProcessAnimation routine, updates time information of each added interpolator and calls afterwards ProcessAnimation for each child interpolator. The animation itself has no animation support, it's only used for grouping PropertyKeyAnimations.
- public procedure LoadFromInterpolatorDef ( ADef : TCustomDef ) ; override;
- public procedure AddInterpolator
(
AInter :
TPropertyKeyAnimation
)
;
Adds a new interpolator to the grouping animation and enables the specific interpolator.
- public procedure Reset
(
)
;
Iterates through all child interpolators and resets time information by ProcessTick(0, 0). This will reset animation of each interpolator to starting position.
- public procedure SetSpeed
(
const
ASpeed :
Single
)
;
Use this method to scale animation speed. The method will iterate through all child interpolators and call their SetSpeed method with the supplied parameter.
- public procedure Start ( ) ; override;
- public procedure Stop ( ) ; override;
- public procedure ProcessAnimationRemote ( ATime : Single; ADeltaTime : Single ) ;
- public procedure Transform
(
const
AMat :
TMatrix3D
)
;
override;
Method to transform an animation by a supplied transformation matrix. You can use this function for mirroring an animation or similar things.
Properties
- public Interpolators : TObjectList<Gorilla.Animation.TPropertyKeyAnimation>
Returns the list of grouped interpolators. Do not use Interpolators.Add()! Use the AddInterpolator() method to add a new interpolator to the animation group. Otherwise the specific interpolator may not be able to run.
read FInterpolators - published AutoRepaint : Boolean
By the AutoRepaint property you can control the update mechanism. By default (TRUE) the SkeletonKeyAnimation will automatically call Repaint() after each ProcessAnimation() call. This means with every animation step an update process is initiated. If you want to control repainting yourself by BeginUpdate/EndUpdate of the TGorillaViewport, set this property to FALSE.
read FAutoRepaint
write FAutoRepaint
TGorillaAnimation
Ancestors
Implements Interfaces
- IDuplicatable
Members
Fields
- protected FDef :
TAnimationDef
- protected FManager :
TGorillaAnimationManager
- protected FSkeleton :
TSkeletonKeyAnimation
- protected FDuration :
Double
- protected FFrameCount :
Integer
- protected FFrameRate :
Integer
- protected FFixedCacheFrame :
Integer
- protected FUseTransform :
Boolean
- protected FTransformMatrix :
TMatrix3D
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public constructor CreateEx ( const AManager : TGorillaAnimationManager ) ;
- public destructor Destroy ( ) ;
- protected function GetId ( ) : string ;
- protected function GetIsRunning ( ) : Boolean ;
- protected function GetIsPaused ( ) : Boolean ;
- protected procedure SetParent ( const Value : TFmxObject ) ; override;
- protected procedure SetManager ( const AValue : TGorillaAnimationManager ) ;
- protected function GetSource ( ) : string ;
- protected procedure SetSource ( const AValue : string ) ;
- protected procedure DoDuplicate ( ASource : TComponent; ADuplicator : TGorillaDuplicator ) ; virtual;
- public procedure LoadFromAnimationDef ( ADef : TAnimationDef ) ; virtual;
- public procedure Start ( ) ; virtual;
- public procedure Stop ( ) ; virtual;
- public procedure Reset ( ) ; virtual;
- public procedure SetSpeed ( const ASpeed : Single ) ;
- public procedure SetFixedCacheFrame
(
AFrameNr :
Integer
)
;
For debugging it is useful to set a specific frame number in cache. This allows to check for correct caching of each frame.
- public procedure UnsetFixedCacheFrame
(
)
;
To deactivate fixed frame rendering from cache, unset the fixed number by this method.
- public function GetCurrentCachedFrame
(
const
AMeshDef :
TMeshDef
)
: TMeshBufferObject
;
Request the current mesh buffer object if caching is activated. The method detects the current frame number by the internal TransitionTime value.
- public function SearchUpwardsForComponent ( const AClass : TClass ) : TFmxObject ;
- public function GetParentViewport ( ) : TFmxObject ;
- public procedure UnsetParentRaw ( ) ;
Properties
- public Def : TAnimationDefread FDef
- public Id : string
- public Skeleton : TSkeletonKeyAnimation
Returns the skeleton helper interpolator which holds all sub interpolators for faster animation.
read FSkeleton - public IsRunning : Boolean
- public IsPaused : Boolean
- public FrameCount : Integer
Returns the internally set number of frames. This value is set on loading from TAnimationDef.
read FFrameCount - public FrameRate : Integer
Returns the internally set number of frames per second. This value is set on loading from TAnimationDef.
read FFrameRate - published UseTransform : Boolean
Enable / disable usage of TransformMatrix on animated vertices. Only if UseTransform is true, the transformation will be applied.
read FUseTransform
write FUseTransform - published TransformMatrix : TMatrix3D
Setup a transformation matrix to manipulate animated vertices. Only if UseTransform is enabled, the matrix will be applied.
read FTransformMatrix
write FTransformMatrix - published Manager : TGorillaAnimationManager
- published Source : string
TGorillaAnimationManager
Ancestors
Implements Interfaces
- IDuplicatable
Members
Fields
- private FLastTickTime :
Double
- protected FMesh :
TObject
- protected FCurrent :
TGorillaAnimation
- protected FAnimations :
TGorillaAnimationMap
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure SetCurrentAnimation ( const AValue : TGorillaAnimation ) ;
- protected function GetCurrentAnimation ( ) : TGorillaAnimation ;
- protected procedure SetCurrentAnimationName ( const AValue : string ) ;
- protected function GetCurrentAnimationName ( ) : string ;
- protected procedure DoOnValueNotify ( ASender : TObject; const AItem : TGorillaAnimation; AAction : TCollectionNotification ) ;
- protected procedure DoDuplicate ( ASource : TComponent; ADuplicator : TGorillaDuplicator ) ; virtual;
- public procedure Clear ( ) ; virtual;
- public function GetFirstAnimation
(
)
: TGorillaAnimation
;
Returns the first animation can be found in animations map.
- public function GetLastAnimation
(
)
: TGorillaAnimation
;
Returns the last animation can be found in animations map.
- public function GetAnimation
(
const
AId :
string
=
)
: TGorillaAnimation
;
overload;
Returns an animation instance identified by its id.
- public function GetAnimation
(
const
ADef :
TAnimationDef
)
: TGorillaAnimation
;
overload;
Returns an animation instance based on a specific animation definition.
- public function AddAnimation
(
const
AId :
string; const
AAnimation :
TGorillaAnimation
)
: TGorillaAnimation
;
Adds a new animation by id to the animation manager.
- public function PlayAnimation
(
const
AId :
string
)
: TGorillaAnimation
;
overload;
Sets the current animation to an animation with the supplied id.
- public function PlayAnimation
(
const
AAnim :
TGorillaAnimation
)
: TGorillaAnimation
;
overload;
Sets the current animation to an animation with the supplied animation.
- public function PlayNextAnimation
(
)
: TGorillaAnimation
;
Starts the next animation in row. If no current animation is running, the method will start the first animation it can find. If there is no next animation, the first animation will be played again. If no animation exists, the routine returns nil.
- public function PlayPreviousAnimation
(
)
: TGorillaAnimation
;
Starts the previous animation in row. If no current animation is running, the method will start the last animation it can find. If there is no previous animation, the last animation will be played again. If no animation exists, the routine returns nil.
- public function ForceStep
(
AMinDeltaTime :
Double
=
0.01
)
: Boolean
;
class;
It is useful to call for an animation update aside of FMX message loop. Because TAniThread is a TTimer running in main thread, sometimes its getting stuttering on animation playback. By this method you can force to update all animations. This updates all animations of all characters!
- public function FindComponentDeepSearch ( const AName : string ) : TComponent ;
- public function FindComponentDeepSearchByClass ( AClass : TClass ) : TComponent ;
- public procedure FindAllComponentsByClass ( AClass : TClass; var AReturn : TArray<System.Classes.TComponent> ) ;
- public function LogComponentHierarchy ( AIndent : string ) : string ;
- public procedure ReadPointField ( var AField : TPoint; Reader : TReader ) ;
- public procedure WritePointField ( AField : TPoint; Writer : TWriter ) ;
- public procedure ReadPointFField ( var AField : TPointF; Reader : TReader ) ;
- public procedure WritePointFField ( AField : TPointF; Writer : TWriter ) ;
- public procedure ReadPoint3DField ( var AField : TPoint3D; Reader : TReader ) ;
- public procedure WritePoint3DField ( AField : TPoint3D; Writer : TWriter ) ;
- public procedure ReadSize3DField ( var AField : TSize3D; Reader : TReader ) ;
- public procedure WriteSize3DField ( AField : TSize3D; Writer : TWriter ) ;
- public procedure ReadVector3DField ( var AField : TVector3D; Reader : TReader ) ;
- public procedure WriteVector3DField ( AField : TVector3D; Writer : TWriter ) ;
- public procedure ReadQuaternionField ( var AField : TQuaternion3D; Reader : TReader ) ;
- public procedure WriteQuaternionField ( AField : TQuaternion3D; Writer : TWriter ) ;
- public procedure ReadAlphaColorFField ( var AField : TAlphaColorF; Reader : TReader ) ;
- public procedure WriteAlphaColorFField ( AField : TAlphaColorF; Writer : TWriter ) ;
- public procedure ReadPlaneFField ( var AField : TPlaneF; Reader : TReader ) ;
- public procedure WritePlaneFField ( AField : TPlaneF; Writer : TWriter ) ;
Properties
TAnimationHack
The animation helper structure allows to access private fields. Those are not available for public access, but need to be manipulated to support animations during background caching.
Ancestors
Members
Fields
- public AniFrameRate :
Integer
- private FAniThread :
TTimer
- public FTickCount :
Integer
- public FDuration :
Single
- public FDelay :
Single
- public FDelayTime :
Single
- public FTime :
Single
- public FInverse :
Boolean
- public FSavedInverse :
Boolean
- public FLoop :
Boolean
- public FPause :
Boolean
- public FRunning :
Boolean
- public FOnFinish :
TNotifyEvent
- public FOnProcess :
TNotifyEvent
- public FInterpolation :
TInterpolationType
- public FAnimationType :
TAnimationType
- public FEnabled :
Boolean
- public FAutoReverse :
Boolean
- public FTriggers :