Update mesh.h

pull/4962/head
Kim Kulling 2023-02-15 21:02:03 +01:00 committed by GitHub
parent bfa19f6900
commit 9898138516
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 304 additions and 223 deletions

View File

@ -3,7 +3,7 @@
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team Copyright (c) 2006-2023, assimp team
All rights reserved. All rights reserved.
@ -111,7 +111,8 @@ extern "C" {
#endif // !! AI_MAX_NUMBER_OF_TEXTURECOORDS #endif // !! AI_MAX_NUMBER_OF_TEXTURECOORDS
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** @brief A single face in a mesh, referring to multiple vertices. /**
* @brief A single face in a mesh, referring to multiple vertices.
* *
* If mNumIndices is 3, we call the face 'triangle', for mNumIndices > 3 * If mNumIndices is 3, we call the face 'triangle', for mNumIndices > 3
* it's called 'polygon' (hey, that's just a definition!). * it's called 'polygon' (hey, that's just a definition!).
@ -142,25 +143,25 @@ struct aiFace {
#ifdef __cplusplus #ifdef __cplusplus
//! Default constructor //! @brief Default constructor.
aiFace() AI_NO_EXCEPT aiFace() AI_NO_EXCEPT
: mNumIndices(0), : mNumIndices(0),
mIndices(nullptr) { mIndices(nullptr) {
// empty // empty
} }
//! Default destructor. Delete the index array //! @brief Default destructor. Delete the index array
~aiFace() { ~aiFace() {
delete[] mIndices; delete[] mIndices;
} }
//! Copy constructor. Copy the index array //! @brief Copy constructor. Copy the index array
aiFace(const aiFace &o) : aiFace(const aiFace &o) :
mNumIndices(0), mIndices(nullptr) { mNumIndices(0), mIndices(nullptr) {
*this = o; *this = o;
} }
//! Assignment operator. Copy the index array //! @brief Assignment operator. Copy the index array
aiFace &operator=(const aiFace &o) { aiFace &operator=(const aiFace &o) {
if (&o == this) { if (&o == this) {
return *this; return *this;
@ -178,8 +179,7 @@ struct aiFace {
return *this; return *this;
} }
//! Comparison operator. Checks whether the index array //! @brief Comparison operator. Checks whether the index array of two faces is identical.
//! of two faces is identical
bool operator==(const aiFace &o) const { bool operator==(const aiFace &o) const {
if (mIndices == o.mIndices) { if (mIndices == o.mIndices) {
return true; return true;
@ -202,7 +202,7 @@ struct aiFace {
return true; return true;
} }
//! Inverse comparison operator. Checks whether the index //! @brief Inverse comparison operator. Checks whether the index
//! array of two faces is NOT identical //! array of two faces is NOT identical
bool operator!=(const aiFace &o) const { bool operator!=(const aiFace &o) const {
return !(*this == o); return !(*this == o);
@ -223,14 +223,14 @@ struct aiVertexWeight {
#ifdef __cplusplus #ifdef __cplusplus
//! Default constructor //! @brief Default constructor
aiVertexWeight() AI_NO_EXCEPT aiVertexWeight() AI_NO_EXCEPT
: mVertexId(0), : mVertexId(0),
mWeight(0.0f) { mWeight(0.0f) {
// empty // empty
} }
//! Initialization from a given index and vertex weight factor //! @brief Initialization from a given index and vertex weight factor
//! \param pID ID //! \param pID ID
//! \param pWeight Vertex weight factor //! \param pWeight Vertex weight factor
aiVertexWeight(unsigned int pID, float pWeight) : aiVertexWeight(unsigned int pID, float pWeight) :
@ -261,27 +261,38 @@ struct aiNode;
* position of the bone at the time of binding. * position of the bone at the time of binding.
*/ */
struct aiBone { struct aiBone {
//! The name of the bone. /**
* The name of the bone.
*/
C_STRUCT aiString mName; C_STRUCT aiString mName;
//! The number of vertices affected by this bone. /**
//! The maximum value for this member is #AI_MAX_BONE_WEIGHTS. * The number of vertices affected by this bone.
* The maximum value for this member is #AI_MAX_BONE_WEIGHTS.
*/
unsigned int mNumWeights; unsigned int mNumWeights;
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS #ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
/// The bone armature node - used for skeleton conversion /**
/// you must enable aiProcess_PopulateArmatureData to populate this * The bone armature node - used for skeleton conversion
* you must enable aiProcess_PopulateArmatureData to populate this
*/
C_STRUCT aiNode *mArmature; C_STRUCT aiNode *mArmature;
/// The bone node in the scene - used for skeleton conversion /**
/// you must enable aiProcess_PopulateArmatureData to populate this * The bone node in the scene - used for skeleton conversion
* you must enable aiProcess_PopulateArmatureData to populate this
*/
C_STRUCT aiNode *mNode; C_STRUCT aiNode *mNode;
#endif #endif
//! The influence weights of this bone, by vertex index. /**
* The influence weights of this bone, by vertex index.
*/
C_STRUCT aiVertexWeight *mWeights; C_STRUCT aiVertexWeight *mWeights;
/** Matrix that transforms from mesh space to bone space in bind pose. /**
* Matrix that transforms from mesh space to bone space in bind pose.
* *
* This matrix describes the position of the mesh * This matrix describes the position of the mesh
* in the local space of this bone when the skeleton was bound. * in the local space of this bone when the skeleton was bound.
@ -338,7 +349,7 @@ struct aiBone {
::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight)); ::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight));
} }
//! Assignment operator //! @brief Assignment operator
aiBone &operator = (const aiBone &other) { aiBone &operator = (const aiBone &other) {
if (this == &other) { if (this == &other) {
return *this; return *this;
@ -352,6 +363,7 @@ struct aiBone {
return *this; return *this;
} }
/// @brief Compare operator.
bool operator==(const aiBone &rhs) const { bool operator==(const aiBone &rhs) const {
if (mName != rhs.mName || mNumWeights != rhs.mNumWeights ) { if (mName != rhs.mName || mNumWeights != rhs.mNumWeights ) {
return false; return false;
@ -365,7 +377,7 @@ struct aiBone {
return true; return true;
} }
//! Destructor - deletes the array of vertex weights //! @brief Destructor - deletes the array of vertex weights
~aiBone() { ~aiBone() {
delete[] mWeights; delete[] mWeights;
} }
@ -381,27 +393,31 @@ struct aiBone {
* @see AI_CONFIG_PP_SBP_REMOVE Removal of specific primitive types. * @see AI_CONFIG_PP_SBP_REMOVE Removal of specific primitive types.
*/ */
enum aiPrimitiveType { enum aiPrimitiveType {
/** A point primitive. /**
* @brief A point primitive.
* *
* This is just a single vertex in the virtual world, * This is just a single vertex in the virtual world,
* #aiFace contains just one index for such a primitive. * #aiFace contains just one index for such a primitive.
*/ */
aiPrimitiveType_POINT = 0x1, aiPrimitiveType_POINT = 0x1,
/** A line primitive. /**
* @brief A line primitive.
* *
* This is a line defined through a start and an end position. * This is a line defined through a start and an end position.
* #aiFace contains exactly two indices for such a primitive. * #aiFace contains exactly two indices for such a primitive.
*/ */
aiPrimitiveType_LINE = 0x2, aiPrimitiveType_LINE = 0x2,
/** A triangular primitive. /**
* @brief A triangular primitive.
* *
* A triangle consists of three indices. * A triangle consists of three indices.
*/ */
aiPrimitiveType_TRIANGLE = 0x4, aiPrimitiveType_TRIANGLE = 0x4,
/** A higher-level polygon with more than 3 edges. /**
* @brief A higher-level polygon with more than 3 edges.
* *
* A triangle is a polygon, but polygon in this context means * A triangle is a polygon, but polygon in this context means
* "all polygons that are not triangles". The "Triangulate"-Step * "all polygons that are not triangles". The "Triangulate"-Step
@ -411,7 +427,7 @@ enum aiPrimitiveType {
aiPrimitiveType_POLYGON = 0x8, aiPrimitiveType_POLYGON = 0x8,
/** /**
* A flag to determine whether this triangles only mesh is NGON encoded. * @brief A flag to determine whether this triangles only mesh is NGON encoded.
* *
* NGON encoding is a special encoding that tells whether 2 or more consecutive triangles * NGON encoding is a special encoding that tells whether 2 or more consecutive triangles
* should be considered as a triangle fan. This is identified by looking at the first vertex index. * should be considered as a triangle fan. This is identified by looking at the first vertex index.
@ -428,7 +444,8 @@ enum aiPrimitiveType {
*/ */
aiPrimitiveType_NGONEncodingFlag = 0x10, aiPrimitiveType_NGONEncodingFlag = 0x10,
/** This value is not used. It is just here to force the /**
* This value is not used. It is just here to force the
* compiler to map this enum to a 32 Bit integer. * compiler to map this enum to a 32 Bit integer.
*/ */
#ifndef SWIG #ifndef SWIG
@ -494,25 +511,20 @@ struct aiAnimMesh {
float mWeight; float mWeight;
#ifdef __cplusplus #ifdef __cplusplus
/// @brief The class constructor.
aiAnimMesh() AI_NO_EXCEPT aiAnimMesh() AI_NO_EXCEPT :
: mVertices(nullptr), mVertices(nullptr),
mNormals(nullptr), mNormals(nullptr),
mTangents(nullptr), mTangents(nullptr),
mBitangents(nullptr), mBitangents(nullptr),
mColors(), mColors {nullptr},
mTextureCoords(), mTextureCoords{nullptr},
mNumVertices(0), mNumVertices(0),
mWeight(0.0f) { mWeight(0.0f) {
// fixme consider moving this to the ctor initializer list as well // empty
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
mTextureCoords[a] = nullptr;
}
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) {
mColors[a] = nullptr;
}
} }
/// @brief The class destructor.
~aiAnimMesh() { ~aiAnimMesh() {
delete[] mVertices; delete[] mVertices;
delete[] mNormals; delete[] mNormals;
@ -526,35 +538,51 @@ struct aiAnimMesh {
} }
} }
/** Check whether the anim mesh overrides the vertex positions /**
* of its host mesh*/ * @brief Check whether the anim-mesh overrides the vertex positions
* of its host mesh.
* @return true if positions are stored, false if not.
*/
bool HasPositions() const { bool HasPositions() const {
return mVertices != nullptr; return mVertices != nullptr;
} }
/** Check whether the anim mesh overrides the vertex normals /**
* of its host mesh*/ * @brief Check whether the anim-mesh overrides the vertex normals
* of its host mesh
* @return true if normals are stored, false if not.
*/
bool HasNormals() const { bool HasNormals() const {
return mNormals != nullptr; return mNormals != nullptr;
} }
/** Check whether the anim mesh overrides the vertex tangents /**
* @brief Check whether the anim-mesh overrides the vertex tangents
* and bitangents of its host mesh. As for aiMesh, * and bitangents of its host mesh. As for aiMesh,
* tangents and bitangents always go together. */ * tangents and bitangents always go together.
* @return true if tangents and bi-tangents are stored, false if not.
*/
bool HasTangentsAndBitangents() const { bool HasTangentsAndBitangents() const {
return mTangents != nullptr; return mTangents != nullptr;
} }
/** Check whether the anim mesh overrides a particular /**
* @brief Check whether the anim mesh overrides a particular
* set of vertex colors on his host mesh. * set of vertex colors on his host mesh.
* @param pIndex 0<index<AI_MAX_NUMBER_OF_COLOR_SETS */ * @param pIndex 0<index<AI_MAX_NUMBER_OF_COLOR_SETS
* @return true if vertex colors are stored, false if not.
*/
bool HasVertexColors(unsigned int pIndex) const { bool HasVertexColors(unsigned int pIndex) const {
return pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS ? false : mColors[pIndex] != nullptr; return pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS ? false : mColors[pIndex] != nullptr;
} }
/** Check whether the anim mesh overrides a particular /**
* @brief Check whether the anim mesh overrides a particular
* set of texture coordinates on his host mesh. * set of texture coordinates on his host mesh.
* @param pIndex 0<index<AI_MAX_NUMBER_OF_TEXTURECOORDS */ * @param pIndex 0<index<AI_MAX_NUMBER_OF_TEXTURECOORDS
* @return true if texture coordinates are stored, false if not.
*/
bool HasTextureCoords(unsigned int pIndex) const { bool HasTextureCoords(unsigned int pIndex) const {
return pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? false : mTextureCoords[pIndex] != nullptr; return pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? false : mTextureCoords[pIndex] != nullptr;
} }
@ -606,26 +634,31 @@ enum aiMorphingMethod {
* @endcode * @endcode
*/ */
struct aiMesh { struct aiMesh {
/** Bitwise combination of the members of the #aiPrimitiveType enum. /**
* Bitwise combination of the members of the #aiPrimitiveType enum.
* This specifies which types of primitives are present in the mesh. * This specifies which types of primitives are present in the mesh.
* The "SortByPrimitiveType"-Step can be used to make sure the * The "SortByPrimitiveType"-Step can be used to make sure the
* output meshes consist of one primitive type each. * output meshes consist of one primitive type each.
*/ */
unsigned int mPrimitiveTypes; unsigned int mPrimitiveTypes;
/** The number of vertices in this mesh. /**
* The number of vertices in this mesh.
* This is also the size of all of the per-vertex data arrays. * This is also the size of all of the per-vertex data arrays.
* The maximum value for this member is #AI_MAX_VERTICES. * The maximum value for this member is #AI_MAX_VERTICES.
*/ */
unsigned int mNumVertices; unsigned int mNumVertices;
/** The number of primitives (triangles, polygons, lines) in this mesh. /**
* The number of primitives (triangles, polygons, lines) in this mesh.
* This is also the size of the mFaces array. * This is also the size of the mFaces array.
* The maximum value for this member is #AI_MAX_FACES. * The maximum value for this member is #AI_MAX_FACES.
*/ */
unsigned int mNumFaces; unsigned int mNumFaces;
/** Vertex positions. /**
* @brief Vertex positions.
*
* This array is always present in a mesh. The array is * This array is always present in a mesh. The array is
* mNumVertices in size. * mNumVertices in size.
*/ */
@ -655,7 +688,9 @@ struct aiMesh {
*/ */
C_STRUCT aiVector3D *mNormals; C_STRUCT aiVector3D *mNormals;
/** Vertex tangents. /**
* @brief Vertex tangents.
*
* The tangent of a vertex points in the direction of the positive * The tangent of a vertex points in the direction of the positive
* X texture axis. The array contains normalized vectors, nullptr if * X texture axis. The array contains normalized vectors, nullptr if
* not present. The array is mNumVertices in size. A mesh consisting * not present. The array is mNumVertices in size. A mesh consisting
@ -669,7 +704,9 @@ struct aiMesh {
*/ */
C_STRUCT aiVector3D *mTangents; C_STRUCT aiVector3D *mTangents;
/** Vertex bitangents. /**
* @brief Vertex bitangents.
*
* The bitangent of a vertex points in the direction of the positive * The bitangent of a vertex points in the direction of the positive
* Y texture axis. The array contains normalized vectors, nullptr if not * Y texture axis. The array contains normalized vectors, nullptr if not
* present. The array is mNumVertices in size. * present. The array is mNumVertices in size.
@ -678,20 +715,26 @@ struct aiMesh {
*/ */
C_STRUCT aiVector3D *mBitangents; C_STRUCT aiVector3D *mBitangents;
/** Vertex color sets. /**
* @brief Vertex color sets.
*
* A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex * A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex
* colors per vertex. nullptr if not present. Each array is * colors per vertex. nullptr if not present. Each array is
* mNumVertices in size if present. * mNumVertices in size if present.
*/ */
C_STRUCT aiColor4D *mColors[AI_MAX_NUMBER_OF_COLOR_SETS]; C_STRUCT aiColor4D *mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
/** Vertex texture coordinates, also known as UV channels. /**
* @brief Vertex texture coordinates, also known as UV channels.
*
* A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per * A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
* vertex. nullptr if not present. The array is mNumVertices in size. * vertex. nullptr if not present. The array is mNumVertices in size.
*/ */
C_STRUCT aiVector3D *mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS]; C_STRUCT aiVector3D *mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
/** Specifies the number of components for a given UV channel. /**
* @brief Specifies the number of components for a given UV channel.
*
* Up to three channels are supported (UVW, for accessing volume * Up to three channels are supported (UVW, for accessing volume
* or cube maps). If the value is 2 for a given channel n, the * or cube maps). If the value is 2 for a given channel n, the
* component p.z of mTextureCoords[n][p] is set to 0.0f. * component p.z of mTextureCoords[n][p] is set to 0.0f.
@ -700,7 +743,9 @@ struct aiMesh {
*/ */
unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS]; unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS];
/** The faces the mesh is constructed from. /**
* @brief The faces the mesh is constructed from.
*
* Each face refers to a number of vertices by their indices. * Each face refers to a number of vertices by their indices.
* This array is always present in a mesh, its size is given * This array is always present in a mesh, its size is given
* in mNumFaces. If the #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT * in mNumFaces. If the #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
@ -708,25 +753,30 @@ struct aiMesh {
*/ */
C_STRUCT aiFace *mFaces; C_STRUCT aiFace *mFaces;
/** The number of bones this mesh contains. /**
* Can be 0, in which case the mBones array is nullptr. * The number of bones this mesh contains. Can be 0, in which case the mBones array is nullptr.
*/ */
unsigned int mNumBones; unsigned int mNumBones;
/** The bones of this mesh. /**
* @brief The bones of this mesh.
*
* A bone consists of a name by which it can be found in the * A bone consists of a name by which it can be found in the
* frame hierarchy and a set of vertex weights. * frame hierarchy and a set of vertex weights.
*/ */
C_STRUCT aiBone **mBones; C_STRUCT aiBone **mBones;
/** The material used by this mesh. /**
* @brief The material used by this mesh.
*
* A mesh uses only a single material. If an imported model uses * A mesh uses only a single material. If an imported model uses
* multiple materials, the import splits up the mesh. Use this value * multiple materials, the import splits up the mesh. Use this value
* as index into the scene's material list. * as index into the scene's material list.
*/ */
unsigned int mMaterialIndex; unsigned int mMaterialIndex;
/** Name of the mesh. Meshes can be named, but this is not a /**
* Name of the mesh. Meshes can be named, but this is not a
* requirement and leaving this field empty is totally fine. * requirement and leaving this field empty is totally fine.
* There are mainly three uses for mesh names: * There are mainly three uses for mesh names:
* - some formats name nodes and meshes independently. * - some formats name nodes and meshes independently.
@ -736,17 +786,19 @@ struct aiMesh {
* aids the caller at recovering the original mesh * aids the caller at recovering the original mesh
* partitioning. * partitioning.
* - Vertex animations refer to meshes by their names. * - Vertex animations refer to meshes by their names.
**/ */
C_STRUCT aiString mName; C_STRUCT aiString mName;
/** The number of attachment meshes. /**
* The number of attachment meshes.
* Currently known to work with loaders: * Currently known to work with loaders:
* - Collada * - Collada
* - gltf * - gltf
*/ */
unsigned int mNumAnimMeshes; unsigned int mNumAnimMeshes;
/** Attachment meshes for this mesh, for vertex-based animation. /**
* Attachment meshes for this mesh, for vertex-based animation.
* Attachment meshes carry replacement data for some of the * Attachment meshes carry replacement data for some of the
* mesh'es vertex components (usually positions, normals). * mesh'es vertex components (usually positions, normals).
* Currently known to work with loaders: * Currently known to work with loaders:
@ -766,7 +818,8 @@ struct aiMesh {
*/ */
C_STRUCT aiAABB mAABB; C_STRUCT aiAABB mAABB;
/** Vertex UV stream names. Pointer to array of size AI_MAX_NUMBER_OF_TEXTURECOORDS /**
* Vertex UV stream names. Pointer to array of size AI_MAX_NUMBER_OF_TEXTURECOORDS
*/ */
C_STRUCT aiString **mTextureCoordsNames; C_STRUCT aiString **mTextureCoordsNames;
@ -781,9 +834,9 @@ struct aiMesh {
mNormals(nullptr), mNormals(nullptr),
mTangents(nullptr), mTangents(nullptr),
mBitangents(nullptr), mBitangents(nullptr),
mColors(), mColors{nullptr},
mTextureCoords(), mTextureCoords{nullptr},
mNumUVComponents(), mNumUVComponents{0},
mFaces(nullptr), mFaces(nullptr),
mNumBones(0), mNumBones(0),
mBones(nullptr), mBones(nullptr),
@ -793,17 +846,10 @@ struct aiMesh {
mMethod(aiMorphingMethod_UNKNOWN), mMethod(aiMorphingMethod_UNKNOWN),
mAABB(), mAABB(),
mTextureCoordsNames(nullptr) { mTextureCoordsNames(nullptr) {
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) { // empty
mNumUVComponents[a] = 0;
mTextureCoords[a] = nullptr;
} }
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) { //! @brief The class destructor.
mColors[a] = nullptr;
}
}
//! Deletes all storage allocated for the mesh
~aiMesh() { ~aiMesh() {
delete[] mVertices; delete[] mVertices;
delete[] mNormals; delete[] mNormals;
@ -844,44 +890,58 @@ struct aiMesh {
delete[] mFaces; delete[] mFaces;
} }
//! Check whether the mesh contains positions. Provided no special //! @brief Check whether the mesh contains positions. Provided no special
//! scene flags are set, this will always be true //! scene flags are set, this will always be true
bool HasPositions() const { return mVertices != nullptr && mNumVertices > 0; } //! @return true, if positions are stored, false if not.
bool HasPositions() const {
return mVertices != nullptr && mNumVertices > 0;
}
//! Check whether the mesh contains faces. If no special scene flags //! @brief Check whether the mesh contains faces. If no special scene flags
//! are set this should always return true //! are set this should always return true
bool HasFaces() const { return mFaces != nullptr && mNumFaces > 0; } //! @return true, if faces are stored, false if not.
bool HasFaces() const {
return mFaces != nullptr && mNumFaces > 0;
}
//! Check whether the mesh contains normal vectors //! @brief Check whether the mesh contains normal vectors
bool HasNormals() const { return mNormals != nullptr && mNumVertices > 0; } //! @return true, if normals are stored, false if not.
bool HasNormals() const {
return mNormals != nullptr && mNumVertices > 0;
}
//! Check whether the mesh contains tangent and bitangent vectors //! @brief Check whether the mesh contains tangent and bitangent vectors.
//!
//! It is not possible that it contains tangents and no bitangents //! It is not possible that it contains tangents and no bitangents
//! (or the other way round). The existence of one of them //! (or the other way round). The existence of one of them
//! implies that the second is there, too. //! implies that the second is there, too.
bool HasTangentsAndBitangents() const { return mTangents != nullptr && mBitangents != nullptr && mNumVertices > 0; } //! @return true, if tangents and bi-tangents are stored, false if not.
bool HasTangentsAndBitangents() const {
return mTangents != nullptr && mBitangents != nullptr && mNumVertices > 0;
}
//! Check whether the mesh contains a vertex color set //! @brief Check whether the mesh contains a vertex color set
//! \param pIndex Index of the vertex color set //! @param index Index of the vertex color set
bool HasVertexColors(unsigned int pIndex) const { //! @return true, if vertex colors are stored, false if not.
if (pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS) { bool HasVertexColors(unsigned int index) const {
if (index >= AI_MAX_NUMBER_OF_COLOR_SETS) {
return false; return false;
} else {
return mColors[pIndex] != nullptr && mNumVertices > 0;
} }
return mColors[index] != nullptr && mNumVertices > 0;
} }
//! Check whether the mesh contains a texture coordinate set //! @brief Check whether the mesh contains a texture coordinate set
//! \param pIndex Index of the texture coordinates set //! @param index Index of the texture coordinates set
bool HasTextureCoords(unsigned int pIndex) const { //! @return true, if texture coordinates are stored, false if not.
if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) { bool HasTextureCoords(unsigned int index) const {
if (index >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
return false; return false;
} else {
return mTextureCoords[pIndex] != nullptr && mNumVertices > 0;
} }
return (mTextureCoords[index] != nullptr && mNumVertices > 0);
} }
//! Get the number of UV channels the mesh contains //! @brief Get the number of UV channels the mesh contains.
//! @return the number of stored uv-channels.
unsigned int GetNumUVChannels() const { unsigned int GetNumUVChannels() const {
unsigned int n(0); unsigned int n(0);
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n]) { while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n]) {
@ -891,7 +951,8 @@ struct aiMesh {
return n; return n;
} }
//! Get the number of vertex color channels the mesh contains //! @brief Get the number of vertex color channels the mesh contains.
//! @return The number of stored color channels.
unsigned int GetNumColorChannels() const { unsigned int GetNumColorChannels() const {
unsigned int n(0); unsigned int n(0);
while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n]) { while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n]) {
@ -900,13 +961,15 @@ struct aiMesh {
return n; return n;
} }
//! Check whether the mesh contains bones //! @brief Check whether the mesh contains bones.
//! @return true, if bones are stored.
bool HasBones() const { bool HasBones() const {
return mBones != nullptr && mNumBones > 0; return mBones != nullptr && mNumBones > 0;
} }
//! Check whether the mesh contains a texture coordinate set name //! @brief Check whether the mesh contains a texture coordinate set name
//! \param pIndex Index of the texture coordinates set //! @param pIndex Index of the texture coordinates set
//! @return true, if texture coordinates for the index exists.
bool HasTextureCoordsName(unsigned int pIndex) const { bool HasTextureCoordsName(unsigned int pIndex) const {
if (mTextureCoordsNames == nullptr || pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) { if (mTextureCoordsNames == nullptr || pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
return false; return false;
@ -914,9 +977,9 @@ struct aiMesh {
return mTextureCoordsNames[pIndex] != nullptr; return mTextureCoordsNames[pIndex] != nullptr;
} }
//! Set a texture coordinate set name //! @brief Set a texture coordinate set name
//! \param pIndex Index of the texture coordinates set //! @param pIndex Index of the texture coordinates set
//! \param texCoordsName name of the texture coordinate set //! @param texCoordsName name of the texture coordinate set
void SetTextureCoordsName(unsigned int pIndex, const aiString &texCoordsName) { void SetTextureCoordsName(unsigned int pIndex, const aiString &texCoordsName) {
if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) { if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
return; return;
@ -941,21 +1004,22 @@ struct aiMesh {
*mTextureCoordsNames[pIndex] = texCoordsName; *mTextureCoordsNames[pIndex] = texCoordsName;
} }
//! Get a texture coordinate set name //! @brief Get a texture coordinate set name
//! \param pIndex Index of the texture coordinates set //! @param pIndex Index of the texture coordinates set
const aiString *GetTextureCoordsName(unsigned int pIndex) const { //! @return The texture coordinate name.
if (mTextureCoordsNames == nullptr || pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) { const aiString *GetTextureCoordsName(unsigned int index) const {
if (mTextureCoordsNames == nullptr || index >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
return nullptr; return nullptr;
} }
return mTextureCoordsNames[pIndex]; return mTextureCoordsNames[index];
} }
#endif // __cplusplus #endif // __cplusplus
}; };
/** /**
* @brief A skeleton bone represents a single bone in a aiSkeleton instance. * @brief A skeleton bone represents a single bone is a skeleton structure.
* *
* Skeleton-Animations can be represented via a skeleton struct, which describes * Skeleton-Animations can be represented via a skeleton struct, which describes
* a hierarchical tree assembled from skeleton bones. A bone is linked to a mesh. * a hierarchical tree assembled from skeleton bones. A bone is linked to a mesh.
@ -1025,6 +1089,21 @@ struct aiSkeletonBone {
// empty // empty
} }
/// @brief The class constructor with its parent
/// @param parent The parent node index.
aiSkeletonBone(unsigned int parent) :
mParent(parent),
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
mArmature(nullptr),
mNode(nullptr),
#endif
mNumnWeights(0),
mMeshId(nullptr),
mWeights(nullptr),
mOffsetMatrix(),
mLocalMatrix() {
// empty
}
/// @brief The class destructor. /// @brief The class destructor.
~aiSkeletonBone() { ~aiSkeletonBone() {
delete[] mWeights; delete[] mWeights;
@ -1081,4 +1160,6 @@ struct aiSkeleton {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif //! extern "C" #endif //! extern "C"
#endif // AI_MESH_H_INC #endif // AI_MESH_H_INC