2015-05-19 04:16:51 +00:00
|
|
|
/*
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2022-01-10 20:13:43 +00:00
|
|
|
Copyright (c) 2006-2022, assimp team
|
2018-01-28 18:42:05 +00:00
|
|
|
|
2015-05-19 04:16:51 +00:00
|
|
|
All rights reserved.
|
|
|
|
|
2015-05-19 04:17:45 +00:00
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the following
|
2015-05-19 04:16:51 +00:00
|
|
|
conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
|
|
|
|
|
|
|
* Neither the name of the assimp team, nor the names of its
|
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
|
|
|
written permission of the assimp team.
|
|
|
|
|
2015-05-19 04:17:45 +00:00
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
2015-05-19 04:16:51 +00:00
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
2015-05-19 04:17:45 +00:00
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
2015-05-19 04:16:51 +00:00
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
2015-05-19 04:17:45 +00:00
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
2015-05-19 04:16:51 +00:00
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
2015-05-19 04:17:45 +00:00
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
2015-05-19 04:16:51 +00:00
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file mesh.h
|
2015-05-19 04:17:45 +00:00
|
|
|
* @brief Declares the data structures in which the imported geometry is
|
2015-05-19 04:16:51 +00:00
|
|
|
returned by ASSIMP: aiMesh, aiFace and aiBone data structures.
|
|
|
|
*/
|
2016-07-11 18:56:38 +00:00
|
|
|
#pragma once
|
|
|
|
#ifndef AI_MESH_H_INC
|
|
|
|
#define AI_MESH_H_INC
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2019-10-11 11:27:36 +00:00
|
|
|
#ifdef __GNUC__
|
2020-03-19 14:10:46 +00:00
|
|
|
#pragma GCC system_header
|
2019-10-11 11:27:36 +00:00
|
|
|
#endif
|
|
|
|
|
2020-12-01 20:35:14 +00:00
|
|
|
#ifdef _MSC_VER
|
2020-03-19 14:10:46 +00:00
|
|
|
#pragma warning(disable : 4351)
|
2020-12-01 20:35:14 +00:00
|
|
|
#endif // _MSC_VER
|
2020-03-19 14:10:46 +00:00
|
|
|
|
2019-06-23 18:24:32 +00:00
|
|
|
#include <assimp/aabb.h>
|
2020-03-19 14:10:46 +00:00
|
|
|
#include <assimp/types.h>
|
2015-05-19 04:16:51 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
2015-05-19 04:17:45 +00:00
|
|
|
// Limits. These values are required to match the settings Assimp was
|
2017-04-11 20:33:13 +00:00
|
|
|
// compiled against. Therefore, do not redefine them unless you build the
|
2015-05-19 04:16:51 +00:00
|
|
|
// library from source using the same definitions.
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/** @def AI_MAX_FACE_INDICES
|
|
|
|
* Maximum number of indices per face (polygon). */
|
|
|
|
|
2015-05-19 04:17:45 +00:00
|
|
|
#ifndef AI_MAX_FACE_INDICES
|
2020-03-19 14:10:46 +00:00
|
|
|
#define AI_MAX_FACE_INDICES 0x7fff
|
2015-05-19 04:16:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @def AI_MAX_BONE_WEIGHTS
|
|
|
|
* Maximum number of indices per face (polygon). */
|
|
|
|
|
|
|
|
#ifndef AI_MAX_BONE_WEIGHTS
|
2020-03-19 14:10:46 +00:00
|
|
|
#define AI_MAX_BONE_WEIGHTS 0x7fffffff
|
2015-05-19 04:16:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @def AI_MAX_VERTICES
|
|
|
|
* Maximum number of vertices per mesh. */
|
|
|
|
|
|
|
|
#ifndef AI_MAX_VERTICES
|
2020-03-19 14:10:46 +00:00
|
|
|
#define AI_MAX_VERTICES 0x7fffffff
|
2015-05-19 04:16:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @def AI_MAX_FACES
|
|
|
|
* Maximum number of faces per mesh. */
|
|
|
|
|
|
|
|
#ifndef AI_MAX_FACES
|
2020-03-19 14:10:46 +00:00
|
|
|
#define AI_MAX_FACES 0x7fffffff
|
2015-05-19 04:16:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @def AI_MAX_NUMBER_OF_COLOR_SETS
|
|
|
|
* Supported number of vertex color sets per mesh. */
|
|
|
|
|
|
|
|
#ifndef AI_MAX_NUMBER_OF_COLOR_SETS
|
2020-03-19 14:10:46 +00:00
|
|
|
#define AI_MAX_NUMBER_OF_COLOR_SETS 0x8
|
2015-05-19 04:16:51 +00:00
|
|
|
#endif // !! AI_MAX_NUMBER_OF_COLOR_SETS
|
|
|
|
|
|
|
|
/** @def AI_MAX_NUMBER_OF_TEXTURECOORDS
|
|
|
|
* Supported number of texture coord sets (UV(W) channels) per mesh */
|
|
|
|
|
|
|
|
#ifndef AI_MAX_NUMBER_OF_TEXTURECOORDS
|
2020-03-19 14:10:46 +00:00
|
|
|
#define AI_MAX_NUMBER_OF_TEXTURECOORDS 0x8
|
2015-05-19 04:16:51 +00:00
|
|
|
#endif // !! AI_MAX_NUMBER_OF_TEXTURECOORDS
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
2015-05-19 04:17:45 +00:00
|
|
|
/** @brief A single face in a mesh, referring to multiple vertices.
|
2015-05-19 04:16:51 +00:00
|
|
|
*
|
2015-05-19 04:17:45 +00:00
|
|
|
* If mNumIndices is 3, we call the face 'triangle', for mNumIndices > 3
|
2015-05-19 04:16:51 +00:00
|
|
|
* it's called 'polygon' (hey, that's just a definition!).
|
|
|
|
* <br>
|
|
|
|
* aiMesh::mPrimitiveTypes can be queried to quickly examine which types of
|
2015-05-19 04:17:45 +00:00
|
|
|
* primitive are actually present in a mesh. The #aiProcess_SortByPType flag
|
2015-05-19 04:16:51 +00:00
|
|
|
* executes a special post-processing algorithm which splits meshes with
|
|
|
|
* *different* primitive types mixed up (e.g. lines and triangles) in several
|
2022-04-05 18:07:22 +00:00
|
|
|
* 'clean' sub-meshes. Furthermore there is a configuration option (
|
2015-05-19 04:17:45 +00:00
|
|
|
* #AI_CONFIG_PP_SBP_REMOVE) to force #aiProcess_SortByPType to remove
|
2015-05-19 04:16:51 +00:00
|
|
|
* specific kinds of primitives from the imported scene, completely and forever.
|
2015-05-19 04:17:45 +00:00
|
|
|
* In many cases you'll probably want to set this setting to
|
|
|
|
* @code
|
2015-05-19 04:16:51 +00:00
|
|
|
* aiPrimitiveType_LINE|aiPrimitiveType_POINT
|
|
|
|
* @endcode
|
|
|
|
* Together with the #aiProcess_Triangulate flag you can then be sure that
|
2015-05-19 04:17:45 +00:00
|
|
|
* #aiFace::mNumIndices is always 3.
|
2015-05-19 04:16:51 +00:00
|
|
|
* @note Take a look at the @link data Data Structures page @endlink for
|
|
|
|
* more information on the layout and winding order of a face.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
struct aiFace {
|
2015-05-19 04:18:29 +00:00
|
|
|
//! Number of indices defining this face.
|
|
|
|
//! The maximum value for this member is #AI_MAX_FACE_INDICES.
|
|
|
|
unsigned int mNumIndices;
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2015-05-19 04:18:29 +00:00
|
|
|
//! Pointer to the indices array. Size of the array is given in numIndices.
|
2020-03-19 14:10:46 +00:00
|
|
|
unsigned int *mIndices;
|
2015-05-19 04:16:51 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2015-05-19 04:18:29 +00:00
|
|
|
//! Default constructor
|
2018-09-21 14:25:27 +00:00
|
|
|
aiFace() AI_NO_EXCEPT
|
2020-03-19 14:10:46 +00:00
|
|
|
: mNumIndices(0),
|
|
|
|
mIndices(nullptr) {
|
2018-09-21 14:07:09 +00:00
|
|
|
// empty
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2015-05-19 04:18:29 +00:00
|
|
|
//! Default destructor. Delete the index array
|
2020-03-19 14:10:46 +00:00
|
|
|
~aiFace() {
|
|
|
|
delete[] mIndices;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2015-05-19 04:18:29 +00:00
|
|
|
//! Copy constructor. Copy the index array
|
2020-03-19 14:10:46 +00:00
|
|
|
aiFace(const aiFace &o) :
|
|
|
|
mNumIndices(0), mIndices(nullptr) {
|
2015-05-19 04:18:29 +00:00
|
|
|
*this = o;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Assignment operator. Copy the index array
|
2020-03-19 14:10:46 +00:00
|
|
|
aiFace &operator=(const aiFace &o) {
|
2018-09-21 14:07:09 +00:00
|
|
|
if (&o == this) {
|
2015-05-19 04:18:29 +00:00
|
|
|
return *this;
|
2018-09-21 14:07:09 +00:00
|
|
|
}
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
delete[] mIndices;
|
|
|
|
mNumIndices = o.mNumIndices;
|
|
|
|
if (mNumIndices) {
|
|
|
|
mIndices = new unsigned int[mNumIndices];
|
2020-03-19 14:10:46 +00:00
|
|
|
::memcpy(mIndices, o.mIndices, mNumIndices * sizeof(unsigned int));
|
2018-09-21 14:07:09 +00:00
|
|
|
} else {
|
|
|
|
mIndices = nullptr;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
2018-09-21 14:07:09 +00:00
|
|
|
|
2015-05-19 04:18:29 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Comparison operator. Checks whether the index array
|
|
|
|
//! of two faces is identical
|
2020-03-19 14:10:46 +00:00
|
|
|
bool operator==(const aiFace &o) const {
|
2018-09-21 14:07:09 +00:00
|
|
|
if (mIndices == o.mIndices) {
|
2015-05-19 04:18:29 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-09-21 14:07:09 +00:00
|
|
|
|
|
|
|
if (nullptr != mIndices && mNumIndices != o.mNumIndices) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nullptr == mIndices) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < this->mNumIndices; ++i) {
|
|
|
|
if (mIndices[i] != o.mIndices[i]) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Inverse comparison operator. Checks whether the index
|
|
|
|
//! array of two faces is NOT identical
|
2020-03-19 14:10:46 +00:00
|
|
|
bool operator!=(const aiFace &o) const {
|
2015-05-19 04:18:29 +00:00
|
|
|
return !(*this == o);
|
|
|
|
}
|
2015-05-19 04:16:51 +00:00
|
|
|
#endif // __cplusplus
|
|
|
|
}; // struct aiFace
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** @brief A single influence of a bone on a vertex.
|
|
|
|
*/
|
2018-02-12 20:45:47 +00:00
|
|
|
struct aiVertexWeight {
|
2015-05-19 04:18:29 +00:00
|
|
|
//! Index of the vertex which is influenced by the bone.
|
|
|
|
unsigned int mVertexId;
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2015-05-19 04:18:29 +00:00
|
|
|
//! The strength of the influence in the range (0...1).
|
|
|
|
//! The influence from all bones at one vertex amounts to 1.
|
2020-03-14 10:16:44 +00:00
|
|
|
ai_real mWeight;
|
2015-05-19 04:16:51 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2015-05-19 04:18:29 +00:00
|
|
|
//! Default constructor
|
2018-09-21 14:25:27 +00:00
|
|
|
aiVertexWeight() AI_NO_EXCEPT
|
2020-03-19 14:10:46 +00:00
|
|
|
: mVertexId(0),
|
|
|
|
mWeight(0.0f) {
|
2018-02-12 20:45:47 +00:00
|
|
|
// empty
|
|
|
|
}
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2018-09-21 14:07:09 +00:00
|
|
|
//! Initialization from a given index and vertex weight factor
|
2015-05-19 04:18:29 +00:00
|
|
|
//! \param pID ID
|
|
|
|
//! \param pWeight Vertex weight factor
|
2020-03-19 14:10:46 +00:00
|
|
|
aiVertexWeight(unsigned int pID, float pWeight) :
|
|
|
|
mVertexId(pID), mWeight(pWeight) {
|
2018-02-12 20:45:47 +00:00
|
|
|
// empty
|
|
|
|
}
|
|
|
|
|
2020-03-19 14:10:46 +00:00
|
|
|
bool operator==(const aiVertexWeight &rhs) const {
|
|
|
|
return (mVertexId == rhs.mVertexId && mWeight == rhs.mWeight);
|
2018-02-12 20:45:47 +00:00
|
|
|
}
|
|
|
|
|
2020-03-19 14:10:46 +00:00
|
|
|
bool operator!=(const aiVertexWeight &rhs) const {
|
|
|
|
return (*this == rhs);
|
2018-02-12 20:45:47 +00:00
|
|
|
}
|
2015-05-19 04:16:51 +00:00
|
|
|
|
|
|
|
#endif // __cplusplus
|
|
|
|
};
|
|
|
|
|
2019-10-26 15:28:51 +00:00
|
|
|
// Forward declare aiNode (pointer use only)
|
|
|
|
struct aiNode;
|
|
|
|
|
2015-05-19 04:16:51 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** @brief A single bone of a mesh.
|
|
|
|
*
|
|
|
|
* A bone has a name by which it can be found in the frame hierarchy and by
|
2015-05-19 04:17:45 +00:00
|
|
|
* which it can be addressed by animations. In addition it has a number of
|
2018-02-19 10:34:26 +00:00
|
|
|
* influences on vertices, and a matrix relating the mesh position to the
|
|
|
|
* position of the bone at the time of binding.
|
2015-05-19 04:16:51 +00:00
|
|
|
*/
|
2018-02-12 20:45:47 +00:00
|
|
|
struct aiBone {
|
2015-05-19 04:18:29 +00:00
|
|
|
//! The name of the bone.
|
|
|
|
C_STRUCT aiString mName;
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2018-02-19 10:34:26 +00:00
|
|
|
//! The number of vertices affected by this bone.
|
2015-05-19 04:18:29 +00:00
|
|
|
//! The maximum value for this member is #AI_MAX_BONE_WEIGHTS.
|
|
|
|
unsigned int mNumWeights;
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2019-10-26 18:48:34 +00:00
|
|
|
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
|
2022-04-05 18:07:22 +00:00
|
|
|
/// The bone armature node - used for skeleton conversion
|
|
|
|
/// you must enable aiProcess_PopulateArmatureData to populate this
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiNode *mArmature;
|
2019-10-26 15:28:51 +00:00
|
|
|
|
2022-04-05 18:07:22 +00:00
|
|
|
/// The bone node in the scene - used for skeleton conversion
|
|
|
|
/// you must enable aiProcess_PopulateArmatureData to populate this
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiNode *mNode;
|
2019-10-26 15:28:51 +00:00
|
|
|
|
2019-10-26 18:48:34 +00:00
|
|
|
#endif
|
2018-02-19 10:34:26 +00:00
|
|
|
//! The influence weights of this bone, by vertex index.
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiVertexWeight *mWeights;
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2018-02-19 10:34:26 +00:00
|
|
|
/** Matrix that transforms from bone space to mesh space in bind pose.
|
|
|
|
*
|
|
|
|
* This matrix describes the position of the mesh
|
|
|
|
* in the local space of this bone when the skeleton was bound.
|
|
|
|
* Thus it can be used directly to determine a desired vertex position,
|
|
|
|
* given the world-space transform of the bone when animated,
|
|
|
|
* and the position of the vertex in mesh space.
|
|
|
|
*
|
|
|
|
* It is sometimes called an inverse-bind matrix,
|
|
|
|
* or inverse bind pose matrix.
|
|
|
|
*/
|
2015-05-19 04:18:29 +00:00
|
|
|
C_STRUCT aiMatrix4x4 mOffsetMatrix;
|
2015-05-19 04:16:51 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2022-04-05 18:07:22 +00:00
|
|
|
/// @brief Default constructor
|
2018-09-21 14:25:27 +00:00
|
|
|
aiBone() AI_NO_EXCEPT
|
2020-03-19 14:10:46 +00:00
|
|
|
: mName(),
|
|
|
|
mNumWeights(0),
|
2021-11-10 08:19:29 +00:00
|
|
|
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
|
|
|
|
mArmature(nullptr),
|
|
|
|
mNode(nullptr),
|
|
|
|
#endif
|
2020-03-19 14:10:46 +00:00
|
|
|
mWeights(nullptr),
|
|
|
|
mOffsetMatrix() {
|
2018-02-12 20:45:47 +00:00
|
|
|
// empty
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2022-04-05 18:07:22 +00:00
|
|
|
/// @brief Copy constructor
|
2020-03-19 14:10:46 +00:00
|
|
|
aiBone(const aiBone &other) :
|
2020-04-29 18:43:23 +00:00
|
|
|
mName(other.mName),
|
|
|
|
mNumWeights(other.mNumWeights),
|
2021-11-10 08:19:29 +00:00
|
|
|
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
|
|
|
|
mArmature(nullptr),
|
|
|
|
mNode(nullptr),
|
|
|
|
#endif
|
2020-04-29 18:43:23 +00:00
|
|
|
mWeights(nullptr),
|
|
|
|
mOffsetMatrix(other.mOffsetMatrix) {
|
2022-04-05 18:07:22 +00:00
|
|
|
copyVertexWeights(other);
|
|
|
|
}
|
|
|
|
|
|
|
|
void copyVertexWeights( const aiBone &other ) {
|
|
|
|
if (other.mWeights == nullptr || other.mNumWeights == 0) {
|
|
|
|
mWeights = nullptr;
|
|
|
|
mNumWeights = 0;
|
|
|
|
return;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
2022-04-05 18:07:22 +00:00
|
|
|
|
|
|
|
mNumWeights = other.mNumWeights;
|
|
|
|
if (mWeights) {
|
|
|
|
delete[] mWeights;
|
|
|
|
}
|
|
|
|
|
|
|
|
mWeights = new aiVertexWeight[mNumWeights];
|
|
|
|
::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight));
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
2018-02-03 14:24:45 +00:00
|
|
|
//! Assignment operator
|
2022-04-05 18:07:22 +00:00
|
|
|
aiBone &operator = (const aiBone &other) {
|
2018-02-03 14:24:45 +00:00
|
|
|
if (this == &other) {
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-03-19 14:10:46 +00:00
|
|
|
mName = other.mName;
|
|
|
|
mNumWeights = other.mNumWeights;
|
2018-02-03 14:24:45 +00:00
|
|
|
mOffsetMatrix = other.mOffsetMatrix;
|
2022-04-05 18:07:22 +00:00
|
|
|
copyVertexWeights(other);
|
2018-02-03 14:24:45 +00:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-03-19 14:10:46 +00:00
|
|
|
bool operator==(const aiBone &rhs) const {
|
2022-04-05 18:07:22 +00:00
|
|
|
if (mName != rhs.mName || mNumWeights != rhs.mNumWeights ) {
|
2018-02-12 20:45:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
2018-02-03 14:24:45 +00:00
|
|
|
|
2020-03-19 14:10:46 +00:00
|
|
|
for (size_t i = 0; i < mNumWeights; ++i) {
|
|
|
|
if (mWeights[i] != rhs.mWeights[i]) {
|
2018-02-12 20:45:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-05-19 04:18:29 +00:00
|
|
|
//! Destructor - deletes the array of vertex weights
|
2018-09-21 14:07:09 +00:00
|
|
|
~aiBone() {
|
2020-03-19 14:10:46 +00:00
|
|
|
delete[] mWeights;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
2015-05-19 04:16:51 +00:00
|
|
|
#endif // __cplusplus
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** @brief Enumerates the types of geometric primitives supported by Assimp.
|
2015-05-19 04:17:45 +00:00
|
|
|
*
|
2015-05-19 04:16:51 +00:00
|
|
|
* @see aiFace Face data structure
|
|
|
|
* @see aiProcess_SortByPType Per-primitive sorting of meshes
|
|
|
|
* @see aiProcess_Triangulate Automatic triangulation
|
|
|
|
* @see AI_CONFIG_PP_SBP_REMOVE Removal of specific primitive types.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
enum aiPrimitiveType {
|
2015-05-19 04:18:29 +00:00
|
|
|
/** A point primitive.
|
|
|
|
*
|
|
|
|
* This is just a single vertex in the virtual world,
|
|
|
|
* #aiFace contains just one index for such a primitive.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
aiPrimitiveType_POINT = 0x1,
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** A line primitive.
|
|
|
|
*
|
|
|
|
* This is a line defined through a start and an end position.
|
|
|
|
* #aiFace contains exactly two indices for such a primitive.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
aiPrimitiveType_LINE = 0x2,
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** A triangular primitive.
|
|
|
|
*
|
|
|
|
* A triangle consists of three indices.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
aiPrimitiveType_TRIANGLE = 0x4,
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** A higher-level polygon with more than 3 edges.
|
|
|
|
*
|
|
|
|
* A triangle is a polygon, but polygon in this context means
|
|
|
|
* "all polygons that are not triangles". The "Triangulate"-Step
|
|
|
|
* is provided for your convenience, it splits all polygons in
|
|
|
|
* triangles (which are much easier to handle).
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
aiPrimitiveType_POLYGON = 0x8,
|
2015-05-19 04:18:29 +00:00
|
|
|
|
2021-03-29 17:03:01 +00:00
|
|
|
/**
|
|
|
|
* A flag to determine whether this triangles only mesh is NGON encoded.
|
2021-07-29 11:28:51 +00:00
|
|
|
*
|
2021-03-29 17:03:01 +00:00
|
|
|
* 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.
|
|
|
|
* 2 consecutive triangles with the same 1st vertex index are part of the same
|
|
|
|
* NGON.
|
2021-07-29 11:28:51 +00:00
|
|
|
*
|
|
|
|
* At the moment, only quads (concave or convex) are supported, meaning that polygons are 'seen' as
|
2021-03-29 17:03:01 +00:00
|
|
|
* triangles, as usual after a triangulation pass.
|
2021-07-29 11:28:51 +00:00
|
|
|
*
|
2021-03-29 17:03:01 +00:00
|
|
|
* To get an NGON encoded mesh, please use the aiProcess_Triangulate post process.
|
2021-07-29 11:28:51 +00:00
|
|
|
*
|
2021-03-29 17:03:01 +00:00
|
|
|
* @see aiProcess_Triangulate
|
|
|
|
* @link https://github.com/KhronosGroup/glTF/pull/1620
|
|
|
|
*/
|
2021-03-30 18:24:03 +00:00
|
|
|
aiPrimitiveType_NGONEncodingFlag = 0x10,
|
2021-03-29 17:03:01 +00:00
|
|
|
|
2020-03-19 14:10:46 +00:00
|
|
|
/** This value is not used. It is just here to force the
|
2015-05-19 04:18:29 +00:00
|
|
|
* compiler to map this enum to a 32 Bit integer.
|
|
|
|
*/
|
2015-05-19 04:16:51 +00:00
|
|
|
#ifndef SWIG
|
2015-05-19 04:18:29 +00:00
|
|
|
_aiPrimitiveType_Force32Bit = INT_MAX
|
2015-05-19 04:16:51 +00:00
|
|
|
#endif
|
|
|
|
}; //! enum aiPrimitiveType
|
|
|
|
|
|
|
|
// Get the #aiPrimitiveType flag for a specific number of face indices
|
|
|
|
#define AI_PRIMITIVE_TYPE_FOR_N_INDICES(n) \
|
2015-05-19 04:18:29 +00:00
|
|
|
((n) > 3 ? aiPrimitiveType_POLYGON : (aiPrimitiveType)(1u << ((n)-1)))
|
2015-05-19 04:16:51 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
2019-01-06 18:37:30 +00:00
|
|
|
/** @brief An AnimMesh is an attachment to an #aiMesh stores per-vertex
|
2015-05-19 04:16:51 +00:00
|
|
|
* animations for a particular frame.
|
2015-05-19 04:17:45 +00:00
|
|
|
*
|
2015-05-19 04:16:51 +00:00
|
|
|
* You may think of an #aiAnimMesh as a `patch` for the host mesh, which
|
2015-05-19 04:17:45 +00:00
|
|
|
* replaces only certain vertex data streams at a particular time.
|
2015-05-19 04:16:51 +00:00
|
|
|
* Each mesh stores n attached attached meshes (#aiMesh::mAnimMeshes).
|
2015-05-19 04:17:45 +00:00
|
|
|
* The actual relationship between the time line and anim meshes is
|
2015-05-19 04:16:51 +00:00
|
|
|
* established by #aiMeshAnim, which references singular mesh attachments
|
|
|
|
* by their ID and binds them to a time offset.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
struct aiAnimMesh {
|
2019-01-06 18:37:30 +00:00
|
|
|
/**Anim Mesh name */
|
|
|
|
C_STRUCT aiString mName;
|
|
|
|
|
2019-10-27 11:29:56 +00:00
|
|
|
/** Replacement for aiMesh::mVertices. If this array is non-nullptr,
|
2015-05-19 04:18:29 +00:00
|
|
|
* it *must* contain mNumVertices entries. The corresponding
|
2019-10-27 11:29:56 +00:00
|
|
|
* array in the host mesh must be non-nullptr as well - animation
|
2015-05-19 04:18:29 +00:00
|
|
|
* meshes may neither add or nor remove vertex components (if
|
2019-10-27 11:29:56 +00:00
|
|
|
* a replacement array is nullptr and the corresponding source
|
2015-05-19 04:18:29 +00:00
|
|
|
* array is not, the source data is taken instead)*/
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiVector3D *mVertices;
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** Replacement for aiMesh::mNormals. */
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiVector3D *mNormals;
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** Replacement for aiMesh::mTangents. */
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiVector3D *mTangents;
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** Replacement for aiMesh::mBitangents. */
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiVector3D *mBitangents;
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** Replacement for aiMesh::mColors */
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiColor4D *mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** Replacement for aiMesh::mTextureCoords */
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiVector3D *mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** The number of vertices in the aiAnimMesh, and thus the length of all
|
|
|
|
* the member arrays.
|
|
|
|
*
|
|
|
|
* This has always the same value as the mNumVertices property in the
|
|
|
|
* corresponding aiMesh. It is duplicated here merely to make the length
|
|
|
|
* of the member arrays accessible even if the aiMesh is not known, e.g.
|
|
|
|
* from language bindings.
|
|
|
|
*/
|
|
|
|
unsigned int mNumVertices;
|
2020-03-19 14:10:46 +00:00
|
|
|
|
2020-12-01 20:35:14 +00:00
|
|
|
/**
|
|
|
|
* Weight of the AnimMesh.
|
2017-05-06 09:04:40 +00:00
|
|
|
*/
|
2017-01-12 11:41:32 +00:00
|
|
|
float mWeight;
|
|
|
|
|
2015-05-19 04:16:51 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2018-09-21 14:25:27 +00:00
|
|
|
aiAnimMesh() AI_NO_EXCEPT
|
2020-03-19 14:10:46 +00:00
|
|
|
: mVertices(nullptr),
|
|
|
|
mNormals(nullptr),
|
|
|
|
mTangents(nullptr),
|
|
|
|
mBitangents(nullptr),
|
|
|
|
mColors(),
|
|
|
|
mTextureCoords(),
|
|
|
|
mNumVertices(0),
|
|
|
|
mWeight(0.0f) {
|
2015-05-19 04:18:29 +00:00
|
|
|
// fixme consider moving this to the ctor initializer list as well
|
2020-03-19 14:10:46 +00:00
|
|
|
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
|
2019-02-25 21:06:24 +00:00
|
|
|
mTextureCoords[a] = nullptr;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
2020-03-19 14:10:46 +00:00
|
|
|
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) {
|
2019-02-25 21:06:24 +00:00
|
|
|
mColors[a] = nullptr;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-19 14:10:46 +00:00
|
|
|
~aiAnimMesh() {
|
|
|
|
delete[] mVertices;
|
|
|
|
delete[] mNormals;
|
|
|
|
delete[] mTangents;
|
|
|
|
delete[] mBitangents;
|
|
|
|
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
|
|
|
|
delete[] mTextureCoords[a];
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
2020-03-19 14:10:46 +00:00
|
|
|
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) {
|
|
|
|
delete[] mColors[a];
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Check whether the anim mesh overrides the vertex positions
|
|
|
|
* of its host mesh*/
|
|
|
|
bool HasPositions() const {
|
2019-02-25 21:06:24 +00:00
|
|
|
return mVertices != nullptr;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Check whether the anim mesh overrides the vertex normals
|
|
|
|
* of its host mesh*/
|
|
|
|
bool HasNormals() const {
|
2019-02-25 21:06:24 +00:00
|
|
|
return mNormals != nullptr;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Check whether the anim mesh overrides the vertex tangents
|
|
|
|
* and bitangents of its host mesh. As for aiMesh,
|
|
|
|
* tangents and bitangents always go together. */
|
|
|
|
bool HasTangentsAndBitangents() const {
|
2019-02-25 21:06:24 +00:00
|
|
|
return mTangents != nullptr;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Check whether the anim mesh overrides a particular
|
|
|
|
* set of vertex colors on his host mesh.
|
|
|
|
* @param pIndex 0<index<AI_MAX_NUMBER_OF_COLOR_SETS */
|
2020-03-19 14:10:46 +00:00
|
|
|
bool HasVertexColors(unsigned int pIndex) const {
|
2019-02-25 21:06:24 +00:00
|
|
|
return pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS ? false : mColors[pIndex] != nullptr;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Check whether the anim mesh overrides a particular
|
|
|
|
* set of texture coordinates on his host mesh.
|
|
|
|
* @param pIndex 0<index<AI_MAX_NUMBER_OF_TEXTURECOORDS */
|
2020-03-19 14:10:46 +00:00
|
|
|
bool HasTextureCoords(unsigned int pIndex) const {
|
2019-02-25 21:06:24 +00:00
|
|
|
return pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? false : mTextureCoords[pIndex] != nullptr;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
2015-05-19 04:16:51 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2017-01-12 11:41:32 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/** @brief Enumerates the methods of mesh morphing supported by Assimp.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
enum aiMorphingMethod {
|
2017-01-12 11:41:32 +00:00
|
|
|
/** Interpolation between morph targets */
|
2020-03-19 14:10:46 +00:00
|
|
|
aiMorphingMethod_VERTEX_BLEND = 0x1,
|
2017-01-12 11:41:32 +00:00
|
|
|
|
|
|
|
/** Normalized morphing between morph targets */
|
2020-03-19 14:10:46 +00:00
|
|
|
aiMorphingMethod_MORPH_NORMALIZED = 0x2,
|
2017-01-12 11:41:32 +00:00
|
|
|
|
|
|
|
/** Relative morphing between morph targets */
|
2020-03-19 14:10:46 +00:00
|
|
|
aiMorphingMethod_MORPH_RELATIVE = 0x3,
|
2017-01-12 11:41:32 +00:00
|
|
|
|
2020-03-19 14:10:46 +00:00
|
|
|
/** This value is not used. It is just here to force the
|
2017-01-12 11:41:32 +00:00
|
|
|
* compiler to map this enum to a 32 Bit integer.
|
|
|
|
*/
|
|
|
|
#ifndef SWIG
|
|
|
|
_aiMorphingMethod_Force32Bit = INT_MAX
|
|
|
|
#endif
|
|
|
|
}; //! enum aiMorphingMethod
|
2015-05-19 04:16:51 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
2015-05-19 04:17:45 +00:00
|
|
|
/** @brief A mesh represents a geometry or model with a single material.
|
2015-05-19 04:16:51 +00:00
|
|
|
*
|
2015-05-19 04:17:45 +00:00
|
|
|
* It usually consists of a number of vertices and a series of primitives/faces
|
|
|
|
* referencing the vertices. In addition there might be a series of bones, each
|
|
|
|
* of them addressing a number of vertices with a certain weight. Vertex data
|
|
|
|
* is presented in channels with each channel containing a single per-vertex
|
2021-09-13 20:38:20 +00:00
|
|
|
* information such as a set of texture coordinates or a normal vector.
|
2015-05-19 04:16:51 +00:00
|
|
|
* If a data pointer is non-null, the corresponding data stream is present.
|
|
|
|
* From C++-programs you can also use the comfort functions Has*() to
|
|
|
|
* test for the presence of various data streams.
|
|
|
|
*
|
|
|
|
* A Mesh uses only a single material which is referenced by a material ID.
|
2015-05-19 04:17:45 +00:00
|
|
|
* @note The mPositions member is usually not optional. However, vertex positions
|
|
|
|
* *could* be missing if the #AI_SCENE_FLAGS_INCOMPLETE flag is set in
|
2015-05-19 04:16:51 +00:00
|
|
|
* @code
|
|
|
|
* aiScene::mFlags
|
|
|
|
* @endcode
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
struct aiMesh {
|
2015-05-19 04:18:29 +00:00
|
|
|
/** Bitwise combination of the members of the #aiPrimitiveType enum.
|
|
|
|
* This specifies which types of primitives are present in the mesh.
|
|
|
|
* The "SortByPrimitiveType"-Step can be used to make sure the
|
|
|
|
* output meshes consist of one primitive type each.
|
|
|
|
*/
|
|
|
|
unsigned int mPrimitiveTypes;
|
|
|
|
|
|
|
|
/** The number of vertices in this mesh.
|
|
|
|
* This is also the size of all of the per-vertex data arrays.
|
|
|
|
* The maximum value for this member is #AI_MAX_VERTICES.
|
|
|
|
*/
|
|
|
|
unsigned int mNumVertices;
|
|
|
|
|
|
|
|
/** The number of primitives (triangles, polygons, lines) in this mesh.
|
|
|
|
* This is also the size of the mFaces array.
|
|
|
|
* The maximum value for this member is #AI_MAX_FACES.
|
|
|
|
*/
|
|
|
|
unsigned int mNumFaces;
|
|
|
|
|
|
|
|
/** Vertex positions.
|
|
|
|
* This array is always present in a mesh. The array is
|
|
|
|
* mNumVertices in size.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiVector3D *mVertices;
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** Vertex normals.
|
2019-10-27 11:29:56 +00:00
|
|
|
* The array contains normalized vectors, nullptr if not present.
|
2015-05-19 04:18:29 +00:00
|
|
|
* The array is mNumVertices in size. Normals are undefined for
|
|
|
|
* point and line primitives. A mesh consisting of points and
|
|
|
|
* lines only may not have normal vectors. Meshes with mixed
|
|
|
|
* primitive types (i.e. lines and triangles) may have normals,
|
|
|
|
* but the normals for vertices that are only referenced by
|
|
|
|
* point or line primitives are undefined and set to QNaN (WARN:
|
|
|
|
* qNaN compares to inequal to *everything*, even to qNaN itself.
|
|
|
|
* Using code like this to check whether a field is qnan is:
|
|
|
|
* @code
|
|
|
|
* #define IS_QNAN(f) (f != f)
|
|
|
|
* @endcode
|
|
|
|
* still dangerous because even 1.f == 1.f could evaluate to false! (
|
|
|
|
* remember the subtleties of IEEE754 artithmetics). Use stuff like
|
|
|
|
* @c fpclassify instead.
|
|
|
|
* @note Normal vectors computed by Assimp are always unit-length.
|
|
|
|
* However, this needn't apply for normals that have been taken
|
|
|
|
* directly from the model file.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiVector3D *mNormals;
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** Vertex tangents.
|
|
|
|
* The tangent of a vertex points in the direction of the positive
|
2019-10-27 11:29:56 +00:00
|
|
|
* X texture axis. The array contains normalized vectors, nullptr if
|
2015-05-19 04:18:29 +00:00
|
|
|
* not present. The array is mNumVertices in size. A mesh consisting
|
|
|
|
* of points and lines only may not have normal vectors. Meshes with
|
|
|
|
* mixed primitive types (i.e. lines and triangles) may have
|
|
|
|
* normals, but the normals for vertices that are only referenced by
|
|
|
|
* point or line primitives are undefined and set to qNaN. See
|
2016-04-03 00:38:00 +00:00
|
|
|
* the #mNormals member for a detailed discussion of qNaNs.
|
2015-05-19 04:18:29 +00:00
|
|
|
* @note If the mesh contains tangents, it automatically also
|
|
|
|
* contains bitangents.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiVector3D *mTangents;
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** Vertex bitangents.
|
|
|
|
* The bitangent of a vertex points in the direction of the positive
|
2019-10-27 11:29:56 +00:00
|
|
|
* Y texture axis. The array contains normalized vectors, nullptr if not
|
2015-05-19 04:18:29 +00:00
|
|
|
* present. The array is mNumVertices in size.
|
|
|
|
* @note If the mesh contains tangents, it automatically also contains
|
|
|
|
* bitangents.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiVector3D *mBitangents;
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** Vertex color sets.
|
|
|
|
* A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex
|
2019-10-27 11:29:56 +00:00
|
|
|
* colors per vertex. nullptr if not present. Each array is
|
2015-05-19 04:18:29 +00:00
|
|
|
* mNumVertices in size if present.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiColor4D *mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
|
2015-05-19 04:18:29 +00:00
|
|
|
|
2021-09-13 20:38:20 +00:00
|
|
|
/** Vertex texture coordinates, also known as UV channels.
|
2015-05-19 04:18:29 +00:00
|
|
|
* A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
|
2019-10-27 11:29:56 +00:00
|
|
|
* vertex. nullptr if not present. The array is mNumVertices in size.
|
2015-05-19 04:18:29 +00:00
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiVector3D *mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** Specifies the number of components for a given UV channel.
|
|
|
|
* Up to three channels are supported (UVW, for accessing volume
|
|
|
|
* 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.
|
|
|
|
* If the value is 1 for a given channel, p.y is set to 0.0f, too.
|
2021-09-13 20:38:20 +00:00
|
|
|
* @note 4D coordinates are not supported
|
2015-05-19 04:18:29 +00:00
|
|
|
*/
|
|
|
|
unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
|
|
|
|
|
|
|
/** The faces the mesh is constructed from.
|
|
|
|
* Each face refers to a number of vertices by their indices.
|
|
|
|
* This array is always present in a mesh, its size is given
|
|
|
|
* in mNumFaces. If the #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
|
|
|
|
* is NOT set each face references an unique set of vertices.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiFace *mFaces;
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** The number of bones this mesh contains.
|
2019-10-27 11:29:56 +00:00
|
|
|
* Can be 0, in which case the mBones array is nullptr.
|
2015-05-19 04:18:29 +00:00
|
|
|
*/
|
|
|
|
unsigned int mNumBones;
|
|
|
|
|
|
|
|
/** The bones of this mesh.
|
|
|
|
* A bone consists of a name by which it can be found in the
|
|
|
|
* frame hierarchy and a set of vertex weights.
|
|
|
|
*/
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiBone **mBones;
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
/** The material used by this mesh.
|
2015-12-14 06:12:25 +00:00
|
|
|
* A mesh uses only a single material. If an imported model uses
|
2015-05-19 04:18:29 +00:00
|
|
|
* multiple materials, the import splits up the mesh. Use this value
|
|
|
|
* as index into the scene's material list.
|
|
|
|
*/
|
|
|
|
unsigned int mMaterialIndex;
|
|
|
|
|
|
|
|
/** Name of the mesh. Meshes can be named, but this is not a
|
|
|
|
* requirement and leaving this field empty is totally fine.
|
|
|
|
* There are mainly three uses for mesh names:
|
|
|
|
* - some formats name nodes and meshes independently.
|
|
|
|
* - importers tend to split meshes up to meet the
|
|
|
|
* one-material-per-mesh requirement. Assigning
|
|
|
|
* the same (dummy) name to each of the result meshes
|
|
|
|
* aids the caller at recovering the original mesh
|
|
|
|
* partitioning.
|
|
|
|
* - Vertex animations refer to meshes by their names.
|
|
|
|
**/
|
|
|
|
C_STRUCT aiString mName;
|
|
|
|
|
2017-01-12 11:41:32 +00:00
|
|
|
/** The number of attachment meshes. Note! Currently only works with Collada loader. */
|
2015-05-19 04:18:29 +00:00
|
|
|
unsigned int mNumAnimMeshes;
|
|
|
|
|
2017-01-12 11:41:32 +00:00
|
|
|
/** Attachment meshes for this mesh, for vertex-based animation.
|
2015-05-19 04:18:29 +00:00
|
|
|
* Attachment meshes carry replacement data for some of the
|
2017-01-12 11:41:32 +00:00
|
|
|
* mesh'es vertex components (usually positions, normals).
|
|
|
|
* Note! Currently only works with Collada loader.*/
|
2020-03-19 14:10:46 +00:00
|
|
|
C_STRUCT aiAnimMesh **mAnimMeshes;
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2020-12-01 20:35:14 +00:00
|
|
|
/**
|
2021-09-13 20:38:20 +00:00
|
|
|
* Method of morphing when anim-meshes are specified.
|
2022-01-04 16:32:18 +00:00
|
|
|
* @see aiMorphingMethod to learn more about the provided morphing targets.
|
2017-05-06 09:08:57 +00:00
|
|
|
*/
|
2017-01-12 11:41:32 +00:00
|
|
|
unsigned int mMethod;
|
2019-06-23 18:24:32 +00:00
|
|
|
|
|
|
|
/**
|
2021-09-13 20:38:20 +00:00
|
|
|
* The bounding box.
|
2019-06-23 18:24:32 +00:00
|
|
|
*/
|
|
|
|
C_STRUCT aiAABB mAABB;
|
2020-03-19 14:10:46 +00:00
|
|
|
|
2021-11-09 13:03:06 +00:00
|
|
|
/** Vertex UV stream names. Pointer to array of size AI_MAX_NUMBER_OF_TEXTURECOORDS
|
|
|
|
*/
|
|
|
|
C_STRUCT aiString **mTextureCoordsNames;
|
|
|
|
|
2015-05-19 04:16:51 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2015-05-19 04:18:29 +00:00
|
|
|
//! Default constructor. Initializes all members to 0
|
2018-09-21 14:25:27 +00:00
|
|
|
aiMesh() AI_NO_EXCEPT
|
2020-03-19 14:10:46 +00:00
|
|
|
: mPrimitiveTypes(0),
|
|
|
|
mNumVertices(0),
|
|
|
|
mNumFaces(0),
|
|
|
|
mVertices(nullptr),
|
|
|
|
mNormals(nullptr),
|
|
|
|
mTangents(nullptr),
|
|
|
|
mBitangents(nullptr),
|
|
|
|
mColors(),
|
|
|
|
mTextureCoords(),
|
|
|
|
mNumUVComponents(),
|
|
|
|
mFaces(nullptr),
|
|
|
|
mNumBones(0),
|
|
|
|
mBones(nullptr),
|
|
|
|
mMaterialIndex(0),
|
|
|
|
mNumAnimMeshes(0),
|
|
|
|
mAnimMeshes(nullptr),
|
|
|
|
mMethod(0),
|
2021-11-09 13:03:06 +00:00
|
|
|
mAABB(),
|
|
|
|
mTextureCoordsNames(nullptr) {
|
2020-03-19 14:10:46 +00:00
|
|
|
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
|
2015-05-19 04:18:29 +00:00
|
|
|
mNumUVComponents[a] = 0;
|
2018-09-21 14:07:09 +00:00
|
|
|
mTextureCoords[a] = nullptr;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
2018-09-21 14:07:09 +00:00
|
|
|
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) {
|
|
|
|
mColors[a] = nullptr;
|
|
|
|
}
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Deletes all storage allocated for the mesh
|
2018-09-21 14:07:09 +00:00
|
|
|
~aiMesh() {
|
2020-03-19 14:10:46 +00:00
|
|
|
delete[] mVertices;
|
|
|
|
delete[] mNormals;
|
|
|
|
delete[] mTangents;
|
|
|
|
delete[] mBitangents;
|
|
|
|
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
|
|
|
|
delete[] mTextureCoords[a];
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
2021-11-09 13:03:06 +00:00
|
|
|
|
|
|
|
if (mTextureCoordsNames) {
|
|
|
|
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
|
|
|
|
delete mTextureCoordsNames[a];
|
|
|
|
}
|
|
|
|
delete[] mTextureCoordsNames;
|
|
|
|
}
|
|
|
|
|
2020-03-19 14:10:46 +00:00
|
|
|
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) {
|
|
|
|
delete[] mColors[a];
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DO NOT REMOVE THIS ADDITIONAL CHECK
|
2020-03-19 14:10:46 +00:00
|
|
|
if (mNumBones && mBones) {
|
|
|
|
for (unsigned int a = 0; a < mNumBones; a++) {
|
|
|
|
if (mBones[a]) {
|
2019-10-26 15:28:51 +00:00
|
|
|
delete mBones[a];
|
|
|
|
}
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
2020-03-19 14:10:46 +00:00
|
|
|
delete[] mBones;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
2020-03-19 14:10:46 +00:00
|
|
|
if (mNumAnimMeshes && mAnimMeshes) {
|
|
|
|
for (unsigned int a = 0; a < mNumAnimMeshes; a++) {
|
2015-05-19 04:18:29 +00:00
|
|
|
delete mAnimMeshes[a];
|
|
|
|
}
|
2020-03-19 14:10:46 +00:00
|
|
|
delete[] mAnimMeshes;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
2020-03-19 14:10:46 +00:00
|
|
|
delete[] mFaces;
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Check whether the mesh contains positions. Provided no special
|
|
|
|
//! scene flags are set, this will always be true
|
2020-03-19 14:10:46 +00:00
|
|
|
bool HasPositions() const { return mVertices != nullptr && mNumVertices > 0; }
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
//! Check whether the mesh contains faces. If no special scene flags
|
|
|
|
//! are set this should always return true
|
2020-03-19 14:10:46 +00:00
|
|
|
bool HasFaces() const { return mFaces != nullptr && mNumFaces > 0; }
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
//! Check whether the mesh contains normal vectors
|
2020-03-19 14:10:46 +00:00
|
|
|
bool HasNormals() const { return mNormals != nullptr && mNumVertices > 0; }
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
//! Check whether the mesh contains tangent and bitangent vectors
|
|
|
|
//! It is not possible that it contains tangents and no bitangents
|
|
|
|
//! (or the other way round). The existence of one of them
|
|
|
|
//! implies that the second is there, too.
|
2020-03-19 14:10:46 +00:00
|
|
|
bool HasTangentsAndBitangents() const { return mTangents != nullptr && mBitangents != nullptr && mNumVertices > 0; }
|
2015-05-19 04:18:29 +00:00
|
|
|
|
|
|
|
//! Check whether the mesh contains a vertex color set
|
|
|
|
//! \param pIndex Index of the vertex color set
|
2020-03-19 14:10:46 +00:00
|
|
|
bool HasVertexColors(unsigned int pIndex) const {
|
2018-09-21 14:07:09 +00:00
|
|
|
if (pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS) {
|
2015-05-19 04:18:29 +00:00
|
|
|
return false;
|
2018-09-21 14:07:09 +00:00
|
|
|
} else {
|
|
|
|
return mColors[pIndex] != nullptr && mNumVertices > 0;
|
|
|
|
}
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Check whether the mesh contains a texture coordinate set
|
|
|
|
//! \param pIndex Index of the texture coordinates set
|
2020-03-19 14:10:46 +00:00
|
|
|
bool HasTextureCoords(unsigned int pIndex) const {
|
2018-09-21 14:07:09 +00:00
|
|
|
if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
2015-05-19 04:18:29 +00:00
|
|
|
return false;
|
2018-09-21 14:07:09 +00:00
|
|
|
} else {
|
|
|
|
return mTextureCoords[pIndex] != nullptr && mNumVertices > 0;
|
|
|
|
}
|
2015-05-19 04:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Get the number of UV channels the mesh contains
|
2018-09-21 14:07:09 +00:00
|
|
|
unsigned int GetNumUVChannels() const {
|
2020-03-19 14:10:46 +00:00
|
|
|
unsigned int n(0);
|
2018-09-21 14:07:09 +00:00
|
|
|
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n]) {
|
|
|
|
++n;
|
|
|
|
}
|
|
|
|
|
2015-05-19 04:18:29 +00:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Get the number of vertex color channels the mesh contains
|
2018-09-21 14:07:09 +00:00
|
|
|
unsigned int GetNumColorChannels() const {
|
|
|
|
unsigned int n(0);
|
|
|
|
while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n]) {
|
|
|
|
++n;
|
|
|
|
}
|
2015-05-19 04:18:29 +00:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Check whether the mesh contains bones
|
2018-09-21 14:07:09 +00:00
|
|
|
bool HasBones() const {
|
|
|
|
return mBones != nullptr && mNumBones > 0;
|
|
|
|
}
|
2015-05-19 04:16:51 +00:00
|
|
|
|
2021-11-09 13:03:06 +00:00
|
|
|
//! Check whether the mesh contains a texture coordinate set name
|
|
|
|
//! \param pIndex Index of the texture coordinates set
|
|
|
|
bool HasTextureCoordsName(unsigned int pIndex) const {
|
|
|
|
if (mTextureCoordsNames == nullptr || pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return mTextureCoordsNames[pIndex] != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Set a texture coordinate set name
|
|
|
|
//! \param pIndex Index of the texture coordinates set
|
|
|
|
//! \param texCoordsName name of the texture coordinate set
|
|
|
|
void SetTextureCoordsName(unsigned int pIndex, const aiString &texCoordsName) {
|
|
|
|
if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mTextureCoordsNames == nullptr) {
|
|
|
|
// Construct and null-init array
|
|
|
|
mTextureCoordsNames = new aiString *[AI_MAX_NUMBER_OF_TEXTURECOORDS] {};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (texCoordsName.length == 0) {
|
|
|
|
delete mTextureCoordsNames[pIndex];
|
|
|
|
mTextureCoordsNames[pIndex] = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mTextureCoordsNames[pIndex] == nullptr) {
|
|
|
|
mTextureCoordsNames[pIndex] = new aiString(texCoordsName);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
*mTextureCoordsNames[pIndex] = texCoordsName;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Get a texture coordinate set name
|
|
|
|
//! \param pIndex Index of the texture coordinates set
|
|
|
|
const aiString *GetTextureCoordsName(unsigned int pIndex) const {
|
|
|
|
if (mTextureCoordsNames == nullptr || pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mTextureCoordsNames[pIndex];
|
|
|
|
}
|
|
|
|
|
2015-05-19 04:16:51 +00:00
|
|
|
#endif // __cplusplus
|
|
|
|
};
|
|
|
|
|
2022-04-05 18:07:22 +00:00
|
|
|
struct aiSkeletonBone {
|
|
|
|
/// The parent bone index, is -1 one if this bone represents the root bone.
|
|
|
|
int mParent;
|
|
|
|
|
|
|
|
#ifndef ASSIMP_BUILD_NO_ARMATUREPOPULATE_PROCESS
|
|
|
|
/// The bone armature node - used for skeleton conversion
|
|
|
|
/// you must enable aiProcess_PopulateArmatureData to populate this
|
|
|
|
C_STRUCT aiNode *mArmature;
|
|
|
|
|
|
|
|
/// The bone node in the scene - used for skeleton conversion
|
|
|
|
/// you must enable aiProcess_PopulateArmatureData to populate this
|
|
|
|
C_STRUCT aiNode *mNode;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
/// @brief The number of weights
|
|
|
|
unsigned int mNumnWeights;
|
|
|
|
|
|
|
|
/// The influence weights of this bone, by vertex index.
|
|
|
|
C_STRUCT aiVertexWeight *mWeights;
|
|
|
|
|
|
|
|
/** Matrix that transforms from bone space to mesh space in bind pose.
|
|
|
|
*
|
|
|
|
* This matrix describes the position of the mesh
|
|
|
|
* in the local space of this bone when the skeleton was bound.
|
|
|
|
* Thus it can be used directly to determine a desired vertex position,
|
|
|
|
* given the world-space transform of the bone when animated,
|
|
|
|
* and the position of the vertex in mesh space.
|
|
|
|
*
|
|
|
|
* It is sometimes called an inverse-bind matrix,
|
|
|
|
* or inverse bind pose matrix.
|
|
|
|
*/
|
|
|
|
C_STRUCT aiMatrix4x4 mOffsetMatrix;
|
|
|
|
|
|
|
|
/// Matrix that transforms the locale bone in bind pose.
|
|
|
|
C_STRUCT aiMatrix4x4 mLocalMatrix;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
aiSkeletonBone() :
|
|
|
|
mParent(-1),
|
|
|
|
mArmature(nullptr),
|
|
|
|
mNode(nullptr),
|
|
|
|
mNumnWeights(0),
|
|
|
|
mWeights(nullptr),
|
|
|
|
mOffsetMatrix(),
|
|
|
|
mLocalMatrix() {
|
|
|
|
// empty
|
|
|
|
}
|
|
|
|
|
|
|
|
~aiSkeletonBone() {
|
|
|
|
delete[] mWeights;
|
|
|
|
mWeights = nullptr;
|
|
|
|
}
|
|
|
|
#endif // __cplusplus
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @brief
|
|
|
|
*/
|
2022-02-15 23:18:32 +00:00
|
|
|
struct aiSkeleton {
|
2022-04-05 18:07:22 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2022-02-15 23:18:32 +00:00
|
|
|
C_STRUCT aiString mName;
|
2022-04-05 18:07:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
unsigned int mNumBones;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
C_STRUCT aiSkeletonBone *mBones;
|
2022-02-15 23:18:32 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2022-04-05 18:07:22 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
aiSkeleton() AI_NO_EXCEPT : mName(), mNumBones(0), mBones(nullptr) {
|
2022-02-15 23:18:32 +00:00
|
|
|
// empty
|
|
|
|
}
|
|
|
|
|
2022-04-05 18:07:22 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
~aiSkeleton() {
|
|
|
|
delete[] mBones;
|
2022-02-15 23:18:32 +00:00
|
|
|
}
|
|
|
|
#endif // __cplusplus
|
|
|
|
};
|
2015-05-19 04:16:51 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif //! extern "C"
|
2016-07-11 18:56:38 +00:00
|
|
|
#endif // AI_MESH_H_INC
|