Class AnimatedModel
Performs an animation and renders a skinned model.
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[ActorContextMenu("New/Other/Animated Model")]
[ActorToolbox("Visuals")]
[Unmanaged]
public class AnimatedModel : ModelInstanceActor, ISerializable
Constructors
AnimatedModel()
Properties
AnimationGraph
The animation graph asset used for the skinned mesh skeleton bones evaluation (controls the animation).
Declaration
[EditorOrder(15)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public AnimationGraph AnimationGraph { get; set; }
Property Value
AnimationGraph
|
BoundsScale
The master scale parameter for the actor bounding box. Helps reducing mesh flickering effect on screen edges.
Declaration
[EditorOrder(60)]
[Limit(0F, 3.40282347E+38F, 1F)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public float BoundsScale { get; set; }
Property Value
System.Single
|
CustomBounds
The custom bounds(in actor local space). If set to empty bounds then source skinned model bind pose bounds will be used.
Declaration
[EditorOrder(70)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public BoundingBox CustomBounds { get; set; }
Property Value
BoundingBox
|
DrawModes
The draw passes to use for rendering this object.
Declaration
[EditorOrder(100)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public DrawPass DrawModes { get; set; }
Property Value
DrawPass
|
ForcedLOD
Gets the model forced Level Of Detail index. Allows to bind the given model LOD to show. Value -1 disables this feature.
Declaration
[EditorOrder(90)]
[Limit(-1F, 100F, 0.1F)]
[EditorDisplay("Skinned Model", "Forced LOD")]
[Unmanaged]
public int ForcedLOD { get; set; }
Property Value
System.Int32
|
LODBias
The model Level Of Detail bias value. Allows to increase or decrease rendered model quality.
Declaration
[EditorOrder(80)]
[Limit(-100F, 100F, 0.1F)]
[EditorDisplay("Skinned Model", "LOD Bias")]
[Unmanaged]
public int LODBias { get; set; }
Property Value
System.Int32
|
Parameters
Gets the anim graph instance parameters collection.
Declaration
[Unmanaged]
public AnimGraphParameter[] Parameters { get; }
Property Value
AnimGraphParameter[]
|
PerBoneMotionBlur
If true, use per-bone motion blur on this skeletal model. It requires additional rendering, can be disabled to save performance.
Declaration
[EditorOrder(20)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public bool PerBoneMotionBlur { get; set; }
Property Value
System.Boolean
|
RootMotionTarget
The animation root motion apply target. If not specified the animated model will apply it itself.
Declaration
[EditorOrder(120)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public Actor RootMotionTarget { get; set; }
Property Value
Actor
|
ShadowsMode
The shadows casting mode. [Deprecated on 26.10.2022, expires on 26.10.2024]
Declaration
[EditorOrder(110)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public ShadowsCastingMode ShadowsMode { get; set; }
Property Value
ShadowsCastingMode
|
ShowDebugDrawSkeleton
If checked, the skeleton pose will be shawn during debug shapes drawing.
Declaration
[EditorOrder(200)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public bool ShowDebugDrawSkeleton { get; set; }
Property Value
System.Boolean
|
SkinnedModel
The skinned model asset used for rendering.
Declaration
[EditorOrder(10)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public SkinnedModel SkinnedModel { get; set; }
Property Value
SkinnedModel
|
SortOrder
The object sort order key used when sorting drawable objects during rendering. Use lower values to draw object before others, higher values are rendered later (on top). Can be used to control transparency drawing.
Declaration
[EditorDisplay("Skinned Model", null)]
[EditorOrder(110)]
[Unmanaged]
public sbyte SortOrder { get; set; }
Property Value
System.SByte
|
UpdateMode
The animation update mode. Can be used to optimize the performance.
Declaration
[EditorOrder(50)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public AnimatedModel.AnimationUpdateMode UpdateMode { get; set; }
Property Value
AnimatedModel.AnimationUpdateMode
|
UpdateSpeed
The animation update delta time scale. Can be used to speed up animation playback or create slow motion effect.
Declaration
[EditorOrder(45)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public float UpdateSpeed { get; set; }
Property Value
System.Single
|
UpdateWhenOffscreen
If true, the animation will be updated even when an actor cannot be seen by any camera. Otherwise, the animations themselves will also stop running when the actor is off-screen.
Declaration
[EditorOrder(40)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public bool UpdateWhenOffscreen { get; set; }
Property Value
System.Boolean
|
UseTimeScale
If true, animation speed will be affected by the global time scale parameter.
Declaration
[EditorOrder(30)]
[EditorDisplay("Skinned Model", null)]
[Unmanaged]
public bool UseTimeScale { get; set; }
Property Value
System.Boolean
|
Methods
ClearBlendShapeWeights()
Clears the weights of the blend shapes (disables any used blend shapes).
Declaration
[Unmanaged]
public void ClearBlendShapeWeights()
FindClosestNode(Vector3, Boolean)
Finds the closest node to a given location.
Declaration
[Unmanaged]
public int FindClosestNode(Vector3 location, bool worldSpace = false)
Parameters
Vector3
location
The text location (in local-space of the actor or world-space depending on |
System.Boolean
worldSpace
True if convert input location is in world-space, otherwise it's in local-space of the actor. |
Returns
System.Int32
The zero-based index of the found node. Returns -1 if skeleton is missing. |
GetBlendShapeWeight(String)
Gets the weight of the blend shape.
Declaration
[Unmanaged]
public float GetBlendShapeWeight(string name)
Parameters
System.String
name
The blend shape name. |
Returns
System.Single
The normalized weight of the blend shape (in range -1:1). |
GetCurrentPose(out Matrix[], Boolean)
Gets the per-node final transformations (skeleton pose).
Declaration
[Unmanaged]
public void GetCurrentPose(out Matrix[] nodesTransformation, bool worldSpace = false)
Parameters
Matrix[]
nodesTransformation
The output per-node final transformation matrices. |
System.Boolean
worldSpace
True if convert matrices into world-space, otherwise returned values will be in local-space of the actor. |
GetNodeTransformation(Int32, out Matrix, Boolean)
Gets the node final transformation.
Declaration
[Unmanaged]
public void GetNodeTransformation(int nodeIndex, out Matrix nodeTransformation, bool worldSpace = false)
Parameters
System.Int32
nodeIndex
The index of the skinned model skeleton node. |
Matrix
nodeTransformation
The output final node transformation matrix. |
System.Boolean
worldSpace
True if convert matrices into world-space, otherwise returned values will be in local-space of the actor. |
GetNodeTransformation(String, out Matrix, Boolean)
Gets the node final transformation.
Declaration
[Unmanaged]
public void GetNodeTransformation(string nodeName, out Matrix nodeTransformation, bool worldSpace = false)
Parameters
System.String
nodeName
The name of the skinned model skeleton node. |
Matrix
nodeTransformation
The output final node transformation matrix. |
System.Boolean
worldSpace
True if convert matrices into world-space, otherwise returned values will be in local-space of the actor. |
GetParameter(String)
Gets the anim graph instance parameter by name.
Declaration
[Unmanaged]
public AnimGraphParameter GetParameter(string name)
Parameters
System.String
name
The parameter name. |
Returns
AnimGraphParameter
The parameters. |
GetParameterValue(Guid)
Gets the anim graph instance parameter value.
Declaration
[Unmanaged]
public object GetParameterValue(Guid id)
Parameters
System.Guid
id
The parameter id. |
Returns
System.Object
The value. |
GetParameterValue(String)
Gets the anim graph instance parameter value.
Declaration
[Unmanaged]
public object GetParameterValue(string name)
Parameters
System.String
name
The parameter name. |
Returns
System.Object
The value. |
IsPlayingSlotAnimation()
Checks if the any animation playback is active on the any slot in Anim Graph (not paused).
Declaration
[Unmanaged]
public bool IsPlayingSlotAnimation()
Returns
System.Boolean
|
IsPlayingSlotAnimation(String, Animation)
Checks if the animation playback is active on the slot in Anim Graph (not paused).
Declaration
[Unmanaged]
public bool IsPlayingSlotAnimation(string slotName, Animation anim)
Parameters
System.String
slotName
The name of the slot. |
Animation
anim
The animation to check. |
Returns
System.Boolean
|
PauseSlotAnimation()
Pauses all the animations playback on the all slots in Anim Graph.
Declaration
[Unmanaged]
public void PauseSlotAnimation()
PauseSlotAnimation(String, Animation)
Pauses the animation playback on the slot in Anim Graph.
Declaration
[Unmanaged]
public void PauseSlotAnimation(string slotName, Animation anim)
Parameters
System.String
slotName
The name of the slot. |
Animation
anim
The animation to pause. |
PlaySlotAnimation(String, Animation, Single, Single, Single, Int32)
Plays the animation on the slot in Anim Graph.
Declaration
[Unmanaged]
public void PlaySlotAnimation(string slotName, Animation anim, float speed = 1F, float blendInTime = 0.2F, float blendOutTime = 0.2F, int loopCount = 0)
Parameters
System.String
slotName
The name of the slot. |
Animation
anim
The animation to play. |
System.Single
speed
The playback speed. |
System.Single
blendInTime
The animation blending in time (in seconds). Cam be used to smooth the slot animation playback with the input pose when starting the animation. |
System.Single
blendOutTime
The animation blending out time (in seconds). Cam be used to smooth the slot animation playback with the input pose when ending animation. |
System.Int32
loopCount
The amount of loops to play the animation: 0 to play once, -1 to play infinite, 1 or higher to loop once or more. |
PreInitSkinningData()
Creates and setups the skinning data (writes the identity bones transformations).
Declaration
[Unmanaged]
public void PreInitSkinningData()
ResetAnimation()
Resets the animation state (clears the instance state data but preserves the instance parameters values).
Declaration
[Unmanaged]
public void ResetAnimation()
SetBlendShapeWeight(String, Single)
Sets the weight of the blend shape.
Declaration
[Unmanaged]
public void SetBlendShapeWeight(string name, float value)
Parameters
System.String
name
The blend shape name. |
System.Single
value
The normalized weight of the blend shape (in range -1:1). |
SetCurrentPose(Matrix[], Boolean)
Sets the per-node final transformations (skeleton pose).
Declaration
[Unmanaged]
public void SetCurrentPose(Matrix[] nodesTransformation, bool worldSpace = false)
Parameters
Matrix[]
nodesTransformation
The per-node final transformation matrices. |
System.Boolean
worldSpace
True if convert matrices from world-space, otherwise values are in local-space of the actor. |
SetMasterPoseModel(AnimatedModel)
Sets the master pose model that will be used to copy the skeleton nodes animation. Useful for modular characters.
Declaration
[Unmanaged]
public void SetMasterPoseModel(AnimatedModel masterPose)
Parameters
AnimatedModel
masterPose
The master pose actor to use. |
SetNodeTransformation(Int32, Matrix, Boolean)
Sets the node final transformation. If multiple nodes are to be set within a frame, do not use set worldSpace to true, and do the conversion yourself to avoid recalculation of inv matrices.
Declaration
[Unmanaged]
public void SetNodeTransformation(int nodeIndex, Matrix nodeTransformation, bool worldSpace = false)
Parameters
System.Int32
nodeIndex
The index of the skinned model skeleton node. |
Matrix
nodeTransformation
The final node transformation matrix. |
System.Boolean
worldSpace
True if convert matrices from world-space, otherwise values will be in local-space of the actor. |
SetNodeTransformation(String, Matrix, Boolean)
Sets the node final transformation. If multiple nodes are to be set within a frame, do not use set worldSpace to true, and do the conversion yourself to avoid recalculation of inv matrices.
Declaration
[Unmanaged]
public void SetNodeTransformation(string nodeName, Matrix nodeTransformation, bool worldSpace = false)
Parameters
System.String
nodeName
The name of the skinned model skeleton node. |
Matrix
nodeTransformation
The final node transformation matrix. |
System.Boolean
worldSpace
True if convert matrices from world-space, otherwise values will be in local-space of the actor. |
SetParameterValue(Guid, Object)
Sets the anim graph instance parameter value.
Declaration
[Unmanaged]
public void SetParameterValue(Guid id, object value)
Parameters
System.Guid
id
The parameter id. |
System.Object
value
The value to set. |
SetParameterValue(String, Object)
Sets the anim graph instance parameter value.
Declaration
[Unmanaged]
public void SetParameterValue(string name, object value)
Parameters
System.String
name
The parameter name. |
System.Object
value
The value to set. |
SetupSkinningData()
Validates and creates a proper skinning data.
Declaration
[Unmanaged]
public void SetupSkinningData()
StopSlotAnimation()
Stops all the animations playback on the all slots in Anim Graph.
Declaration
[Unmanaged]
public void StopSlotAnimation()
StopSlotAnimation(String, Animation)
Stops the animation playback on the slot in Anim Graph.
Declaration
[Unmanaged]
public void StopSlotAnimation(string slotName, Animation anim)
Parameters
System.String
slotName
The name of the slot. |
Animation
anim
The animation to stop. |
UpdateAnimation()
Performs the full animation update. The actual update will be performed during gameplay tick.
Declaration
[Unmanaged]
public void UpdateAnimation()
Events
AnimationUpdated
Called after animation gets updated (new skeleton pose).
Declaration
[Unmanaged]
public event Action AnimationUpdated
Event Type
System.Action
|