Open 3D Engine EMotionFX Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
EMotionFX::SubMesh Class Reference

#include <SubMesh.h>

Inherits EMotionFX::BaseObject.

Public Member Functions

uint32 GetStartIndex () const
 
uint32 GetStartVertex () const
 
uint32 GetStartPolygon () const
 
uint32 * GetIndices () const
 
uint8 * GetPolygonVertexCounts () const
 
uint32 GetNumVertices () const
 
uint32 GetNumIndices () const
 
uint32 GetNumPolygons () const
 
MeshGetParentMesh () const
 
void SetParentMesh (Mesh *mesh)
 
void SetStartIndex (uint32 indexOffset)
 
void SetStartPolygon (uint32 polygonNumber)
 
void SetStartVertex (uint32 vertexOffset)
 
void SetNumIndices (uint32 numIndices)
 
void SetNumVertices (uint32 numVertices)
 
void SetNumBones (size_t numBones)
 
void SetBone (size_t index, size_t nodeIndex)
 
MCORE_INLINE size_t GetNumBones () const
 
MCORE_INLINE size_t GetBone (size_t index) const
 
MCORE_INLINE size_t * GetBones ()
 
MCORE_INLINE const AZStd::vector< size_t > & GetBonesArray () const
 
MCORE_INLINE AZStd::vector< size_t > & GetBonesArray ()
 
void ReinitBonesArray (SkinningInfoVertexAttributeLayer *skinLayer)
 
size_t FindBoneIndex (size_t nodeNr) const
 
void RemapBone (size_t oldNodeNr, size_t newNodeNr)
 
void RemoveBone (size_t index)
 
SubMeshClone (Mesh *newParentMesh)
 
uint32 CalcNumTriangles () const
 
- Public Member Functions inherited from EMotionFX::BaseObject
 BaseObject ()
 
virtual ~BaseObject ()
 
- Public Member Functions inherited from MCore::MemoryObject
 MemoryObject ()
 
virtual ~MemoryObject ()
 
void IncreaseReferenceCount ()
 
void DecreaseReferenceCount ()
 
void Destroy ()
 
uint32 GetReferenceCount () const
 

Static Public Member Functions

static SubMeshCreate (Mesh *parentMesh, uint32 startVertex, uint32 startIndex, uint32 startPolygon, uint32 numVerts, uint32 numIndices, uint32 numPolygons, size_t numBones)
 

Protected Member Functions

 SubMesh (Mesh *parentMesh, uint32 startVertex, uint32 startIndex, uint32 startPolygon, uint32 numVerts, uint32 numIndices, uint32 numPolygons, size_t numBones)
 
 ~SubMesh ()
 
- Protected Member Functions inherited from EMotionFX::BaseObject
void Delete () override
 
virtual void Delete ()
 

Protected Attributes

AZStd::vector< size_t > m_bones
 
uint32 m_startVertex
 
uint32 m_startIndex
 
uint32 m_startPolygon
 
uint32 m_numVertices
 
uint32 m_numIndices
 
uint32 m_numPolygons
 
Meshm_parentMesh
 

Detailed Description

The submesh class. A submesh is a part of a mesh, with vertex and polygon data having the same material properties. This allows us to easily render these submeshes on the graphics hardware on an efficient way. You can see the SubMesh class as a draw primitive. It specifies a range inside the Mesh class's vertex data and combines this with a material and a possible list of bones. The submesh itself do not store any vertex data. All vertex and polygon (indices) are stored in the Mesh class. You can access this parent mesh by the GetParentMesh() method. All vertex and index data of all submeshes are stored in big arrays which contain all data for all submeshes. This prevents small memory allocations and allows very efficient mesh updates. The submeshes contain information about what place in the arrays the data for this submesh is stored. So where the vertex data begins, and how many vertices are following after that. As well as where the index values start in the big array, and how many indices will follow for this submesh. Also there are some methods which gives you easy access to the vertex and index data stored inside the parent mesh, so that you do not have to deal with the offsets returned by GetStartIndex() and GetStartVertex().

Constructor & Destructor Documentation

◆ SubMesh()

EMotionFX::SubMesh::SubMesh ( Mesh parentMesh,
uint32  startVertex,
uint32  startIndex,
uint32  startPolygon,
uint32  numVerts,
uint32  numIndices,
uint32  numPolygons,
size_t  numBones 
)
protected

Constructor.

Parameters
parentMeshA pointer to the Mesh to which this submesh belongs to.
startVertexThe start vertex.
startIndexThe start index.
startPolygonThe start polygon number.
numVertsNumber of vertices which submesh holds.
numIndicesNumber of indices which submesh holds.
numPolygonsThe number of polygons inside this submesh.
numBonesThe number of bones inside the submesh.

◆ ~SubMesh()

EMotionFX::SubMesh::~SubMesh ( )
protected

Destructor.

Member Function Documentation

◆ CalcNumTriangles()

uint32 EMotionFX::SubMesh::CalcNumTriangles ( ) const

Calculate how many triangles this submesh has. In case the mesh contains polygons of more than 3 vertices, triangulation will be taken into account.

Returns
The number of triangles that are needed to draw this submesh.

◆ Clone()

SubMesh * EMotionFX::SubMesh::Clone ( Mesh newParentMesh)

Clone the submesh. Please note that this method does not actually add the clone to the new (specified) parent mesh.

Parameters
newParentMeshA pointer to the mesh that will get the cloned submesh added to it.
Returns
A pointer to a submesh that is an exact clone of this submesh.

◆ Create()

static SubMesh * EMotionFX::SubMesh::Create ( Mesh parentMesh,
uint32  startVertex,
uint32  startIndex,
uint32  startPolygon,
uint32  numVerts,
uint32  numIndices,
uint32  numPolygons,
size_t  numBones 
)
static

Creation method.

Parameters
parentMeshA pointer to the Mesh to which this submesh belongs to.
startVertexThe start vertex.
startIndexThe start index.
startPolygonThe start polygon number.
numVertsNumber of vertices which submesh holds.
numIndicesNumber of indices which submesh holds.
numPolygonsThe number of polygons inside this submesh.
numBonesThe number of bones inside the submesh.

◆ FindBoneIndex()

size_t EMotionFX::SubMesh::FindBoneIndex ( size_t  nodeNr) const

Find the bone number, which would be in range of [0..GetNumBones()-1] for a given node number. So you can use this to map a global node number into a local index inside the array of bones of this submesh. This is useful when giving each vertex a list of offsets into the bone matrix array inside your shader.

Parameters
nodeNrThe global node number that is a bone. This must be in range with the number of nodes in the actor.
Returns
The bone number inside the submesh, which is in range of [0..GetNumBones()-1]. A value of MCORE_INVALIDINDEX32 is returned when the specified node isn't used as bone inside this submesh.

◆ GetBone()

MCORE_INLINE size_t EMotionFX::SubMesh::GetBone ( size_t  index) const
inline

Get the node index for a given bone.

Parameters
indexThe bone number, which must be in range of [0..GetNumBones()-1].
Returns
The node index value for the given bone.

◆ GetBones()

MCORE_INLINE size_t * EMotionFX::SubMesh::GetBones ( )
inline

Get direct access to the bone values, by getting a pointer to the first bone index. Each integer in the array represents the node number that acts as bone on this submesh.

Returns
A pointer to the array of bones used by this submesh.

◆ GetBonesArray() [1/2]

MCORE_INLINE AZStd::vector< size_t > & EMotionFX::SubMesh::GetBonesArray ( )
inline

Get direct access to the bones array. Each integer in the array represents the node number that acts as bone on this submesh.

Returns
A reference to the array of bones used by this submesh.

◆ GetBonesArray() [2/2]

MCORE_INLINE const AZStd::vector< size_t > & EMotionFX::SubMesh::GetBonesArray ( ) const
inline

Get direct access to the bones array. Each integer in the array represents the node number that acts as bone on this submesh.

Returns
A read only reference to the array of bones used by this submesh.

◆ GetIndices()

uint32 * EMotionFX::SubMesh::GetIndices ( ) const

Get a pointer to the index data for this submesh. The number of indices to follow equals the value returned by GetNumIndices(). The index values are stored on an absolute way, so they point directly into the vertex data arrays of the Mesh where this submesh belongs to.

Returns
The pointer to the index data for this submesh.

◆ GetNumBones()

MCORE_INLINE size_t EMotionFX::SubMesh::GetNumBones ( ) const
inline

Get the number of bones used by this submesh.

Returns
The number of bones used by this submesh.

◆ GetNumIndices()

uint32 EMotionFX::SubMesh::GetNumIndices ( ) const

Return the number of indices.

Returns
The number of indices contained in the submesh.

◆ GetNumPolygons()

uint32 EMotionFX::SubMesh::GetNumPolygons ( ) const

Return the number of polygons.

Returns
The number of polygons contained in the submesh.

◆ GetNumVertices()

uint32 EMotionFX::SubMesh::GetNumVertices ( ) const

Return the number of vertices.

Returns
The number of vertices contained in the submesh.

◆ GetParentMesh()

Mesh * EMotionFX::SubMesh::GetParentMesh ( ) const

Return parent mesh.

Returns
A pointer to the parent mesh to which this submesh belongs to.

◆ GetPolygonVertexCounts()

uint8 * EMotionFX::SubMesh::GetPolygonVertexCounts ( ) const

Get the pointer to the polygon vertex counts. The number of integers inside this buffer equals GetNumPolygons().

Returns
A pointer to the polygon vertex counts for each polygon inside this submesh.

◆ GetStartIndex()

uint32 EMotionFX::SubMesh::GetStartIndex ( ) const

Get the start index. This is the offset in the index array of the parent mesh where the index data for this submesh starts. So it is not the start vertex or whatsoever. The index array of the parent mesh contains the index data of all its submeshes. So it is one big array, with all index data of the submeshes sticked after eachother. The value returned by this method just contains the offset in the array where the index data for this submesh starts. The number of index values to follow equals the value returned by GetNumIndices(). You can also request a pointer to the first index value of this submesh by using the method GetIndices(). Please keep in mind that the index values stored are absolute and not relative. This means that index values for every submesh point directly into the array of vertex data from the Mesh where this submesh is a part of.

Returns
The offset in the array of indices of the parent mesh, where the index data for this submesh starts.

◆ GetStartPolygon()

uint32 EMotionFX::SubMesh::GetStartPolygon ( ) const

Get the start polygon. This represents the polygon index inside the parent mesh where the polygon vertex count data starts for this submesh.

Returns
The start polygon index inside the parent mesh.

◆ GetStartVertex()

uint32 EMotionFX::SubMesh::GetStartVertex ( ) const

Get the start vertex offset. This offset points into the vertex data arrays (positions, normals, uvs) of the parent mesh. The number of vertices to follow equals the amount returned by GetNumVertices().

Returns
The offset in the vertex data arrays in the parent mesh, where the vertex data for this submesh starts.

◆ ReinitBonesArray()

void EMotionFX::SubMesh::ReinitBonesArray ( SkinningInfoVertexAttributeLayer skinLayer)

Reinitialize the bones. Iterate over the influences from the given skin and make sure all bones used in there are inside the local bones array.

Parameters
[in]skinLayerPointer to the skinning attribute layer used to deform the mesh.

◆ RemapBone()

void EMotionFX::SubMesh::RemapBone ( size_t  oldNodeNr,
size_t  newNodeNr 
)

Remap bone to a new bone. This will overwrite the given old bones with the new one.

Parameters
oldNodeNrThe node number to be searched and replaced.
newNodeNrThe node number with which the old bones will be replaced with.

◆ RemoveBone()

void EMotionFX::SubMesh::RemoveBone ( size_t  index)

Remove the given bone from the bones list.

Parameters
indexThe index of the bone to be removed in range of [0..GetNumBones()-1].

◆ SetBone()

void EMotionFX::SubMesh::SetBone ( size_t  index,
size_t  nodeIndex 
)

Set the index of a given bone.

Parameters
indexThe bone number, which must be in range of [0..GetNumBones()-1].
nodeIndexThe node index number that acts as bone on this submesh.

◆ SetNumBones()

void EMotionFX::SubMesh::SetNumBones ( size_t  numBones)

Set the number of bones that is being used by this submesh.

Parameters
numBonesThe number of bones used by the submesh.

◆ SetNumIndices()

void EMotionFX::SubMesh::SetNumIndices ( uint32  numIndices)

Set the number of indices used by this submesh.

Parameters
numIndicesThe number of indices used by this submesh.

◆ SetNumVertices()

void EMotionFX::SubMesh::SetNumVertices ( uint32  numVertices)

Set the number of vertices used by this submesh.

Parameters
numVerticesThe number of vertices used by this submesh.

◆ SetParentMesh()

void EMotionFX::SubMesh::SetParentMesh ( Mesh mesh)

Set parent mesh.

Parameters
meshA pointer to the parent mesh to which this submesh belongs to.

◆ SetStartIndex()

void EMotionFX::SubMesh::SetStartIndex ( uint32  indexOffset)

Set the offset in the index array of the mesh where this submesh is part of.

Parameters
indexOffsetThe offset inside the index array of the mesh returned by GetParentMesh().

◆ SetStartPolygon()

void EMotionFX::SubMesh::SetStartPolygon ( uint32  polygonNumber)

Set the start polygon number.

Parameters
polygonNumberThe polygon number inside the polygon vertex count array of the mesh returned by GetParentMesh().

◆ SetStartVertex()

void EMotionFX::SubMesh::SetStartVertex ( uint32  vertexOffset)

Set the offset in the vertex array of the mesh where this submesh is part of.

Parameters
vertexOffsetThe offset inside the index array of the mesh returned by GetParentMesh().

Member Data Documentation

◆ m_bones

AZStd::vector<size_t> EMotionFX::SubMesh::m_bones
protected

The collection of bones. These are stored as node numbers that point into the actor.

◆ m_numIndices

uint32 EMotionFX::SubMesh::m_numIndices
protected

The number of indices in this submesh.

◆ m_numPolygons

uint32 EMotionFX::SubMesh::m_numPolygons
protected

The number of polygons in this submesh.

◆ m_numVertices

uint32 EMotionFX::SubMesh::m_numVertices
protected

The number of vertices in this submesh.

◆ m_parentMesh

Mesh* EMotionFX::SubMesh::m_parentMesh
protected

The parent mesh.

◆ m_startIndex

uint32 EMotionFX::SubMesh::m_startIndex
protected

The start index number in the index array of the parent mesh.

◆ m_startPolygon

uint32 EMotionFX::SubMesh::m_startPolygon
protected

The start polygon number in the polygon vertex count array of the parent mesh.

◆ m_startVertex

uint32 EMotionFX::SubMesh::m_startVertex
protected

The start vertex number in the vertex data arrays of the parent mesh.


The documentation for this class was generated from the following file: