Open 3D Engine EMotionFX Gem API Reference
24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
|
#include <Mesh.h>
Inherits MCore::RefCounted.
Public Types | |
enum | : uint32 { ATTRIB_POSITIONS = 0 , ATTRIB_NORMALS = 1 , ATTRIB_TANGENTS = 2 , ATTRIB_UVCOORDS = 3 , ATTRIB_ORGVTXNUMBERS = 5 , ATTRIB_BITANGENTS = 7 } |
enum | { MEMORYBLOCK_ID = 100 } |
enum | EMeshType { MESHTYPE_STATIC = 0 , MESHTYPE_CPU_DEFORMED = 1 , MESHTYPE_GPU_DEFORMED = 2 } |
Public Member Functions | |
void | CalcNormals (bool useDuplicates=false) |
bool | CalcTangents (uint32 uvLayer=0, bool storeBitangents=false) |
void | Allocate (uint32 numVerts, uint32 numIndices, uint32 numPolygons, uint32 numOrgVerts) |
void | ReleaseData () |
MCORE_INLINE uint32 | GetNumVertices () const |
size_t | CalcNumUVLayers () const |
size_t | CalcNumAttributeLayers (uint32 type) const |
MCORE_INLINE uint32 | GetNumOrgVertices () const |
void | ResetToOriginalData () |
MCORE_INLINE uint32 * | GetIndices () const |
MCORE_INLINE uint8 * | GetPolygonVertexCounts () const |
MCORE_INLINE uint32 | GetNumIndices () const |
MCORE_INLINE uint32 | GetNumPolygons () const |
MCORE_INLINE void | AddSubMesh (SubMesh *subMesh) |
MCORE_INLINE size_t | GetNumSubMeshes () const |
MCORE_INLINE SubMesh * | GetSubMesh (size_t nr) const |
MCORE_INLINE void | SetSubMesh (size_t nr, SubMesh *subMesh) |
MCORE_INLINE void | SetNumSubMeshes (size_t numSubMeshes) |
void | RemoveSubMesh (size_t nr, bool delFromMem=true) |
void | InsertSubMesh (size_t insertIndex, SubMesh *subMesh) |
VertexAttributeLayer * | GetSharedVertexAttributeLayer (size_t layerNr) |
void | AddSharedVertexAttributeLayer (VertexAttributeLayer *layer) |
size_t | GetNumSharedVertexAttributeLayers () const |
size_t | FindSharedVertexAttributeLayerNumber (uint32 layerTypeID, size_t occurrence=0) const |
VertexAttributeLayer * | FindSharedVertexAttributeLayer (uint32 layerTypeID, size_t occurence=0) const |
void | RemoveAllSharedVertexAttributeLayers () |
void | RemoveSharedVertexAttributeLayer (size_t layerNr) |
size_t | GetNumVertexAttributeLayers () const |
VertexAttributeLayer * | GetVertexAttributeLayer (size_t layerNr) |
void | AddVertexAttributeLayer (VertexAttributeLayer *layer) |
void | ReserveVertexAttributeLayerSpace (uint32 numLayers) |
size_t | FindVertexAttributeLayerNumber (uint32 layerTypeID, size_t occurrence=0) const |
size_t | FindVertexAttributeLayerNumberByName (uint32 layerTypeID, const char *name) const |
VertexAttributeLayer * | FindVertexAttributeLayerByName (uint32 layerTypeID, const char *name) const |
VertexAttributeLayer * | FindVertexAttributeLayer (uint32 layerTypeID, size_t occurence=0) const |
size_t | FindVertexAttributeLayerIndexByName (const char *name) const |
size_t | FindVertexAttributeLayerIndexByNameString (const AZStd::string &name) const |
size_t | FindVertexAttributeLayerIndexByNameID (uint32 nameID) const |
size_t | FindSharedVertexAttributeLayerIndexByName (const char *name) const |
size_t | FindSharedVertexAttributeLayerIndexByNameString (const AZStd::string &name) const |
size_t | FindSharedVertexAttributeLayerIndexByNameID (uint32 nameID) const |
void | RemoveAllVertexAttributeLayers () |
void | RemoveVertexAttributeLayer (size_t layerNr) |
bool | Intersects (const Transform &transform, const MCore::Ray &ray) |
bool | Intersects (const Transform &transform, const MCore::Ray &ray, AZ::Vector3 *outIntersect, float *outBaryU=nullptr, float *outBaryV=nullptr, uint32 *outIndices=nullptr) |
void | GatherBonesForFace (uint32 startIndexOfFace, AZStd::vector< Node * > &outBones, Actor *actor) |
uint32 | CalcMaxNumInfluencesForFace (uint32 startIndexOfFace) const |
size_t | CalcMaxNumInfluences () const |
size_t | CalcMaxNumInfluences (AZStd::vector< size_t > &outVertexCounts) const |
void | ExtractOriginalVertexPositions (AZStd::vector< AZ::Vector3 > &outPoints) const |
Mesh * | Clone () |
void | SwapVertex (uint32 vertexA, uint32 vertexB) |
void | RemoveVertices (uint32 startVertexNr, uint32 endVertexNr, bool changeIndexBuffer=true, bool removeEmptySubMeshes=false) |
size_t | RemoveEmptySubMeshes (bool onlyRemoveOnZeroVertsAndTriangles=true) |
void * | FindVertexData (uint32 layerID, size_t occurrence=0) const |
void * | FindVertexDataByName (uint32 layerID, const char *name) const |
void * | FindOriginalVertexData (uint32 layerID, size_t occurrence=0) const |
void * | FindOriginalVertexDataByName (uint32 layerID, const char *name) const |
void | CalcAabb (AZ::Aabb *outBoundingBox, const Transform &transform, uint32 vertexFrequency=1) |
EMeshType | ClassifyMeshType (size_t lodLevel, Actor *actor, size_t nodeIndex, bool forceCPUSkinning, uint32 maxInfluences, uint32 maxBonesPerSubMesh) const |
void | Log () |
bool | ConvertTo16BitIndices () |
bool | CheckIfIsTriangleMesh () const |
bool | CheckIfIsQuadMesh () const |
uint32 | CalcNumTriangles () const |
void | Scale (float scaleFactor) |
uint16 | GetNumUniqueJoints () const |
void | SetNumUniqueJoints (uint16 numUniqueJoints) |
uint16 | GetHighestJointIndex () const |
void | SetHighestJointIndex (uint16 highestJointIndex) |
MCORE_INLINE bool | GetIsCollisionMesh () const |
void | SetIsCollisionMesh (bool isCollisionMesh) |
Public Member Functions inherited from MCore::RefCounted | |
RefCounted () | |
virtual | ~RefCounted () |
void | IncreaseReferenceCount () |
void | DecreaseReferenceCount () |
void | Destroy () |
uint32 | GetReferenceCount () const |
Static Public Member Functions | |
static Mesh * | Create () |
static Mesh * | Create (uint32 numVerts, uint32 numIndices, uint32 numPolygons, uint32 numOrgVerts, bool isCollisionMesh) |
static Mesh * | CreateFromModelLod (const AZ::Data::Asset< AZ::RPI::ModelLodAsset > &sourceModelLod, const AZStd::unordered_map< AZ::u16, AZ::u16 > &skinToSkeletonIndexMap) |
static void | CalcTangentAndBitangentForFace (const AZ::Vector3 &posA, const AZ::Vector3 &posB, const AZ::Vector3 &posC, const AZ::Vector2 &uvA, const AZ::Vector2 &uvB, const AZ::Vector2 &uvC, AZ::Vector3 *outTangent, AZ::Vector3 *outBitangent) |
Protected Member Functions | |
Mesh () | |
Mesh (uint32 numVerts, uint32 numIndices, uint32 numPolygons, uint32 numOrgVerts, bool isCollisionMesh) | |
~Mesh () | |
Protected Member Functions inherited from MCore::RefCounted | |
virtual void | Delete () |
Protected Attributes | |
AZStd::vector< SubMesh * > | m_subMeshes |
uint32 * | m_indices |
uint8 * | m_polyVertexCounts |
uint32 | m_numPolygons |
uint32 | m_numOrgVerts |
uint32 | m_numVertices |
uint32 | m_numIndices |
uint16 | m_numUniqueJoints |
uint16 | m_highestJointIndex |
bool | m_isCollisionMesh |
AZStd::vector< VertexAttributeLayer * > | m_sharedVertexAttributes |
AZStd::vector< VertexAttributeLayer * > | m_vertexAttributes |
The mesh base class. Every mesh contains a list of vertex data (positions, normals and uv coordinates) and a set of indices. The indices describe the polygons and point into the vertex data. The vertex data is stored in seperate layers. So the position, normal, uv and tangent data is stored in three layers/arrays. You can access the vertex data with FindVertexData() and FindOriginalVertexData(). The length of all these arrays equals the value returned by GetNumVertices(). So this means that there are ALWAYS the same amount of positions, normals and uv coordinates in the mesh. Vertices automatically are duplicated when needed. This means that a flat shaded cube of triangles which normally has 8 vertices will have 24 vertices in this mesh. This is done, because you can use this vertex data directly to render it on the graphics hardware and it allows multiple normals and texture coordinates per vertex, which is needed for good texture mapping support and support for smoothing groups and flat shading. Still, each of the 24 vertices in the 'cube' example will have indices to their original vertices (which are not stored). This array of indices can be accessed by calling GetOrgVerts(). The values stored in this array will range from [0..7]. The mesh also contains a set of vertex attributes, which are user defined attributes per vertex. Next to that there also are shared vertex attributes, which are only there for the real number of vertices. All vertices have the same number of attributes, and attribute number 'n' has to be of the same type for all vertices as well.
anonymous enum : uint32 |
VertexAttributeLayerAbstractData::GetType() values for the vertex data Use these with the Mesh::FindVertexData() and Mesh::FindOriginalVertexData() methods.
anonymous enum |
The memory block ID where mesh data will be allocated in. Giving mesh data their own memory blocks can reduce the amount of used total blocks when memory gets deleted again.
The mesh type used to indicate if a mesh is either static, like a cube or building, cpu deformed, if it needs to be processed on the CPU, or GPU deformed if it can be processed fully on the GPU.
|
protected |
Default constructor.
|
protected |
Constructor which allocates mesh data. Please keep in mind that this does not create and add any layers for position, normal, tangent, uv data etc.
numVerts | The number of vertices to allocate. |
numIndices | The number of indices to allocate. |
numPolygons | The number of polygons to allocate. |
numOrgVerts | The number of original vertices. |
isCollisionMesh | Set to true if this mesh is a collision mesh. |
|
protected |
Destructor. Automatically releases all data.
void EMotionFX::Mesh::AddSharedVertexAttributeLayer | ( | VertexAttributeLayer * | layer | ) |
Adds a new layer of shared vertex attributes. The data will automatically be deleted from memory on destruction of the mesh.
layer | The layer to add. The array must contain GetNumOrgVertices() elements. |
MCORE_INLINE void Mesh::AddSubMesh | ( | SubMesh * | subMesh | ) |
void EMotionFX::Mesh::AddVertexAttributeLayer | ( | VertexAttributeLayer * | layer | ) |
Adds a new layer of vertex attributes. The data will automatically be deleted from memory on destruction of the mesh.
layer | The layer to add. The array must contain GetNumVertices() elements. |
void EMotionFX::Mesh::Allocate | ( | uint32 | numVerts, |
uint32 | numIndices, | ||
uint32 | numPolygons, | ||
uint32 | numOrgVerts | ||
) |
Allocate mesh data. If there is already data allocated, this data will be deleted first. Please keep in mind this does not create and add any layers for position, normal, uv and tangent data etc. Only indices will be allocated.
numVerts | The number of vertices to allocate. |
numIndices | The number of indices to allocate. |
numPolygons | The number of polygons to allocate. |
numOrgVerts | The number of original vertices. |
void EMotionFX::Mesh::CalcAabb | ( | AZ::Aabb * | outBoundingBox, |
const Transform & | transform, | ||
uint32 | vertexFrequency = 1 |
||
) |
Calculate the axis aligned bounding box of this mesh, after transforming the positions with the provided transform.
outBoundingBox | The bounding box that will contain the bounds after executing this method. |
Transform | The transformation to transform all vertex positions with. |
vertexFrequency | This is the for loop increase counter value. A value of 1 means every vertex will be processed while a value of 2 means every second vertex, etc. The value must be 1 or higher. |
size_t EMotionFX::Mesh::CalcMaxNumInfluences | ( | ) | const |
Calculates the maximum number of bone influences. This is calculated by for each vertex checking the number of bone influences, and take the maximum of that amount.
size_t EMotionFX::Mesh::CalcMaxNumInfluences | ( | AZStd::vector< size_t > & | outVertexCounts | ) | const |
Calculates the maximum number of bone influences. This is calculated by for each vertex checking the number of bone influences, and take the maximum of that amount.
vertexCounts | Reference to an interger array, which will be filled by this function with vertex counts for specific number of influences. array[0] e.g. holds the number of vertices which have no influences, so non-skinned; array[4] holds the number of vertices which are effected by 4 bones. |
uint32 EMotionFX::Mesh::CalcMaxNumInfluencesForFace | ( | uint32 | startIndexOfFace | ) | const |
Calculates the maximum number of bone influences for a given face. This is calculated by for each vertex checking the number of bone influences, and take the maximum of that amount.
startIndexOfFace | The start index of the first vertex of the face. So not the vertex number, but the offset in the index array of this mesh. |
void EMotionFX::Mesh::CalcNormals | ( | bool | useDuplicates = false | ) |
Recalculates the vertex normals.
useDuplicates | Setting this to true will cause hard borders at vertices that have been duplicated. Setting to false (default) will use the original mesh vertex positions only which results in the mesh being fully smoothed. On a cube however that would not work well, as it won't preserve the hard face normals, but it will smooth the normals. Most of the time on character you would want to set this to false though, to prevent seams from showing up in areas between the neck and body. |
size_t EMotionFX::Mesh::CalcNumAttributeLayers | ( | uint32 | type | ) | const |
Calculate the number of vertex attribute layers of the given type. It is recommended NOT to put this function inside a loop, because it is not very fast.
[in] | type | The type of the vertex attribute layer to count. |
uint32 EMotionFX::Mesh::CalcNumTriangles | ( | ) | const |
Calculate how many triangles this mesh has. In case the mesh contains polygons of more than 3 vertices, triangulation will be taken into account.
size_t EMotionFX::Mesh::CalcNumUVLayers | ( | ) | const |
Extract the number of UV coordinate layers. It is recommended NOT to put this function inside a loop, because it is not very fast.
|
static |
Calculates the tangent and bitangent for a given triangle.
posA | The position of the first vertex. |
posB | The position of the second vertex. |
posC | The position of the third vertex. |
uvA | The texture coordinate of the first vertex. |
uvB | The texture coordinate of the second vertex. |
uvC | The texture coordinate of the third vertex. |
outTangent | A pointer to the vector to store the calculated tangent vector. |
outBitangent | A pointer to the vector to store the calculated bitangent vector (calculated using the gradients). |
bool EMotionFX::Mesh::CalcTangents | ( | uint32 | uvLayer = 0 , |
bool | storeBitangents = false |
||
) |
Calculates the tangent vectors which can be used for per pixel lighting. These are vectors also known as S and T, used in per pixel lighting techniques, like bumpmapping. You can calculate the bitangent for the given tangent by taking the cross product between the normal and the tangent for the given vertex. These three vectors (normal, tangent and bitangent) are used to build a matrix which transforms the lights into tangent space. You can only call this method after you have passed all other vertex and index data to the mesh. So after all that has been initialized, call this method to calculate these vectors automatically. If you specify a UV set that doesn't exist, this method will fall back to UV set 0.
uvLayer[in] | The UV texture coordinate layer number. This is not the vertex attribute layer number, but the UV layer number. This means that 0 means the first UV set, and 1 would mean the second UV set, etc. When the UV layer doesn't exist, this method does nothing. |
storeBitangents | Set to true when you want the mesh to store its bitangents in its own layer. This will generate a bitangents layer inside the mesh. False will no do this. |
bool EMotionFX::Mesh::CheckIfIsQuadMesh | ( | ) | const |
Check if this mesh is a pure quad mesh. Please keep in mind that this method is quite heavy to process as it iterates over all polygons to check if the vertex count equals to 4 for all polygons in the worst case.
bool EMotionFX::Mesh::CheckIfIsTriangleMesh | ( | ) | const |
Check if this mesh is a pure triangle mesh. Please keep in mind that this method is quite heavy to process as it iterates over all polygons to check if the vertex count equals to 3 for all polygons in the worst case.
EMeshType EMotionFX::Mesh::ClassifyMeshType | ( | size_t | lodLevel, |
Actor * | actor, | ||
size_t | nodeIndex, | ||
bool | forceCPUSkinning, | ||
uint32 | maxInfluences, | ||
uint32 | maxBonesPerSubMesh | ||
) | const |
Check for a given mesh how we categorize it. A mesh can be either static, like a cube or building, dynamic if it has mesh deformers which have to be processed on the CPU like a morphing deformer or gpu skinned if they only have a skinning deformer applied. There are additional criteria like the maximum number of influences and the maximum number of bones per submesh to make it fit to different hardware specifications.
lodLevel | The geometry LOD level of the mesh to check. |
actor | The actor where this mesh belongs to. |
nodeIndex | The index of the node that has this mesh. |
forceCPUSkinning | If true the function will never return MESHTYPE_GPUSKINNED which means that no hardware processing will be used. |
maxInfluences | The maximum number of influences per vertex that can be processed on hardware. If there will be more influences the mesh will be processed in software which will be very slow. |
maxBonesPerSubMesh | The maximum number of bones per submesh can be processed on hardware. If there will be more bones per submesh the mesh will be processed in software which will be very slow. |
Mesh* EMotionFX::Mesh::Clone | ( | ) |
Clone the mesh.
bool EMotionFX::Mesh::ConvertTo16BitIndices | ( | ) |
Convert the 32-bit vertex indices to 16-bit index values. Do not call this function more than once per mesh. The number of indices will stay the same while the size of the index buffer will be half as big as before. When calling GetIndices() make sure to type-cast the returned pointer to an uint16*.
|
static |
Default constructor.
|
static |
Constructor which allocates mesh data. Please keep in mind that this does not create and add any layers for position, normal, tangent, uv data etc.
numVerts | The number of vertices to allocate. |
numIndices | The number of indices to allocate. |
numPolygons | The number of polygons to allocate. |
numOrgVerts | The number of original vertices. |
isCollisionMesh | Set to true if this mesh is a collision mesh. |
void EMotionFX::Mesh::ExtractOriginalVertexPositions | ( | AZStd::vector< AZ::Vector3 > & | outPoints | ) | const |
Extract a list of positions of the original vertices. For a cube, which normally might have 32 vertices, it will result in 8 positions.
outPoints | The output array to store the points in. The array will be automatically resized. |
void* EMotionFX::Mesh::FindOriginalVertexData | ( | uint32 | layerID, |
size_t | occurrence = 0 |
||
) | const |
Find specific original vertex data in the mesh. The difference between the original vertex data and current vertex data as returned by FindVertexData is that the original vertex data is the data stored in the base pose, before any mesh deformers are being applied to it. Here are some examples to get common vertex data:
Vector3* positions = (Vector3*)mesh->FindOriginalVertexData( Mesh::ATTRIB_POSITIONS ); // the positions Vector3* normals = (Vector3*)mesh->FindOriginalVertexData( Mesh::ATTRIB_NORMALS ); // the normals Vector4* tangents = (Vector4*)mesh->FindOriginalVertexData( Mesh::ATTRIB_TANGENTS ); // first set of tangents, can be nullptr, and note the Vector4! AZ::Vector2* uvCoords = static_cast<AZ::Vector2*>(mesh->FindOriginalVertexData( Mesh::ATTRIB_UVCOORDS )); // the first set of UVs, can be nullptr AZ::Vector2* uvCoords2 = static_cast<AZ::Vector2*>(mesh->FindOriginalVertexData( Mesh::ATTRIB_UVCOORDS, 1 )); // the second set of UVs, can be nullptr
layerID | The layer type ID to get the information from. |
occurrence | The layer number to get. Where 0 means the first layer, 1 means the second, etc. This is used when there are multiple layers of the same type. An example is a mesh having multiple UV layers. |
VertexAttributeLayer* EMotionFX::Mesh::FindSharedVertexAttributeLayer | ( | uint32 | layerTypeID, |
size_t | occurence = 0 |
||
) | const |
Find and return the shared vertex attribute layer of a given type. If you like to find the first layer of the given type, the occurence parameter must be set to a value of 0. If you like to find the second layer of this type, the occurence parameter must be set to a value of of 1, etc. This function will return nullptr when the layer cannot be found.
layerTypeID | the layer type ID to search for. |
occurence | The occurence to search for. Set to 0 when you want the first layer of this type, set to 1 if you want the second layer of the given type, etc. |
size_t EMotionFX::Mesh::FindSharedVertexAttributeLayerNumber | ( | uint32 | layerTypeID, |
size_t | occurrence = 0 |
||
) | const |
Find and return the shared vertex attribute layer of a given type. If you like to find the first layer of the given type, the occurence parameter must be set to a value of 0. If you like to find the second layer of this type, the occurence parameter must be set to a value of of 1, etc. This function will return nullptr when the layer cannot be found.
layerTypeID | the layer type ID to search for. |
occurrence | The occurence to search for. Set to 0 when you want the first layer of this type, set to 1 if you want the second layer of the given type, etc. |
VertexAttributeLayer* EMotionFX::Mesh::FindVertexAttributeLayer | ( | uint32 | layerTypeID, |
size_t | occurence = 0 |
||
) | const |
Find and return the non-shared vertex attribute layer of a given type. If you like to find the first layer of the given type, the occurence parameter must be set to a value of 0. If you like to find the second layer of this type, the occurence parameter must be set to a value of of 1, etc. This function will return nullptr when the layer cannot be found.
layerTypeID | the layer type ID to search for. |
occurence | The occurence to search for. Set to 0 when you want the first layer of this type, set to 1 if you want the second layer of the given type, etc. |
size_t EMotionFX::Mesh::FindVertexAttributeLayerNumber | ( | uint32 | layerTypeID, |
size_t | occurrence = 0 |
||
) | const |
Find and return the non-shared vertex attribute layer of a given type. If you like to find the first layer of the given type, the occurence parameter must be set to a value of 0. If you like to find the second layer of this type, the occurence parameter must be set to a value of of 1, etc. This function will return nullptr when the layer cannot be found.
layerTypeID | the layer type ID to search for. |
occurrence | The occurence to search for. Set to 0 when you want the first layer of this type, set to 1 if you want the second layer of the given type, etc. |
void* EMotionFX::Mesh::FindVertexData | ( | uint32 | layerID, |
size_t | occurrence = 0 |
||
) | const |
Find specific current vertex data in the mesh. This contains the vertex data after mesh deformers have been applied to them. If you want the vertex data before any mesh deformers have been applied to it, use the method named FindOriginalVertexData instead. Here are some examples to get common vertex data:
Vector3* positions = (Vector3*)mesh->FindVertexData( Mesh::ATTRIB_POSITIONS ); // the positions Vector3* normals = (Vector3*)mesh->FindVertexData( Mesh::ATTRIB_NORMALS ); // the normals Vector4* tangents = (Vector4*)mesh->FindVertexData( Mesh::ATTRIB_TANGENTS ); // first set of tangents, can be nullptr, and note the Vector4! AZ::Vector2* uvCoords = static_cast<AZ::Vector2*>(mesh->FindVertexData( Mesh::ATTRIB_UVCOORDS )); // the first set of UVs, can be nullptr AZ::Vector2* uvCoords2 = static_cast<AZ::Vector2*>(mesh->FindVertexData( Mesh::ATTRIB_UVCOORDS, 1 )); // the second set of UVs, can be nullptr
layerID | The layer type ID to get the information from. |
occurrence | The layer number to get. Where 0 means the first layer, 1 means the second, etc. This is used when there are multiple layers of the same type. An example is a mesh having multiple UV layers. |
void EMotionFX::Mesh::GatherBonesForFace | ( | uint32 | startIndexOfFace, |
AZStd::vector< Node * > & | outBones, | ||
Actor * | actor | ||
) |
Gather all bones influencing a specified face into a specified array. The outBones array will be cleared when it enters the method.
startIndexOfFace | The start index of the first vertex of the face. So not the vertex number, but the offset in the index array of this mesh. |
outBones | The array to store the pointers to the bones in. Any existing array contents will be cleared when it enters the method. |
actor | The actor to search the bones in. |
MCORE_INLINE uint16 Mesh::GetHighestJointIndex | ( | ) | const |
Get the highest id of all the jointId's used by this mesh
MCORE_INLINE uint32 * Mesh::GetIndices | ( | ) | const |
Get a pointer to the face indices. Every face has 3 indices and all faces indices are stored after eachother.
MCORE_INLINE uint32 Mesh::GetNumIndices | ( | ) | const |
Returns the number of indices in the mesh, which is the sum of all polygon vertex counts.
MCORE_INLINE uint32 Mesh::GetNumOrgVertices | ( | ) | const |
Get the number of original vertices. This can be lower compared to the value returned by GetNumVertices(). For the example of the cube with 8 real vertices, but 24 vertices in this mesh, this method would return a value of 8, while the method GetNumVertices() would return 24. Please keep in mind that the number of elements in the array returned by GetOrgVerts() however equals the amount returned by GetNumVertices() and not the amount returned by this method!
MCORE_INLINE uint32 Mesh::GetNumPolygons | ( | ) | const |
Returns the number of polygons.
size_t EMotionFX::Mesh::GetNumSharedVertexAttributeLayers | ( | ) | const |
Get the number of shared vertex attributes. This value is the same for all shared vertices.
MCORE_INLINE size_t Mesh::GetNumSubMeshes | ( | ) | const |
Get the number of sub meshes currently in the mesh.
MCORE_INLINE uint16 Mesh::GetNumUniqueJoints | ( | ) | const |
Get the total number of unique joints that impact this mesh
size_t EMotionFX::Mesh::GetNumVertexAttributeLayers | ( | ) | const |
Get the number of vertex attributes. This value is the same for all vertices.
MCORE_INLINE uint32 Mesh::GetNumVertices | ( | ) | const |
Get the number of vertices in the mesh. The number of positions, normals and uv coordinates is equal to the value returned by this method.
MCORE_INLINE uint8 * Mesh::GetPolygonVertexCounts | ( | ) | const |
Get a pointer to the polygon vertex count. Every polygon stores an integer which represents the number of vertices/indices this polygon stores. The length of this array equals GetNumPolygons().
VertexAttributeLayer* EMotionFX::Mesh::GetSharedVertexAttributeLayer | ( | size_t | layerNr | ) |
Get the shared vertex attribute data of a given layer. The number of arrays inside the array returned equals the value returned by GetNumOrgVertices().
layerNr | The layer number to get the attributes from. Must be below the value returned by GetNumSharedVertexAttributeLayers(). |
MCORE_INLINE SubMesh * Mesh::GetSubMesh | ( | size_t | nr | ) | const |
VertexAttributeLayer* EMotionFX::Mesh::GetVertexAttributeLayer | ( | size_t | layerNr | ) |
Get the vertex attribute data of a given layer. The number of arrays inside the array returned equals the value returned by GetNumVertices().
layerNr | The layer number to get the attributes from. Must be below the value returned by GetNumVertexAttributeLayers(). |
void EMotionFX::Mesh::InsertSubMesh | ( | size_t | insertIndex, |
SubMesh * | subMesh | ||
) |
Insert a submesh into the array of submeshes.
insertIndex | The position in the submesh array to insert this new submesh. |
subMesh | A pointer to the submesh to insert into this mesh. |
bool EMotionFX::Mesh::Intersects | ( | const Transform & | transform, |
const MCore::Ray & | ray | ||
) |
Checks for an intersection between the mesh and a given ray.
transform | The transformation of the mesh. |
ray | The ray to test with. |
bool EMotionFX::Mesh::Intersects | ( | const Transform & | transform, |
const MCore::Ray & | ray, | ||
AZ::Vector3 * | outIntersect, | ||
float * | outBaryU = nullptr , |
||
float * | outBaryV = nullptr , |
||
uint32 * | outIndices = nullptr |
||
) |
Check for an intersection between the mesh a given ray, and calculate the closest intersection point. If you do NOT need to know the intersection point, use the other Intersects method, because that one is faster, since it doesn't need to calculate the closest intersection point. The intersection point returned is in object space.
transform | The transformation of the mesh. |
ray | The ray to test with. |
outIntersect | A pointer to the vector to store the intersection point in, in case of a collision (nullptr allowed). |
outBaryU | A pointer to a float in which the method will store the barycentric U coordinate, to be used to interpolate values on the triangle (nullptr allowed). |
outBaryV | A pointer to a float in which the method will store the barycentric V coordinate, to be used to interpolate values on the triangle (nullptr allowed). |
outIndices | A pointer to an array of 3 integers, which will contain the 3 vertex indices of the closest intersecting triangle. Even on polygon meshes with polygons of more than 3 vertices three indices are returned. In that case the indices represent a sub-triangle inside the polygon. A value of nullptr is allowed, which will skip storing the resulting triangle indices. |
void EMotionFX::Mesh::Log | ( | ) |
Debug log information. Information will be logged using LOGLEVEL_DEBUG.
void EMotionFX::Mesh::ReleaseData | ( | ) |
Releases all allocated mesh data.
void EMotionFX::Mesh::RemoveAllSharedVertexAttributeLayers | ( | ) |
Removes all shared vertex attributes for all shared vertices. The previously allocated attributes will be deleted from memory automatically.
void EMotionFX::Mesh::RemoveAllVertexAttributeLayers | ( | ) |
Removes all vertex attributes for all vertices. The previously allocated attributes will be deleted from memory automatically.
size_t EMotionFX::Mesh::RemoveEmptySubMeshes | ( | bool | onlyRemoveOnZeroVertsAndTriangles = true | ) |
Remove all empty submeshes. A submesh is either empty if it has no vertices or no indices or a combination of both.
onlyRemoveOnZeroVertsAndTriangles | Only remove when both the number of vertices and number of indices/triangles are zero. |
void EMotionFX::Mesh::RemoveSharedVertexAttributeLayer | ( | size_t | layerNr | ) |
Remove a layer of shared vertex attributes. Automatically deletes the data from memory.
layerNr | The layer number to remove, must be below the value returned by GetNumSharedVertexAttributeLayers(). |
void EMotionFX::Mesh::RemoveSubMesh | ( | size_t | nr, |
bool | delFromMem = true |
||
) |
Remove a given submesh from this mesh.
nr | The submesh index number to remove, which must be in range of 0..GetNumSubMeshes()-1. |
delFromMem | Set to true when you want to delete the submesh from memory as well, otherwise set to false. |
void EMotionFX::Mesh::RemoveVertexAttributeLayer | ( | size_t | layerNr | ) |
Remove a layer of vertex attributes. Automatically deletes the data from memory.
layerNr | The layer number to remove, must be below the value returned by GetNumVertexAttributeLayers(). |
void EMotionFX::Mesh::RemoveVertices | ( | uint32 | startVertexNr, |
uint32 | endVertexNr, | ||
bool | changeIndexBuffer = true , |
||
bool | removeEmptySubMeshes = false |
||
) |
Remove a specific range of vertices from the mesh. This also might change all pointers to vertex and index data returned by this mesh and its submeshes. This automatically also adjusts the index buffer as well. Please note that the specified end vertex will also be removed!
startVertexNr | The vertex number to start removing from. |
endVertexNr | The last vertex number to remove, this value must be bigger or equal than the start vertex number. |
changeIndexBuffer | If this is set to true, the index buffer will be modified on such a way that all vertex number indexed by the index buffer, which are above the startVertexNr parameter value, will be decreased by the amount of removed vertices. |
removeEmptySubMeshes | When set to true (default) submeshes that become empty will be removed from memory. |
void EMotionFX::Mesh::ReserveVertexAttributeLayerSpace | ( | uint32 | numLayers | ) |
Reserve space for the given amount of vertex attribute layers. This just pre-allocates array data to prevent reallocs.
numLayers | The number of layers to reserve space for. |
void EMotionFX::Mesh::ResetToOriginalData | ( | ) |
Resets all final/output vertex data to its original data, as it was before any deformers where applied. This will copy the original positions over the final positions, the original normals over the final normals and the original uv coordinates over the final uv coordinates.
void EMotionFX::Mesh::Scale | ( | float | scaleFactor | ) |
Scale all positional data. This is a slow operation and is used to convert between different unit systems (cm, meters, etc).
scaleFactor | The scale factor to scale the current data by. |
MCORE_INLINE void Mesh::SetHighestJointIndex | ( | uint16 | highestJointIndex | ) |
Get the highest id of all the jointId's used by this mesh
|
inline |
Set the number of submeshes. This adjusts the number returned by GetNumSubMeshes(). Do not forget to use SetSubMesh() to initialize all submeshes!
numSubMeshes | The number of submeshes to use. |
MCORE_INLINE void Mesh::SetNumUniqueJoints | ( | uint16 | numUniqueJoints | ) |
Set the total number of unique joints that impact this mesh
|
inline |
Set the value for a given submesh.
nr | The submesh number, which must be in range of [0..GetNumSubMeshes()-1]. |
subMesh | The submesh to use. |
void EMotionFX::Mesh::SwapVertex | ( | uint32 | vertexA, |
uint32 | vertexB | ||
) |
Swap two vertices. This will swap all data elements, such as position and normals. Not only it will swap the basic data like position and normals, but also all vertex attributes. This method is used by the meshes support inside GetEMotionFX().
vertexA | The first vertex number. |
vertexB | The second vertex number. |
|
protected |
The highest id of all the joints used by this mesh
|
protected |
The array of indices, which define the faces.
|
protected |
Is this mesh a collision mesh?
|
protected |
Number of indices.
|
protected |
The number of original vertices.
|
protected |
The number of polygons in this mesh.
|
protected |
Number of unique joints
|
protected |
Number of vertices.
|
protected |
The number of vertices for each polygon, where the length of this array equals the number of polygons.
|
protected |
The array of shared vertex attribute layers. The number of attributes in each shared layer will be equal to the value returned by Mesh::GetNumOrgVertices().
|
protected |
The collection of sub meshes.
|
protected |
The array of non-shared vertex attribute layers. The number of attributes in each shared layer will be equal to the value returned by Mesh::GetNumVertices().