Gorilla.Animation.Controller
Unit Gorilla.Animation.Controller.pasClasses
- TGorillaAnimationRef = class ( TObject )
- TGorillaAnimationRefList = class ( {System.Generics.Collections}TObjectList<Gorilla.Animation.Controller.TGorillaAnimationRef> )
- TGorillaAnimationTransition = class ( TCollectionItem )
- TGorillaAnimationTransitionsMap = class ( {System.Generics.Collections}TDictionary<System.string,System.Generics.Collections.TList<Gorilla.Animation.Controller.TGorillaAnimationTransition>> )
- TGorillaAnimationTransitionCollection = class ( TOwnedCollection )
- TGorillaAnimationTransitionLayer = class ( TCollectionItem )
- TGorillaAnimationTransitionLayerCollection = class ( TOwnedCollection )
- TGorillaAnimationController = class ( TGorillaController )
Records
Enumerations
- enum TGorillaAnimationTransitionDetectionKind = ( tkHotKeyAndStates, tkCustom ) ;
- enum TGorillaAnimationTransitionMode = ( tmImmediatly, tmSequentially, tmBlend ) ;
Constants
TGorillaAnimationTransitionDetectionKind
The detection kind defines, what kind of information is used to trigger a transition.
Remarks
tkHotKeyAndStates - a pressed hotkey and active states are checked.
tkCustom - a variable and its value is submitted.
TGorillaAnimationTransitionMode
The transition mode defines how switching between two animations is handled. You can choose between immediatly, sequential or blending.
Remarks
tmImmediatly - destination animation will be switched immediatly.
tmSequential - controller will switch to destination animation at the end of the current animation.
tmBlend - controller will blend animations (not supported yet!) - will be treated like tmSequential at the moment.
TGorillaAnimationTransitionKey
Methods
- public function GetKey ( AAnimFrom : string; AHotKey : TGorillaCharacterControllerHotKey; AStates : TGorillaCharacterControllerStates ) : string ; static overload;
- public function GetKey ( AAnimFrom : string; AVariable : string; AValue : string ) : string ; static overload;
- public function GetKey ( AAnimFrom : string; AVariable : string; AValue : TValue ) : string ; static overload;
TGorillaAnimationRef
Ancestors
Members
TGorillaAnimationTransition
An animation transition defines the switch between two different animations by the TGorillaAnimationController component.
Ancestors
Members
Fields
- protected FName :
string
- protected FDetectionKind :
TGorillaAnimationTransitionDetectionKind
- protected FMode :
TGorillaAnimationTransitionMode
- protected FLoop :
Boolean
- protected FHotKey :
TGorillaCharacterControllerHotKey
- protected FStates :
TGorillaCharacterControllerStates
- protected FVariable :
string
- protected FValue :
string
- protected FAnimationFrom :
string
- protected FAnimationFromLink :
TGorillaAnimation
- protected FAnimationTo :
string
- protected FAnimationToLink :
TGorillaAnimation
- protected FOffsetAnimationFrom :
Single
- protected FOffsetAnimationTo :
Single
- protected FDuration :
Single
Methods
- public constructor Create ( ACollection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected function GetKey ( ) : string ; virtual;
- protected function GetDisplayName ( ) : string ; override;
- protected procedure SetDisplayName ( const AValue : string ) ; override;
- protected function GetAnimationFrom ( ) : string ; virtual;
- protected procedure SetAnimationFrom ( const AValue : string ) ; virtual;
- protected function GetAnimationTo ( ) : string ; virtual;
- protected procedure SetAnimationTo ( const AValue : string ) ; virtual;
- protected function GetAnimationFromLink ( ) : TGorillaAnimation ;
- protected function GetAnimationToLink ( ) : TGorillaAnimation ;
- protected function GetAnimationManager ( ) : TGorillaAnimationManager ;
- protected function GetCurrentAnimation ( ) : TGorillaAnimation ;
- protected procedure DoOnFinishAnimation ( ASender : TObject ) ;
- public procedure Assign ( Source : TPersistent ) ; override;
- public function ToJSON ( ) : TJSONObject ; virtual;
- public function ToJSONString ( ) : string ; virtual;
- public procedure FromJSON ( AJSON : TJSONObject ) ; virtual;
- public function DispatchInput
(
ACurrent :
TGorillaAnimation; AHotKey :
TGorillaCharacterControllerHotKey; AStates :
TGorillaCharacterControllerStates
)
: Boolean
;
overload virtual;
Dispatches input event data to check for a transition to be triggered.
- public function DispatchInput
(
ACurrent :
TGorillaAnimation; AVariable :
string; AValue :
TValue
)
: Boolean
;
overload virtual;
Dispatches variable data to check for a transition to be triggered.
- public procedure Switch
(
ACurrent :
TGorillaAnimation
)
;
Starts an animation transition to switch from one animation to another. This method will automatically be called after DispatchInput returns true.
Properties
- public Key : string
Returns a unique key depending on search criteria. The key is used for fast finding the right transition, instead of iterating all transitions.
read GetKey - published DisplayName : string
- published DetectionKind : TGorillaAnimationTransitionDetectionKind
The detection kind defines which kind of variables are used to trigger a specific transition. You can choose between an integrated method by input controller hotkey and input state, or by custom variable name and value.
read FDetectionKind
write FDetectionKind - published Mode : TGorillaAnimationTransitionMode
- published Loop : Boolean
- published HotKey : TGorillaCharacterControllerHotKey
- published States : TGorillaCharacterControllerStates
- published Variable : string
- published Value : string
- published AnimationFrom : string
Get or set the animation where transitions starts (current animation). Set the id of the specific animation, references will be solved later.
read GetAnimationFrom
write SetAnimationFrom - published AnimationTo : string
Get or set the animation where transitions ends (destination animation). Set the id of the specific animation, references will be solved later.
read GetAnimationTo
write SetAnimationTo - published OffsetAnimationFrom : Single
On blended transitions we need an offset in from-animation, where blending should start. The duration value defines the length of blending section.
read FOffsetAnimationFrom
write FOffsetAnimationFrom - published OffsetAnimationTo : Single
On blended transitions we need an offset in to-animation, where blending should start. The duration value defines the length of blending section.
read FOffsetAnimationTo
write FOffsetAnimationTo - published Duration : Single
TGorillaAnimationTransitionsMap
TGorillaAnimationTransitionCollection
An animation transition collection holds all registered transitions managed by the TGorillaAnimationController. This is an UI helper class to support DesignTime editing of transitions.
Ancestors
Members
Fields
Methods
- public destructor Destroy ( ) ;
- protected function GetLayer ( ) : TGorillaAnimationTransitionLayer ; virtual;
- protected function GetController ( ) : TGorillaAnimationController ; virtual;
- public function ToJSON ( ) : TJSONArray ; virtual;
- public procedure FromJSON ( AJSON : TJSONArray ) ; virtual;
- public procedure UpdateHashMap
(
)
;
Rebuilds the hashmap of transitions to support fast finding of transitions.
- public function TryGetTransition ( ACurrent : TGorillaAnimation; AHotKey : TGorillaCharacterControllerHotKey; AStates : TGorillaCharacterControllerStates; out ATransition : TGorillaAnimationTransition ) : Boolean ; overload;
- public function TryGetTransition ( ACurrent : TGorillaAnimation; AVariable : string; AValue : string; out ATransition : TGorillaAnimationTransition ) : Boolean ; overload;
Properties
TGorillaAnimationTransitionLayer
An animation transition layer is an abstraction to group complex animation behaviour. Because models with many animations will produce a very complex system of transitions. To allow grouping of those transitions we provide the layer system.
Ancestors
Members
Fields
- protected FName :
string
- protected FAnimations :
TGorillaAnimationRefList
- protected FTransitions :
TGorillaAnimationTransitionCollection
Methods
- public constructor Create ( ACollection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected procedure SetTransitions ( const AValue : TGorillaAnimationTransitionCollection ) ; virtual;
- protected function GetDisplayName ( ) : string ; override;
- protected procedure SetDisplayName ( const AValue : string ) ; override;
- protected function GetModel ( ) : TGorillaModel ;
- protected function GetAnimationManager ( ) : TGorillaAnimationManager ;
- protected function GetCurrentAnimation ( ) : TGorillaAnimation ;
- protected function GetAnimationController ( ) : TGorillaAnimationController ;
- protected procedure SetLastDispatch ( ADisp : TGorillaAnimationDispatcher ) ;
- public procedure Assign ( Source : TPersistent ) ; override;
- public procedure Clear ( ) ; virtual;
- public function ToJSON ( ) : TJSONObject ; virtual;
- public procedure FromJSON ( AJSON : TJSONObject ) ; virtual;
- public procedure RebuildAnimationReferences ( ) ;
- public procedure RequestAnimationReferences ( ) ;
- public procedure AddAllAnimationReferences ( ) ;
- public procedure DispatchInput
(
ADispatcher :
TGorillaAnimationDispatcher
)
;
overload virtual;
Dispatch dispatcher-information. This is used on recalling dispatching on animation switches.
- public procedure DispatchInput
(
AHotKey :
TGorillaCharacterControllerHotKey; AStates :
TGorillaCharacterControllerStates
)
;
overload virtual;
Dispatch input event data to all transitions to check if one getting triggered.
- public procedure DispatchInput
(
AVariable :
string; AValue :
string
)
;
overload virtual;
Dispatch input variable data to all transitions to check if one getting triggered.
- public procedure DispatchInput
(
AVariable :
string; AValue :
TValue
)
;
overload virtual;
Dispatch input variable data to all transitions to check if one getting triggered.
- public function AddTransition
(
const
AName :
string; const
AFrom :
string; const
ATo :
string; ADoLoop :
Boolean; AHotKey :
TGorillaCharacterControllerHotKey; AStates :
TGorillaCharacterControllerStates; AMode :
TGorillaAnimationTransitionMode
)
: TGorillaAnimationTransition
;
overload virtual;
Helper method to add a new transition instance easily.
- public function AddTransition
(
const
AName :
string; const
AFrom :
string; const
ATo :
string; ADoLoop :
Boolean; AVariable :
string; AValue :
TValue; AMode :
TGorillaAnimationTransitionMode
)
: TGorillaAnimationTransition
;
overload virtual;
Helper method to add a new transition instance easily.
- public procedure DeleteTransition ( const AName : string ) ; overload virtual;
- public procedure DeleteTransition ( const AFrom : string; const ATo : string ) ; overload virtual;
- public function FindTransition ( const AName : string ) : TGorillaAnimationTransition ; overload virtual;
- public function FindTransition ( const AFrom : string; const ATo : string ) : TGorillaAnimationTransition ; overload virtual;
Properties
- public Model : TGorillaModelread GetModel
- public Controller : TGorillaAnimationController
- public Animations : TGorillaAnimationRefListread FAnimations
- published DisplayName : string
- published Transitions : TGorillaAnimationTransitionCollection
A collection of transition settings working on an linked TGorillaModel. If no model was linked, transitions will not be triggered.
read FTransitions
write SetTransitions
TGorillaAnimationTransitionLayerCollection
The animation transition layer collection holds all available layers.
Ancestors
Members
Methods
- protected function GetController ( ) : TGorillaAnimationController ;
- public function ToJSON ( ) : TJSONArray ; virtual;
- public procedure FromJSON ( AJSON : TJSONArray ) ; virtual;
- public function FindLayer ( const AName : string ) : TGorillaAnimationTransitionLayer ;
- public procedure DispatchInput
(
ADispatcher :
TGorillaAnimationDispatcher
)
;
overload virtual;
Dispatch dispatcher-information. This is used on recalling dispatching on animation switches.
- public procedure DispatchInput
(
AHotKey :
TGorillaCharacterControllerHotKey; AStates :
TGorillaCharacterControllerStates
)
;
overload virtual;
Dispatch input event data to all transitions to check if one getting triggered.
- public procedure DispatchInput
(
AVariable :
string; AValue :
string
)
;
overload virtual;
Dispatch input variable data to all transitions to check if one getting triggered.
- public procedure DispatchInput
(
AVariable :
string; AValue :
TValue
)
;
overload virtual;
Dispatch input variable data to all transitions to check if one getting triggered.
Properties
TGorillaAnimationController
The animation controller is able to automatically switch character animations depending on configured transitions. A Transition defines when and how to switch from one animation to another. For example this can be used on character movement.
Ancestors
Members
Fields
- protected FDefaultAnimation :
string
- protected FDefaultAnimationLink :
TGorillaAnimation
- protected FModel :
TGorillaModel
- protected FIsStandaloneModel :
Boolean
- protected FLayers :
TGorillaAnimationTransitionLayerCollection
- protected FLastDispatch :
TGorillaAnimationDispatcher
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure SetLayers ( const AValue : TGorillaAnimationTransitionLayerCollection ) ; virtual;
- protected procedure SetDefaultAnimation ( const AValue : string ) ; virtual;
- protected function GetDefaultAnimationLink ( ) : TGorillaAnimation ; virtual;
- protected procedure SetModel ( const AValue : TGorillaModel ) ;
- protected procedure Notification ( AComponent : TComponent; Operation : TOperation ) ; override;
- public procedure AfterConstruction ( ) ; override;
- public procedure Clear ( ) ;
- public function ToJSON ( ) : TJSONObject ; virtual;
- public procedure FromJSON ( AJSON : TJSONObject; const APackage : TGorillaAssetsPackage = nil ) ; virtual;
- public procedure SaveToFile ( const AFilename : string ) ;
- public procedure SaveToStream ( AStream : TStream ) ;
- public procedure LoadFromFile ( const AFilename : string; const APackage : TGorillaAssetsPackage = nil ) ;
- public procedure LoadFromStream ( AStream : TStream; const APackage : TGorillaAssetsPackage = nil ) ;
- public function GetAnimationManager
(
)
: TGorillaAnimationManager
;
virtual;
Tries to to get the linked animation manager. An animation manager can only be retrieved if a model was linked to the TGorillaAnimationController.
- public function GetCurrentAnimation
(
)
: TGorillaAnimation
;
virtual;
Tries to to get the linked animation manager. An animation manager can only be retrieved if a model was linked to the TGorillaAnimationController. If an animation manager was returned, the method checks for the current animation.
- public procedure DispatchInput
(
ADispatcher :
TGorillaAnimationDispatcher
)
;
overload virtual;
Dispatch dispatcher-information. This is used on recalling dispatching on animation switches.
- public procedure DispatchInput
(
AHotKey :
TGorillaCharacterControllerHotKey; AStates :
TGorillaCharacterControllerStates
)
;
overload virtual;
Dispatch input event data to all transitions to check if one getting triggered.
- public procedure DispatchInput
(
AVariable :
string; AValue :
string
)
;
overload virtual;
Dispatch input variable data to all transitions to check if one getting triggered.
- public procedure DispatchInput
(
AVariable :
string; AValue :
TValue
)
;
overload virtual;
Dispatch input variable data to all transitions to check if one getting triggered.
- public function AddLayer
(
const
AName :
string
)
: TGorillaAnimationTransitionLayer
;
virtual;
Adds a new layer to the animation controller to add transitions.
- public procedure RemoveLayer
(
const
AName :
string
)
;
virtual;
Removes an existing layer.
- public function FindLayer
(
const
AName :
string
)
: TGorillaAnimationTransitionLayer
;
virtual;
Tries to find a specific layer by its name
- public function LayerExists
(
const
AName :
string
)
: Boolean
;
virtual;
Returns if a layer with a specific name exists or not.
- public function AddTransition
(
const
ALayer :
string; const
AName :
string; const
AFrom :
string; const
ATo :
string; ADoLoop :
Boolean; AHotKey :
TGorillaCharacterControllerHotKey; AStates :
TGorillaCharacterControllerStates; AMode :
TGorillaAnimationTransitionMode
)
: TGorillaAnimationTransition
;
overload virtual;
Helper method to add a new transition instance easily.
- public function AddTransition
(
const
ALayer :
string; const
AName :
string; const
AFrom :
string; const
ATo :
string; ADoLoop :
Boolean; AVariable :
string; AValue :
TValue; AMode :
TGorillaAnimationTransitionMode
)
: TGorillaAnimationTransition
;
overload virtual;
Helper method to add a new transition instance easily.
- public function FindTransition ( const ALayer : string; const AName : string ) : TGorillaAnimationTransition ; overload virtual;
- public function FindTransition ( const ALayer : string; const AFrom : string; const ATo : string ) : TGorillaAnimationTransition ; overload virtual;
- public procedure DeleteTransition ( const ALayer : string; const AName : string ) ; overload virtual;
- public procedure DeleteTransition ( const ALayer : string; const AFrom : string; const ATo : string ) ; overload virtual;
Properties
- published DefaultAnimation : string
Setup the default animation to initialize the TGorillaAnimationController. If no default animation is set, the controller can not find triggered transitions.
read FDefaultAnimation
write SetDefaultAnimation - published Model : TGorillaModel
- published Layers : TGorillaAnimationTransitionLayerCollection