Class SkinnedModel
Skinned model asset that contains model object made of meshes that can be rendered on the GPU using skeleton bones skinning.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Content/Assets/SkinnedModel.h
Syntax
public class SkinnedModel : public ModelBase
Constructors
~SkinnedModel()
Fields
LODs
Model level of details. The first entry is the highest quality LOD0 followed by more optimized versions.
Declaration
public Array<SkinnedModelLOD, FixedAllocation<MODEL_MAX_LODS>> LODs
Field Value
Array<SkinnedModelLOD, FixedAllocation<MODEL_MAX_LODS>>
|
Skeleton
Methods
Draw(const RenderContext& renderContext, const SkinnedMesh::DrawInfo& info)
Draws the model.
Declaration
public void Draw(const RenderContext& renderContext, const SkinnedMesh::DrawInfo& info)
Parameters
RenderContext
renderContext
The rendering context. |
SkinnedMesh::DrawInfo
info
The packed drawing info data. |
Draw(const RenderContextBatch& renderContextBatch, const SkinnedMesh::DrawInfo& info)
Draws the model.
Declaration
public void Draw(const RenderContextBatch& renderContextBatch, const SkinnedMesh::DrawInfo& info)
Parameters
RenderContextBatch
renderContextBatch
The rendering context batch. |
SkinnedMesh::DrawInfo
info
The packed drawing info data. |
FindBone(const StringView& name)
Finds the bone with the given name.
Declaration
public int32 FindBone(const StringView& name) const
Parameters
StringView
name
The name of the node used by the bone. |
Returns
int32
The index of the bone or -1 if not found. |
FindBone(int32 nodeIndex)
Finds the bone that is using a given node index.
Declaration
public int32 FindBone(int32 nodeIndex) const
Parameters
int32
nodeIndex
The index of the node. |
Returns
int32
The index of the bone or -1 if not found. |
FindNode(const StringView& name)
Finds the node with the given name.
Declaration
public int32 FindNode(const StringView& name) const
Parameters
StringView
name
The name of the node. |
Returns
int32
The index of the node or -1 if not found. |
GetAllocatedResidency()
Gets resource allocated residency level.
Declaration
public virtual int32 GetAllocatedResidency() const override
Returns
int32
|
Overrides
GetBlendShapes()
Gets the blend shapes names used by the skinned model meshes (from LOD 0 only).
Declaration
public Array<String> GetBlendShapes()
Returns
Array<String>
|
GetBones()
Gets the skeleton bones hierarchy.
Declaration
public Array<SkeletonBone> GetBones() const
Returns
Array<SkeletonBone>
|
GetBox(const Matrix& world, int32 lodIndex = 0)
Gets the model bounding box in custom matrix world space (rig pose transformed by matrix, not animated).
Declaration
public BoundingBox GetBox(const Matrix& world, int32 lodIndex = 0) const
Parameters
Matrix
world
The transformation matrix. |
int32
lodIndex
The Level Of Detail index. |
Returns
BoundingBox
The bounding box. |
GetBox(int32 lodIndex = 0)
Gets the model bounding box in local space (rig pose, not animated).
Declaration
public BoundingBox GetBox(int32 lodIndex = 0) const
Parameters
int32
lodIndex
The Level Of Detail index. |
Returns
BoundingBox
The bounding box. |
getChunksToPreload()
Gets packed chunks indices to preload before asset loading action
Declaration
protected virtual AssetChunksFlag getChunksToPreload() const override
Returns
AssetChunksFlag
Chunks to load flags |
Overrides
GetLOD(int32 lodIndex)
Gets the mesh for a particular LOD index.
Declaration
public virtual ModelLODBase* GetLOD(int32 lodIndex) const override
Parameters
int32
lodIndex
|
Returns
ModelLODBase
|
Overrides
GetLODsCount()
Gets amount of the level of details in the model.
Declaration
public virtual int32 GetLODsCount() const override
Returns
int32
|
Overrides
GetMaxResidency()
Gets resource maximum residency level.
Declaration
public virtual int32 GetMaxResidency() const override
Returns
int32
|
Overrides
GetMemoryUsage()
Gets amount of CPU memory used by this resource (in bytes). It's a rough estimation. Memory may be fragmented, compressed or sub-allocated so the actual memory pressure from this resource may vary.
Declaration
public virtual uint64 GetMemoryUsage() const override
Returns
uint64
|
Overrides
GetMesh(int32 meshIndex, int32 lodIndex = 0)
Gets the mesh for a particular LOD index.
Declaration
public virtual MeshBase* GetMesh(int32 meshIndex, int32 lodIndex = 0) const override
Parameters
int32
meshIndex
|
int32
lodIndex
|
Returns
MeshBase
|
Overrides
GetMeshes(Array<const MeshBase* >& meshes, int32 lodIndex = 0)
Gets the meshes for a particular LOD index.
Declaration
public virtual void GetMeshes(Array<const MeshBase* >& meshes, int32 lodIndex = 0) const override
Parameters
Array<MeshBase >
meshes
|
int32
lodIndex
|
Overrides
GetMeshes(Array<MeshBase* >& meshes, int32 lodIndex = 0)
Gets the meshes for a particular LOD index.
Declaration
public virtual void GetMeshes(Array<MeshBase* >& meshes, int32 lodIndex = 0) override
Parameters
Array<MeshBase >
meshes
|
int32
lodIndex
|
Overrides
GetNodes()
Gets the skeleton nodes hierarchy.
Declaration
public Array<SkeletonNode> GetNodes() const
Returns
Array<SkeletonNode>
|
GetSkeletonMapping(Asset* source, bool autoRetarget=true)
Gets the skeleton mapping for a given asset (animation or other skinned model). Uses identity mapping or manually created retargeting setup.
Declaration
public SkeletonMapping GetSkeletonMapping(Asset* source, bool autoRetarget=true)
Parameters
Asset
source
The source asset (animation or other skinned model) to get mapping to its skeleton. |
bool
autoRetarget
Enables automatic skeleton retargeting based on nodes names. Can be disabled to query existing skeleton mapping or return null if not defined. |
Returns
SkeletonMapping
The skeleton mapping for the source asset into this skeleton. |
GetSkeletonRetargets()
Declaration
public Array<SkeletonRetarget> GetSkeletonRetargets() const
Returns
Array<SkeletonRetarget>
|
HasAnyLODInitialized()
Determines whether any LOD has been initialized.
Declaration
public bool HasAnyLODInitialized() const
Returns
bool
|
InitAsVirtual()
Initializes asset data as virtual asset.
Declaration
public virtual void InitAsVirtual() override
Overrides
Intersects(const Ray& ray, const Matrix& world, Real& distance, Vector3& normal, SkinnedMesh* *mesh, int32 lodIndex = 0)
Determines if there is an intersection between the SkinnedModel and a Ray in given world using given instance.
Declaration
public bool Intersects(const Ray& ray, const Matrix& world, Real& distance, Vector3& normal, SkinnedMesh* *mesh, int32 lodIndex = 0)
Parameters
Ray
ray
The ray to test |
Matrix
world
World to test |
Real
distance
When the method completes, contains the distance of the intersection (if any valid). |
Vector3
normal
When the method completes, contains the intersection surface normal vector (if any valid). |
SkinnedMesh
mesh
Mesh, or null |
int32
lodIndex
Level Of Detail index |
Returns
bool
True whether the two objects intersected |
Intersects(const Ray& ray, const Transform& transform, Real& distance, Vector3& normal, SkinnedMesh* *mesh, int32 lodIndex = 0)
Determines if there is an intersection between the SkinnedModel and a Ray in given world using given instance.
Declaration
public bool Intersects(const Ray& ray, const Transform& transform, Real& distance, Vector3& normal, SkinnedMesh* *mesh, int32 lodIndex = 0)
Parameters
Ray
ray
The ray to test |
Transform
transform
Instance transformation |
Real
distance
When the method completes, contains the distance of the intersection (if any valid). |
Vector3
normal
When the method completes, contains the intersection surface normal vector (if any valid). |
SkinnedMesh
mesh
Mesh, or null |
int32
lodIndex
Level Of Detail index |
Returns
bool
True whether the two objects intersected |
load()
Load data from the chunks
Declaration
protected virtual LoadResult load() override
Returns
LoadResult
Loading result |
Overrides
Render(GPUContext* context, int32 lodIndex = 0)
Draws the meshes. Binds vertex and index buffers and invokes the draw calls.
Declaration
public void Render(GPUContext* context, int32 lodIndex = 0)
Parameters
GPUContext
context
The GPU context to draw with. |
int32
lodIndex
The Level Of Detail index. |
SetSkeletonRetargets(const Array<SkeletonRetarget>& value)
Declaration
public void SetSkeletonRetargets(const Array<SkeletonRetarget>& value)
Parameters
Array<SkeletonRetarget>
value
|
SetupLODs(const Span<int32>& meshesCountPerLod)
Setups the model LODs collection including meshes creation.
Declaration
public bool SetupLODs(const Span<int32>& meshesCountPerLod)
Parameters
Span<int32>
meshesCountPerLod
The meshes count per lod array (amount of meshes per LOD). |
Returns
bool
True if failed, otherwise false. |
SetupMaterialSlots(int32 slotsCount)
Resizes the material slots collection. Updates meshes that were using removed slots.
Declaration
public virtual void SetupMaterialSlots(int32 slotsCount) override
Parameters
int32
slotsCount
|
Overrides
SetupSkeleton(const Array<SkeletonNode>& nodes)
Setups the skinned model skeleton. Uses the same nodes layout for skeleton bones and calculates the offset matrix by auto.
Declaration
public bool SetupSkeleton(const Array<SkeletonNode>& nodes)
Parameters
Array<SkeletonNode>
nodes
The nodes hierarchy. The first node must be a root one (with parent index equal -1). |
Returns
bool
True if failed, otherwise false. |
SetupSkeleton(const Array<SkeletonNode>& nodes, const Array<SkeletonBone>& bones, bool autoCalculateOffsetMatrix)
Setups the skinned model skeleton.
Declaration
public bool SetupSkeleton(const Array<SkeletonNode>& nodes, const Array<SkeletonBone>& bones, bool autoCalculateOffsetMatrix)
Parameters
Array<SkeletonNode>
nodes
The nodes hierarchy. The first node must be a root one (with parent index equal -1). |
Array<SkeletonBone>
bones
The bones hierarchy. |
bool
autoCalculateOffsetMatrix
If true then the OffsetMatrix for each bone will be auto-calculated by the engine, otherwise the provided values will be used. |
Returns
bool
True if failed, otherwise false. |
unload(bool isReloading)
Unloads asset data
Declaration
protected virtual void unload(bool isReloading) override
Parameters
bool
isReloading
True if asset is reloading data, otherwise false. |