vrshoot

diff libs/assimp/assimp/mesh.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/assimp/assimp/mesh.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,740 @@
     1.4 +/*
     1.5 +---------------------------------------------------------------------------
     1.6 +Open Asset Import Library (assimp)
     1.7 +---------------------------------------------------------------------------
     1.8 +
     1.9 +Copyright (c) 2006-2012, assimp team
    1.10 +
    1.11 +All rights reserved.
    1.12 +
    1.13 +Redistribution and use of this software in source and binary forms, 
    1.14 +with or without modification, are permitted provided that the following 
    1.15 +conditions are met:
    1.16 +
    1.17 +* Redistributions of source code must retain the above
    1.18 +  copyright notice, this list of conditions and the
    1.19 +  following disclaimer.
    1.20 +
    1.21 +* Redistributions in binary form must reproduce the above
    1.22 +  copyright notice, this list of conditions and the
    1.23 +  following disclaimer in the documentation and/or other
    1.24 +  materials provided with the distribution.
    1.25 +
    1.26 +* Neither the name of the assimp team, nor the names of its
    1.27 +  contributors may be used to endorse or promote products
    1.28 +  derived from this software without specific prior
    1.29 +  written permission of the assimp team.
    1.30 +
    1.31 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    1.32 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    1.33 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.34 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    1.35 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.36 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    1.37 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.38 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    1.39 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    1.40 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    1.41 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.42 +---------------------------------------------------------------------------
    1.43 +*/
    1.44 +
    1.45 +/** @file mesh.h
    1.46 + *  @brief Declares the data structures in which the imported geometry is 
    1.47 +    returned by ASSIMP: aiMesh, aiFace and aiBone data structures.
    1.48 + */
    1.49 +#ifndef INCLUDED_AI_MESH_H
    1.50 +#define INCLUDED_AI_MESH_H
    1.51 +
    1.52 +#include "types.h"
    1.53 +
    1.54 +#ifdef __cplusplus
    1.55 +extern "C" {
    1.56 +#endif
    1.57 +
    1.58 +// ---------------------------------------------------------------------------
    1.59 +// Limits. These values are required to match the settings Assimp was 
    1.60 +// compiled against. Therfore, do not redefine them unless you build the 
    1.61 +// library from source using the same definitions.
    1.62 +// ---------------------------------------------------------------------------
    1.63 +
    1.64 +/** @def AI_MAX_FACE_INDICES
    1.65 + *  Maximum number of indices per face (polygon). */
    1.66 +
    1.67 +#ifndef AI_MAX_FACE_INDICES 
    1.68 +#	define AI_MAX_FACE_INDICES 0x7fff
    1.69 +#endif
    1.70 +
    1.71 +/** @def AI_MAX_BONE_WEIGHTS
    1.72 + *  Maximum number of indices per face (polygon). */
    1.73 +
    1.74 +#ifndef AI_MAX_BONE_WEIGHTS
    1.75 +#	define AI_MAX_BONE_WEIGHTS 0x7fffffff
    1.76 +#endif
    1.77 +
    1.78 +/** @def AI_MAX_VERTICES
    1.79 + *  Maximum number of vertices per mesh.  */
    1.80 +
    1.81 +#ifndef AI_MAX_VERTICES
    1.82 +#	define AI_MAX_VERTICES 0x7fffffff
    1.83 +#endif
    1.84 +
    1.85 +/** @def AI_MAX_FACES
    1.86 + *  Maximum number of faces per mesh. */
    1.87 +
    1.88 +#ifndef AI_MAX_FACES
    1.89 +#	define AI_MAX_FACES 0x7fffffff
    1.90 +#endif
    1.91 +
    1.92 +/** @def AI_MAX_NUMBER_OF_COLOR_SETS
    1.93 + *  Supported number of vertex color sets per mesh. */
    1.94 +
    1.95 +#ifndef AI_MAX_NUMBER_OF_COLOR_SETS
    1.96 +#	define AI_MAX_NUMBER_OF_COLOR_SETS 0x8
    1.97 +#endif // !! AI_MAX_NUMBER_OF_COLOR_SETS
    1.98 +
    1.99 +/** @def AI_MAX_NUMBER_OF_TEXTURECOORDS
   1.100 + *  Supported number of texture coord sets (UV(W) channels) per mesh */
   1.101 +
   1.102 +#ifndef AI_MAX_NUMBER_OF_TEXTURECOORDS
   1.103 +#	define AI_MAX_NUMBER_OF_TEXTURECOORDS 0x8
   1.104 +#endif // !! AI_MAX_NUMBER_OF_TEXTURECOORDS
   1.105 +
   1.106 +// ---------------------------------------------------------------------------
   1.107 +/** @brief A single face in a mesh, referring to multiple vertices. 
   1.108 + *
   1.109 + * If mNumIndices is 3, we call the face 'triangle', for mNumIndices > 3 
   1.110 + * it's called 'polygon' (hey, that's just a definition!).
   1.111 + * <br>
   1.112 + * aiMesh::mPrimitiveTypes can be queried to quickly examine which types of
   1.113 + * primitive are actually present in a mesh. The #aiProcess_SortByPType flag 
   1.114 + * executes a special post-processing algorithm which splits meshes with
   1.115 + * *different* primitive types mixed up (e.g. lines and triangles) in several
   1.116 + * 'clean' submeshes. Furthermore there is a configuration option (
   1.117 + * #AI_CONFIG_PP_SBP_REMOVE) to force #aiProcess_SortByPType to remove 
   1.118 + * specific kinds of primitives from the imported scene, completely and forever.
   1.119 + * In many cases you'll probably want to set this setting to 
   1.120 + * @code 
   1.121 + * aiPrimitiveType_LINE|aiPrimitiveType_POINT
   1.122 + * @endcode
   1.123 + * Together with the #aiProcess_Triangulate flag you can then be sure that
   1.124 + * #aiFace::mNumIndices is always 3. 
   1.125 + * @note Take a look at the @link data Data Structures page @endlink for
   1.126 + * more information on the layout and winding order of a face.
   1.127 + */
   1.128 +struct aiFace
   1.129 +{
   1.130 +	//! Number of indices defining this face. 
   1.131 +	//! The maximum value for this member is #AI_MAX_FACE_INDICES.
   1.132 +	unsigned int mNumIndices; 
   1.133 +
   1.134 +	//! Pointer to the indices array. Size of the array is given in numIndices.
   1.135 +	unsigned int* mIndices;   
   1.136 +
   1.137 +#ifdef __cplusplus
   1.138 +
   1.139 +	//! Default constructor
   1.140 +	aiFace()
   1.141 +      : mNumIndices( 0 )
   1.142 +      , mIndices( NULL )
   1.143 +	{
   1.144 +	}
   1.145 +
   1.146 +	//! Default destructor. Delete the index array
   1.147 +	~aiFace()
   1.148 +	{
   1.149 +		delete [] mIndices;
   1.150 +	}
   1.151 +
   1.152 +	//! Copy constructor. Copy the index array
   1.153 +	aiFace( const aiFace& o)
   1.154 +      : mIndices( NULL )
   1.155 +	{
   1.156 +		*this = o;
   1.157 +	}
   1.158 +
   1.159 +	//! Assignment operator. Copy the index array
   1.160 +	aiFace& operator = ( const aiFace& o)
   1.161 +	{
   1.162 +		if (&o == this)
   1.163 +			return *this;
   1.164 +
   1.165 +		delete[] mIndices;
   1.166 +		mNumIndices = o.mNumIndices;
   1.167 +		if (mNumIndices) {
   1.168 +			mIndices = new unsigned int[mNumIndices];
   1.169 +			::memcpy( mIndices, o.mIndices, mNumIndices * sizeof( unsigned int));
   1.170 +		}
   1.171 +		else {
   1.172 +			mIndices = NULL;
   1.173 +		}
   1.174 +		return *this;
   1.175 +	}
   1.176 +
   1.177 +	//! Comparison operator. Checks whether the index array 
   1.178 +	//! of two faces is identical
   1.179 +	bool operator== (const aiFace& o) const
   1.180 +	{
   1.181 +		if (mIndices == o.mIndices)return true;
   1.182 +		else if (mIndices && mNumIndices == o.mNumIndices)
   1.183 +		{
   1.184 +			for (unsigned int i = 0;i < this->mNumIndices;++i)
   1.185 +				if (mIndices[i] != o.mIndices[i])return false;
   1.186 +			return true;
   1.187 +		}
   1.188 +		return false;
   1.189 +	}
   1.190 +
   1.191 +	//! Inverse comparison operator. Checks whether the index 
   1.192 +	//! array of two faces is NOT identical
   1.193 +	bool operator != (const aiFace& o) const
   1.194 +	{
   1.195 +		return !(*this == o);
   1.196 +	}
   1.197 +#endif // __cplusplus
   1.198 +}; // struct aiFace
   1.199 +
   1.200 +
   1.201 +// ---------------------------------------------------------------------------
   1.202 +/** @brief A single influence of a bone on a vertex.
   1.203 + */
   1.204 +struct aiVertexWeight
   1.205 +{
   1.206 +	//! Index of the vertex which is influenced by the bone.
   1.207 +	unsigned int mVertexId;
   1.208 +
   1.209 +	//! The strength of the influence in the range (0...1).
   1.210 +	//! The influence from all bones at one vertex amounts to 1.
   1.211 +	float mWeight;     
   1.212 +
   1.213 +#ifdef __cplusplus
   1.214 +
   1.215 +	//! Default constructor
   1.216 +	aiVertexWeight() { }
   1.217 +
   1.218 +	//! Initialisation from a given index and vertex weight factor
   1.219 +	//! \param pID ID
   1.220 +	//! \param pWeight Vertex weight factor
   1.221 +	aiVertexWeight( unsigned int pID, float pWeight) 
   1.222 +		: mVertexId( pID), mWeight( pWeight) 
   1.223 +	{ /* nothing to do here */ }
   1.224 +
   1.225 +#endif // __cplusplus
   1.226 +};
   1.227 +
   1.228 +
   1.229 +// ---------------------------------------------------------------------------
   1.230 +/** @brief A single bone of a mesh.
   1.231 + *
   1.232 + *  A bone has a name by which it can be found in the frame hierarchy and by
   1.233 + *  which it can be addressed by animations. In addition it has a number of 
   1.234 + *  influences on vertices.
   1.235 + */
   1.236 +struct aiBone
   1.237 +{
   1.238 +	//! The name of the bone. 
   1.239 +	C_STRUCT aiString mName;
   1.240 +
   1.241 +	//! The number of vertices affected by this bone
   1.242 +	//! The maximum value for this member is #AI_MAX_BONE_WEIGHTS.
   1.243 +	unsigned int mNumWeights;
   1.244 +
   1.245 +	//! The vertices affected by this bone
   1.246 +	C_STRUCT aiVertexWeight* mWeights;
   1.247 +
   1.248 +	//! Matrix that transforms from mesh space to bone space in bind pose
   1.249 +	C_STRUCT aiMatrix4x4 mOffsetMatrix;
   1.250 +
   1.251 +#ifdef __cplusplus
   1.252 +
   1.253 +	//! Default constructor
   1.254 +	aiBone()
   1.255 +      : mNumWeights( 0 )
   1.256 +      , mWeights( NULL )
   1.257 +	{
   1.258 +	}
   1.259 +
   1.260 +	//! Copy constructor
   1.261 +	aiBone(const aiBone& other)
   1.262 +      : mName( other.mName )
   1.263 +      , mNumWeights( other.mNumWeights )
   1.264 +      , mOffsetMatrix( other.mOffsetMatrix )
   1.265 +	{
   1.266 +		if (other.mWeights && other.mNumWeights)
   1.267 +		{
   1.268 +			mWeights = new aiVertexWeight[mNumWeights];
   1.269 +			::memcpy(mWeights,other.mWeights,mNumWeights * sizeof(aiVertexWeight));
   1.270 +		}
   1.271 +	}
   1.272 +
   1.273 +	//! Destructor - deletes the array of vertex weights
   1.274 +	~aiBone()
   1.275 +	{
   1.276 +		delete [] mWeights;
   1.277 +	}
   1.278 +#endif // __cplusplus
   1.279 +};
   1.280 +
   1.281 +
   1.282 +// ---------------------------------------------------------------------------
   1.283 +/** @brief Enumerates the types of geometric primitives supported by Assimp.
   1.284 + *  
   1.285 + *  @see aiFace Face data structure
   1.286 + *  @see aiProcess_SortByPType Per-primitive sorting of meshes
   1.287 + *  @see aiProcess_Triangulate Automatic triangulation
   1.288 + *  @see AI_CONFIG_PP_SBP_REMOVE Removal of specific primitive types.
   1.289 + */
   1.290 +enum aiPrimitiveType
   1.291 +{
   1.292 +	/** A point primitive. 
   1.293 +	 *
   1.294 +	 * This is just a single vertex in the virtual world, 
   1.295 +	 * #aiFace contains just one index for such a primitive.
   1.296 +	 */
   1.297 +	aiPrimitiveType_POINT       = 0x1,
   1.298 +
   1.299 +	/** A line primitive. 
   1.300 +	 *
   1.301 +	 * This is a line defined through a start and an end position.
   1.302 +	 * #aiFace contains exactly two indices for such a primitive.
   1.303 +	 */
   1.304 +	aiPrimitiveType_LINE        = 0x2,
   1.305 +
   1.306 +	/** A triangular primitive. 
   1.307 +	 *
   1.308 +	 * A triangle consists of three indices.
   1.309 +	 */
   1.310 +	aiPrimitiveType_TRIANGLE    = 0x4,
   1.311 +
   1.312 +	/** A higher-level polygon with more than 3 edges.
   1.313 +	 *
   1.314 +	 * A triangle is a polygon, but polygon in this context means
   1.315 +	 * "all polygons that are not triangles". The "Triangulate"-Step
   1.316 +	 * is provided for your convenience, it splits all polygons in
   1.317 +	 * triangles (which are much easier to handle).
   1.318 +	 */
   1.319 +	aiPrimitiveType_POLYGON     = 0x8,
   1.320 +
   1.321 +
   1.322 +	/** This value is not used. It is just here to force the
   1.323 +	 *  compiler to map this enum to a 32 Bit integer.
   1.324 +	 */
   1.325 +#ifndef SWIG
   1.326 +	_aiPrimitiveType_Force32Bit = INT_MAX
   1.327 +#endif
   1.328 +}; //! enum aiPrimitiveType
   1.329 +
   1.330 +// Get the #aiPrimitiveType flag for a specific number of face indices
   1.331 +#define AI_PRIMITIVE_TYPE_FOR_N_INDICES(n) \
   1.332 +	((n) > 3 ? aiPrimitiveType_POLYGON : (aiPrimitiveType)(1u << ((n)-1)))
   1.333 +
   1.334 +
   1.335 +
   1.336 +// ---------------------------------------------------------------------------
   1.337 +/** @brief NOT CURRENTLY IN USE. An AnimMesh is an attachment to an #aiMesh stores per-vertex 
   1.338 + *  animations for a particular frame.
   1.339 + *  
   1.340 + *  You may think of an #aiAnimMesh as a `patch` for the host mesh, which
   1.341 + *  replaces only certain vertex data streams at a particular time. 
   1.342 + *  Each mesh stores n attached attached meshes (#aiMesh::mAnimMeshes).
   1.343 + *  The actual relationship between the time line and anim meshes is 
   1.344 + *  established by #aiMeshAnim, which references singular mesh attachments
   1.345 + *  by their ID and binds them to a time offset.
   1.346 +*/
   1.347 +struct aiAnimMesh
   1.348 +{
   1.349 +	/** Replacement for aiMesh::mVertices. If this array is non-NULL, 
   1.350 +	 *  it *must* contain mNumVertices entries. The corresponding
   1.351 +	 *  array in the host mesh must be non-NULL as well - animation
   1.352 +	 *  meshes may neither add or nor remove vertex components (if
   1.353 +	 *  a replacement array is NULL and the corresponding source
   1.354 +	 *  array is not, the source data is taken instead)*/
   1.355 +	C_STRUCT aiVector3D* mVertices;
   1.356 +
   1.357 +	/** Replacement for aiMesh::mNormals.  */
   1.358 +	C_STRUCT aiVector3D* mNormals;
   1.359 +
   1.360 +	/** Replacement for aiMesh::mTangents. */
   1.361 +	C_STRUCT aiVector3D* mTangents;
   1.362 +
   1.363 +	/** Replacement for aiMesh::mBitangents. */
   1.364 +	C_STRUCT aiVector3D* mBitangents;
   1.365 +
   1.366 +	/** Replacement for aiMesh::mColors */
   1.367 +	C_STRUCT aiColor4D* mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
   1.368 +
   1.369 +	/** Replacement for aiMesh::mTextureCoords */
   1.370 +	C_STRUCT aiVector3D* mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
   1.371 +
   1.372 +	/** The number of vertices in the aiAnimMesh, and thus the length of all
   1.373 +	 * the member arrays.
   1.374 +	 *
   1.375 +	 * This has always the same value as the mNumVertices property in the
   1.376 +	 * corresponding aiMesh. It is duplicated here merely to make the length
   1.377 +	 * of the member arrays accessible even if the aiMesh is not known, e.g.
   1.378 +	 * from language bindings.
   1.379 +	 */
   1.380 +	unsigned int mNumVertices;
   1.381 +
   1.382 +#ifdef __cplusplus
   1.383 +
   1.384 +	aiAnimMesh()
   1.385 +		: mVertices( NULL )
   1.386 +		, mNormals( NULL )
   1.387 +		, mTangents( NULL )
   1.388 +		, mBitangents( NULL )
   1.389 +		, mNumVertices( 0 )
   1.390 +	{
   1.391 +		// fixme consider moving this to the ctor initializer list as well
   1.392 +		for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++){
   1.393 +			mTextureCoords[a] = NULL;
   1.394 +		}
   1.395 +		for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) {
   1.396 +			mColors[a] = NULL;
   1.397 +		}
   1.398 +	}
   1.399 +	
   1.400 +	~aiAnimMesh()
   1.401 +	{
   1.402 +		delete [] mVertices; 
   1.403 +		delete [] mNormals;
   1.404 +		delete [] mTangents;
   1.405 +		delete [] mBitangents;
   1.406 +		for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
   1.407 +			delete [] mTextureCoords[a];
   1.408 +		}
   1.409 +		for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) {
   1.410 +			delete [] mColors[a];
   1.411 +		}
   1.412 +	}
   1.413 +
   1.414 +	/** Check whether the anim mesh overrides the vertex positions 
   1.415 +	 *  of its host mesh*/ 
   1.416 +	bool HasPositions() const {
   1.417 +		return mVertices != NULL; 
   1.418 +	}
   1.419 +
   1.420 +	/** Check whether the anim mesh overrides the vertex normals
   1.421 +	 *  of its host mesh*/ 
   1.422 +	bool HasNormals() const { 
   1.423 +		return mNormals != NULL; 
   1.424 +	}
   1.425 +
   1.426 +	/** Check whether the anim mesh overrides the vertex tangents
   1.427 +	 *  and bitangents of its host mesh. As for aiMesh,
   1.428 +	 *  tangents and bitangents always go together. */ 
   1.429 +	bool HasTangentsAndBitangents() const { 
   1.430 +		return mTangents != NULL; 
   1.431 +	}
   1.432 +
   1.433 +	/** Check whether the anim mesh overrides a particular
   1.434 +	 * set of vertex colors on his host mesh. 
   1.435 +	 *  @param pIndex 0<index<AI_MAX_NUMBER_OF_COLOR_SETS */ 
   1.436 +	bool HasVertexColors( unsigned int pIndex) const	{ 
   1.437 +		return pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS ? false : mColors[pIndex] != NULL; 
   1.438 +	}
   1.439 +
   1.440 +	/** Check whether the anim mesh overrides a particular
   1.441 +	 * set of texture coordinates on his host mesh. 
   1.442 +	 *  @param pIndex 0<index<AI_MAX_NUMBER_OF_TEXTURECOORDS */ 
   1.443 +	bool HasTextureCoords( unsigned int pIndex) const	{ 
   1.444 +		return pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? false : mTextureCoords[pIndex] != NULL; 
   1.445 +	}
   1.446 +
   1.447 +#endif
   1.448 +};
   1.449 +
   1.450 +
   1.451 +// ---------------------------------------------------------------------------
   1.452 +/** @brief A mesh represents a geometry or model with a single material. 
   1.453 +*
   1.454 +* It usually consists of a number of vertices and a series of primitives/faces 
   1.455 +* referencing the vertices. In addition there might be a series of bones, each 
   1.456 +* of them addressing a number of vertices with a certain weight. Vertex data 
   1.457 +* is presented in channels with each channel containing a single per-vertex 
   1.458 +* information such as a set of texture coords or a normal vector.
   1.459 +* If a data pointer is non-null, the corresponding data stream is present.
   1.460 +* From C++-programs you can also use the comfort functions Has*() to
   1.461 +* test for the presence of various data streams.
   1.462 +*
   1.463 +* A Mesh uses only a single material which is referenced by a material ID.
   1.464 +* @note The mPositions member is usually not optional. However, vertex positions 
   1.465 +* *could* be missing if the #AI_SCENE_FLAGS_INCOMPLETE flag is set in 
   1.466 +* @code
   1.467 +* aiScene::mFlags
   1.468 +* @endcode
   1.469 +*/
   1.470 +struct aiMesh
   1.471 +{
   1.472 +	/** Bitwise combination of the members of the #aiPrimitiveType enum.
   1.473 +	 * This specifies which types of primitives are present in the mesh.
   1.474 +	 * The "SortByPrimitiveType"-Step can be used to make sure the 
   1.475 +	 * output meshes consist of one primitive type each.
   1.476 +	 */
   1.477 +	unsigned int mPrimitiveTypes;
   1.478 +
   1.479 +	/** The number of vertices in this mesh. 
   1.480 +	* This is also the size of all of the per-vertex data arrays.
   1.481 +	* The maximum value for this member is #AI_MAX_VERTICES.
   1.482 +	*/
   1.483 +	unsigned int mNumVertices;
   1.484 +
   1.485 +	/** The number of primitives (triangles, polygons, lines) in this  mesh. 
   1.486 +	* This is also the size of the mFaces array.
   1.487 +	* The maximum value for this member is #AI_MAX_FACES.
   1.488 +	*/
   1.489 +	unsigned int mNumFaces;
   1.490 +
   1.491 +	/** Vertex positions. 
   1.492 +	* This array is always present in a mesh. The array is 
   1.493 +	* mNumVertices in size. 
   1.494 +	*/
   1.495 +	C_STRUCT aiVector3D* mVertices;
   1.496 +
   1.497 +	/** Vertex normals. 
   1.498 +	* The array contains normalized vectors, NULL if not present. 
   1.499 +	* The array is mNumVertices in size. Normals are undefined for
   1.500 +	* point and line primitives. A mesh consisting of points and
   1.501 +	* lines only may not have normal vectors. Meshes with mixed
   1.502 +	* primitive types (i.e. lines and triangles) may have normals,
   1.503 +	* but the normals for vertices that are only referenced by
   1.504 +	* point or line primitives are undefined and set to QNaN (WARN:
   1.505 +	* qNaN compares to inequal to *everything*, even to qNaN itself.
   1.506 +	* Using code like this to check whether a field is qnan is:
   1.507 +	* @code
   1.508 +	* #define IS_QNAN(f) (f != f)
   1.509 +	* @endcode
   1.510 +	* still dangerous because even 1.f == 1.f could evaluate to false! (
   1.511 +	* remember the subtleties of IEEE754 artithmetics). Use stuff like
   1.512 +	* @c fpclassify instead.
   1.513 +	* @note Normal vectors computed by Assimp are always unit-length.
   1.514 +	* However, this needn't apply for normals that have been taken
   1.515 +	*   directly from the model file.
   1.516 +	*/
   1.517 +	C_STRUCT aiVector3D* mNormals;
   1.518 +
   1.519 +	/** Vertex tangents. 
   1.520 +	* The tangent of a vertex points in the direction of the positive 
   1.521 +	* X texture axis. The array contains normalized vectors, NULL if
   1.522 +	* not present. The array is mNumVertices in size. A mesh consisting 
   1.523 +	* of points and lines only may not have normal vectors. Meshes with 
   1.524 +	* mixed primitive types (i.e. lines and triangles) may have 
   1.525 +	* normals, but the normals for vertices that are only referenced by
   1.526 +	* point or line primitives are undefined and set to qNaN.  See
   1.527 +	* the #mNormals member for a detailled discussion of qNaNs.
   1.528 +	* @note If the mesh contains tangents, it automatically also 
   1.529 +	* contains bitangents.
   1.530 +	*/
   1.531 +	C_STRUCT aiVector3D* mTangents;
   1.532 +
   1.533 +	/** Vertex bitangents. 
   1.534 +	* The bitangent of a vertex points in the direction of the positive 
   1.535 +	* Y texture axis. The array contains normalized vectors, NULL if not
   1.536 +	* present. The array is mNumVertices in size. 
   1.537 +	* @note If the mesh contains tangents, it automatically also contains
   1.538 +	* bitangents.  
   1.539 +	*/
   1.540 +	C_STRUCT aiVector3D* mBitangents;
   1.541 +
   1.542 +	/** Vertex color sets. 
   1.543 +	* A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex 
   1.544 +	* colors per vertex. NULL if not present. Each array is
   1.545 +	* mNumVertices in size if present.
   1.546 +	*/
   1.547 +	C_STRUCT aiColor4D* mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
   1.548 +
   1.549 +	/** Vertex texture coords, also known as UV channels.
   1.550 +	* A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
   1.551 +	* vertex. NULL if not present. The array is mNumVertices in size. 
   1.552 +	*/
   1.553 +	C_STRUCT aiVector3D* mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
   1.554 +
   1.555 +	/** Specifies the number of components for a given UV channel.
   1.556 +	* Up to three channels are supported (UVW, for accessing volume
   1.557 +	* or cube maps). If the value is 2 for a given channel n, the
   1.558 +	* component p.z of mTextureCoords[n][p] is set to 0.0f.
   1.559 +	* If the value is 1 for a given channel, p.y is set to 0.0f, too.
   1.560 +	* @note 4D coords are not supported 
   1.561 +	*/
   1.562 +	unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS];
   1.563 +
   1.564 +	/** The faces the mesh is constructed from. 
   1.565 +	* Each face refers to a number of vertices by their indices. 
   1.566 +	* This array is always present in a mesh, its size is given 
   1.567 +	* in mNumFaces. If the #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
   1.568 +	* is NOT set each face references an unique set of vertices.
   1.569 +	*/
   1.570 +	C_STRUCT aiFace* mFaces;
   1.571 +
   1.572 +	/** The number of bones this mesh contains. 
   1.573 +	* Can be 0, in which case the mBones array is NULL. 
   1.574 +	*/
   1.575 +	unsigned int mNumBones;
   1.576 +
   1.577 +	/** The bones of this mesh. 
   1.578 +	* A bone consists of a name by which it can be found in the
   1.579 +	* frame hierarchy and a set of vertex weights.
   1.580 +	*/
   1.581 +	C_STRUCT aiBone** mBones;
   1.582 +
   1.583 +	/** The material used by this mesh. 
   1.584 +	 * A mesh does use only a single material. If an imported model uses
   1.585 +	 * multiple materials, the import splits up the mesh. Use this value 
   1.586 +	 * as index into the scene's material list.
   1.587 +	 */
   1.588 +	unsigned int mMaterialIndex;
   1.589 +
   1.590 +	/** Name of the mesh. Meshes can be named, but this is not a
   1.591 +	 *  requirement and leaving this field empty is totally fine.
   1.592 +	 *  There are mainly three uses for mesh names: 
   1.593 +	 *   - some formats name nodes and meshes independently.
   1.594 +	 *   - importers tend to split meshes up to meet the
   1.595 +	 *      one-material-per-mesh requirement. Assigning
   1.596 +	 *      the same (dummy) name to each of the result meshes
   1.597 +	 *      aids the caller at recovering the original mesh
   1.598 +	 *      partitioning.
   1.599 +	 *   - Vertex animations refer to meshes by their names.
   1.600 +	 **/
   1.601 +	C_STRUCT aiString mName;
   1.602 +
   1.603 +
   1.604 +	/** NOT CURRENTLY IN USE. The number of attachment meshes */
   1.605 +	unsigned int mNumAnimMeshes;
   1.606 +
   1.607 +	/** NOT CURRENTLY IN USE. Attachment meshes for this mesh, for vertex-based animation. 
   1.608 +	 *  Attachment meshes carry replacement data for some of the
   1.609 +	 *  mesh'es vertex components (usually positions, normals). */
   1.610 +	C_STRUCT aiAnimMesh** mAnimMeshes;
   1.611 +
   1.612 +
   1.613 +#ifdef __cplusplus
   1.614 +
   1.615 +	//! Default constructor. Initializes all members to 0
   1.616 +	aiMesh()
   1.617 +		: mPrimitiveTypes( 0 )
   1.618 +		, mNumVertices( 0 )
   1.619 +		, mNumFaces( 0 )
   1.620 +		, mVertices( NULL )
   1.621 +		, mNormals( NULL )
   1.622 +		, mTangents( NULL )
   1.623 +		, mBitangents( NULL )
   1.624 +		, mFaces( NULL )
   1.625 +		, mNumBones( 0 )
   1.626 +		, mBones( 0 )
   1.627 +		, mMaterialIndex( 0 )
   1.628 +		, mNumAnimMeshes( 0 )
   1.629 +		, mAnimMeshes( NULL )
   1.630 +	{
   1.631 +		for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++)
   1.632 +		{
   1.633 +			mNumUVComponents[a] = 0;
   1.634 +			mTextureCoords[a] = NULL;
   1.635 +		}
   1.636 +      
   1.637 +		for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++)
   1.638 +			mColors[a] = NULL;
   1.639 +	}
   1.640 +
   1.641 +	//! Deletes all storage allocated for the mesh
   1.642 +	~aiMesh()
   1.643 +	{
   1.644 +		delete [] mVertices; 
   1.645 +		delete [] mNormals;
   1.646 +		delete [] mTangents;
   1.647 +		delete [] mBitangents;
   1.648 +		for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
   1.649 +			delete [] mTextureCoords[a];
   1.650 +		}
   1.651 +		for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) {
   1.652 +			delete [] mColors[a];
   1.653 +		}
   1.654 +
   1.655 +		// DO NOT REMOVE THIS ADDITIONAL CHECK
   1.656 +		if (mNumBones && mBones)	{
   1.657 +			for( unsigned int a = 0; a < mNumBones; a++) {
   1.658 +				delete mBones[a];
   1.659 +			}
   1.660 +			delete [] mBones;
   1.661 +		}
   1.662 +
   1.663 +		if (mNumAnimMeshes && mAnimMeshes)	{
   1.664 +			for( unsigned int a = 0; a < mNumAnimMeshes; a++) {
   1.665 +				delete mAnimMeshes[a];
   1.666 +			}
   1.667 +			delete [] mAnimMeshes;
   1.668 +		}
   1.669 +
   1.670 +		delete [] mFaces;
   1.671 +	}
   1.672 +
   1.673 +	//! Check whether the mesh contains positions. Provided no special
   1.674 +	//! scene flags are set (such as #AI_SCENE_FLAGS_ANIM_SKELETON_ONLY), 
   1.675 +	//! this will always be true 
   1.676 +	bool HasPositions() const 
   1.677 +		{ return mVertices != NULL && mNumVertices > 0; }
   1.678 +
   1.679 +	//! Check whether the mesh contains faces. If no special scene flags
   1.680 +	//! are set this should always return true
   1.681 +	bool HasFaces() const 
   1.682 +		{ return mFaces != NULL && mNumFaces > 0; }
   1.683 +
   1.684 +	//! Check whether the mesh contains normal vectors
   1.685 +	bool HasNormals() const 
   1.686 +		{ return mNormals != NULL && mNumVertices > 0; }
   1.687 +
   1.688 +	//! Check whether the mesh contains tangent and bitangent vectors
   1.689 +	//! It is not possible that it contains tangents and no bitangents
   1.690 +	//! (or the other way round). The existence of one of them
   1.691 +	//! implies that the second is there, too.
   1.692 +	bool HasTangentsAndBitangents() const 
   1.693 +		{ return mTangents != NULL && mBitangents != NULL && mNumVertices > 0; }
   1.694 +
   1.695 +	//! Check whether the mesh contains a vertex color set
   1.696 +	//! \param pIndex Index of the vertex color set
   1.697 +	bool HasVertexColors( unsigned int pIndex) const
   1.698 +	{ 
   1.699 +		if( pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS) 
   1.700 +			return false; 
   1.701 +		else 
   1.702 +			return mColors[pIndex] != NULL && mNumVertices > 0; 
   1.703 +	}
   1.704 +
   1.705 +	//! Check whether the mesh contains a texture coordinate set
   1.706 +	//! \param pIndex Index of the texture coordinates set
   1.707 +	bool HasTextureCoords( unsigned int pIndex) const
   1.708 +	{ 
   1.709 +		if( pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) 
   1.710 +			return false; 
   1.711 +		else 
   1.712 +			return mTextureCoords[pIndex] != NULL && mNumVertices > 0; 
   1.713 +	}
   1.714 +
   1.715 +	//! Get the number of UV channels the mesh contains
   1.716 +	unsigned int GetNumUVChannels() const 
   1.717 +	{
   1.718 +		unsigned int n = 0;
   1.719 +		while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n])++n;
   1.720 +		return n;
   1.721 +	}
   1.722 +
   1.723 +	//! Get the number of vertex color channels the mesh contains
   1.724 +	unsigned int GetNumColorChannels() const 
   1.725 +	{
   1.726 +		unsigned int n = 0;
   1.727 +		while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n])++n;
   1.728 +		return n;
   1.729 +	}
   1.730 +
   1.731 +	//! Check whether the mesh contains bones
   1.732 +	inline bool HasBones() const
   1.733 +		{ return mBones != NULL && mNumBones > 0; }
   1.734 +
   1.735 +#endif // __cplusplus
   1.736 +};
   1.737 +
   1.738 +
   1.739 +#ifdef __cplusplus
   1.740 +}
   1.741 +#endif //! extern "C"
   1.742 +#endif // __AI_MESH_H_INC
   1.743 +