Class Animation3D
Behavior to 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 the 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 was 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 current 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 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.
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. |
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)
Add 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 animation name. |
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 all is OK. |
Overrides
OnDestroy()
Invoked when the object is going 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 | Looping animation. |
| 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 play. |
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)
Remove an existing animation layer, to be played with the other layers.
Declaration
public void RemoveAnimationLayer(AnimationBlendClip clip)
Parameters
| Type | Name | Description |
|---|---|---|
| AnimationBlendClip | clip | The clip to be played. |
ResumeAnimation()
Resume 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 fired when the animation is updated
Declaration
public event EventHandler<AnimationSample> AnimationUpdated
Event Type
| Type | Description |
|---|---|
| EventHandler<AnimationSample> |
OnKeyFrameEvent
Raised when a certain frame of an animation is played.
Declaration
public event EventHandler<AnimationKeyframeEvent> OnKeyFrameEvent
Event Type
| Type | Description |
|---|---|
| EventHandler<AnimationKeyframeEvent> |