Class Animation3D
Behavior that controls the animations of a 3D model.
Inheritance
Implements
Inherited Members
Namespace: Evergine.Components.Animation
Assembly: Evergine.Framework.dll
Syntax
public class Animation3D : Behavior, IDependencyObject
Remarks
Ideally, this class should be used to hold all the animations related to a given 3D model.
Constructors
Animation3D()
Initializes a new instance of the Animation3D class.
Declaration
public Animation3D()
Animation3D(Model)
Initializes a new instance of the Animation3D class.
Declaration
public Animation3D(Model model)
Parameters
| Type | Name | Description |
|---|---|---|
| Model | model | The path to the animation data. |
Fields
modelLink
Dependency System Reference Model.
Declaration
protected LoadableDependencyLink<Model> modelLink
Field Value
| Type | Description |
|---|---|
| LoadableDependencyLink<Model> |
transform3D
The Transform3D.
Declaration
[BindComponent(true, true, BindComponentSource.Owner, null, true)]
protected Transform3D transform3D
Field Value
| Type | Description |
|---|---|
| Transform3D |
Properties
AnimationLayers
Gets the registered animation layers.
Declaration
public IEnumerable<AnimationBlendClip> AnimationLayers { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<AnimationBlendClip> |
AnimationNames
Gets the animation names.
Declaration
public IEnumerable<string> AnimationNames { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<string> | The animation names. |
AnimationState
Gets or sets the state of the current active animation. When using AddAnimationLayer(AnimationBlendClip), it affects the State property of the first animation clip.
Declaration
public AnimationState AnimationState { get; set; }
Property Value
| Type | Description |
|---|---|
| AnimationState |
ApplyRootMotion
Gets or sets a value indicating whether root motion will be applied to this entity.
Declaration
public bool ApplyRootMotion { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
BoundingBoxRefreshed
Gets or sets a value indicating whether the bounding box has been refreshed.
Declaration
public bool BoundingBoxRefreshed { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Clip
Gets the current animation clip. When using AddAnimationLayer(AnimationBlendClip), it returns the first animation clip.
Declaration
public AnimationBlendClip Clip { get; }
Property Value
| Type | Description |
|---|---|
| AnimationBlendClip |
CurrentAnimation
Gets or sets the currently active animation.
Declaration
public string CurrentAnimation { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The current animation. |
CurrentAnimationTrack
Gets the current animation track.
Declaration
public AnimationClip CurrentAnimationTrack { get; }
Property Value
| Type | Description |
|---|---|
| AnimationClip |
Duration
Gets the duration time. When using AddAnimationLayer(AnimationBlendClip), it returns the Duration property of the first animation clip.
Declaration
public float Duration { get; }
Property Value
| Type | Description |
|---|---|
| float |
EndAnimationTime
Gets the end animation time. When using AddAnimationLayer(AnimationBlendClip), it returns the EndAnimationTime property of the first animation clip.
Declaration
public float EndAnimationTime { get; }
Property Value
| Type | Description |
|---|---|
| float |
Frame
Gets or sets the current frame of the animation.
Declaration
public float Frame { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Loop
Gets or sets a value indicating whether the current active animation is looping. When using AddAnimationLayer(AnimationBlendClip) it affects the Loop property of the first animation clip.
Declaration
public bool Loop { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Model
Gets or sets the animation file path.
Declaration
public Model Model { get; set; }
Property Value
| Type | Description |
|---|---|
| Model |
PlayAutomatically
Gets or sets a value indicating whether the animation is played automatically when the CurrentAnimation is set.
Declaration
public bool PlayAutomatically { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
PlayTime
Gets or sets the current animation time. When using AddAnimationLayer(AnimationBlendClip), it affects the PlaybackRate property of the first animation clip.
Declaration
public float PlayTime { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
PlaybackRate
Gets or sets the playback rate. When using AddAnimationLayer(AnimationBlendClip), it affects the PlaybackRate property of the first animation clip.
Declaration
public float PlaybackRate { get; set; }
Property Value
| Type | Description |
|---|---|
| float | The speed of the animation. |
SmoothTransitions
Gets or sets a value indicating whether the animation transitions are smooth.
Declaration
public bool SmoothTransitions { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
StartAnimationTime
Gets the start animation time. When using AddAnimationLayer(AnimationBlendClip) it returns the StartAnimationTime property of the first animation clip.
Declaration
public float StartAnimationTime { get; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
AddAnimationLayer(AnimationBlendClip)
Adds a new animation layer to be played with the other layers.
Declaration
public void AddAnimationLayer(AnimationBlendClip clip)
Parameters
| Type | Name | Description |
|---|---|---|
| AnimationBlendClip | clip | The clip to be played. |
GetDuration(string)
Gets the duration of an animation.
Declaration
public double GetDuration(string animation)
Parameters
| Type | Name | Description |
|---|---|---|
| string | animation | The name of the animation. |
Returns
| Type | Description |
|---|---|
| double | The duration of the animation. |
OnAttached()
Invoked when the object is attached to the system.
Declaration
protected override bool OnAttached()
Returns
| Type | Description |
|---|---|
| bool | True if everything is OK. |
Overrides
OnDestroy()
Invoked when the object is about to be disposed.
Declaration
protected override void OnDestroy()
Overrides
PlayAnimation(AnimationBlendClip, float)
Plays the animation between the specified frames.
Declaration
public void PlayAnimation(AnimationBlendClip clip, float transitionTime = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| AnimationBlendClip | clip | The animation clip. |
| float | transitionTime | The transition time. |
PlayAnimation(string, bool, float, float, float?, float?)
Plays the animation between the specified frames.
Declaration
public void PlayAnimation(string name, bool loop = true, float transitionTime = 0, float playbackRate = 1, float? startTime = null, float? endTime = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the animation. |
| bool | loop | Whether the animation loops. |
| float | transitionTime | The transition time. |
| float | playbackRate | The playback rate. |
| float? | startTime | The frame where the animation starts playing. |
| float? | endTime | The last frame of the animation to be played. |
PlayAnimation(string, int?, int?, bool, float)
Plays the animation between the specified frames.
Declaration
public void PlayAnimation(string name, int? startTime, int? endTime, bool loop = true, float playbackRate = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the animation. |
| int? | startTime | The frame where the animation starts playing. |
| int? | endTime | The last frame of the animation to play. |
| bool | loop | If set to |
| float | playbackRate | The playback rate. |
RemoveAnimationLayer(AnimationBlendClip)
Removes an existing animation layer from being played with the other layers.
Declaration
public void RemoveAnimationLayer(AnimationBlendClip clip)
Parameters
| Type | Name | Description |
|---|---|---|
| AnimationBlendClip | clip | The clip to be played. |
ResumeAnimation()
Resumes the animation.
Declaration
public void ResumeAnimation()
StopAnimation()
Stops the animation.
Declaration
public void StopAnimation()
Update(TimeSpan)
Updates the animation.
Declaration
protected override void Update(TimeSpan gameTime)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | gameTime | The game time. |
Overrides
Events
AnimationUpdated
An event that fires when the animation is updated
Declaration
public event EventHandler<AnimationSample> AnimationUpdated
Event Type
| Type | Description |
|---|---|
| EventHandler<AnimationSample> |
OnKeyFrameEvent
Raised when a specific frame of an animation is played.
Declaration
public event EventHandler<AnimationKeyframeEvent> OnKeyFrameEvent
Event Type
| Type | Description |
|---|---|
| EventHandler<AnimationKeyframeEvent> |