1/*
2---------------------------------------------------------------------------
3Open Asset Import Library (assimp)
4---------------------------------------------------------------------------
5
6Copyright (c) 2006-2017, assimp team
7
8All rights reserved.
9
10Redistribution and use of this software in source and binary forms,
11with or without modification, are permitted provided that the following
12conditions are met:
13
14* Redistributions of source code must retain the above
15 copyright notice, this list of conditions and the
16 following disclaimer.
17
18* Redistributions in binary form must reproduce the above
19 copyright notice, this list of conditions and the
20 following disclaimer in the documentation and/or other
21 materials provided with the distribution.
22
23* Neither the name of the assimp team, nor the names of its
24 contributors may be used to endorse or promote products
25 derived from this software without specific prior
26 written permission of the assimp team.
27
28THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39---------------------------------------------------------------------------
40*/
41
42/** @file mesh.h
43 * @brief Declares the data structures in which the imported geometry is
44 returned by ASSIMP: aiMesh, aiFace and aiBone data structures.
45 */
46#pragma once
47#ifndef AI_MESH_H_INC
48#define AI_MESH_H_INC
49
50#include "types.h"
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56// ---------------------------------------------------------------------------
57// Limits. These values are required to match the settings Assimp was
58// compiled against. Therefore, do not redefine them unless you build the
59// library from source using the same definitions.
60// ---------------------------------------------------------------------------
61
62/** @def AI_MAX_FACE_INDICES
63 * Maximum number of indices per face (polygon). */
64
65#ifndef AI_MAX_FACE_INDICES
66# define AI_MAX_FACE_INDICES 0x7fff
67#endif
68
69/** @def AI_MAX_BONE_WEIGHTS
70 * Maximum number of indices per face (polygon). */
71
72#ifndef AI_MAX_BONE_WEIGHTS
73# define AI_MAX_BONE_WEIGHTS 0x7fffffff
74#endif
75
76/** @def AI_MAX_VERTICES
77 * Maximum number of vertices per mesh. */
78
79#ifndef AI_MAX_VERTICES
80# define AI_MAX_VERTICES 0x7fffffff
81#endif
82
83/** @def AI_MAX_FACES
84 * Maximum number of faces per mesh. */
85
86#ifndef AI_MAX_FACES
87# define AI_MAX_FACES 0x7fffffff
88#endif
89
90/** @def AI_MAX_NUMBER_OF_COLOR_SETS
91 * Supported number of vertex color sets per mesh. */
92
93#ifndef AI_MAX_NUMBER_OF_COLOR_SETS
94# define AI_MAX_NUMBER_OF_COLOR_SETS 0x8
95#endif // !! AI_MAX_NUMBER_OF_COLOR_SETS
96
97/** @def AI_MAX_NUMBER_OF_TEXTURECOORDS
98 * Supported number of texture coord sets (UV(W) channels) per mesh */
99
100#ifndef AI_MAX_NUMBER_OF_TEXTURECOORDS
101# define AI_MAX_NUMBER_OF_TEXTURECOORDS 0x8
102#endif // !! AI_MAX_NUMBER_OF_TEXTURECOORDS
103
104// ---------------------------------------------------------------------------
105/** @brief A single face in a mesh, referring to multiple vertices.
106 *
107 * If mNumIndices is 3, we call the face 'triangle', for mNumIndices > 3
108 * it's called 'polygon' (hey, that's just a definition!).
109 * <br>
110 * aiMesh::mPrimitiveTypes can be queried to quickly examine which types of
111 * primitive are actually present in a mesh. The #aiProcess_SortByPType flag
112 * executes a special post-processing algorithm which splits meshes with
113 * *different* primitive types mixed up (e.g. lines and triangles) in several
114 * 'clean' submeshes. Furthermore there is a configuration option (
115 * #AI_CONFIG_PP_SBP_REMOVE) to force #aiProcess_SortByPType to remove
116 * specific kinds of primitives from the imported scene, completely and forever.
117 * In many cases you'll probably want to set this setting to
118 * @code
119 * aiPrimitiveType_LINE|aiPrimitiveType_POINT
120 * @endcode
121 * Together with the #aiProcess_Triangulate flag you can then be sure that
122 * #aiFace::mNumIndices is always 3.
123 * @note Take a look at the @link data Data Structures page @endlink for
124 * more information on the layout and winding order of a face.
125 */
126struct aiFace
127{
128 //! Number of indices defining this face.
129 //! The maximum value for this member is #AI_MAX_FACE_INDICES.
130 unsigned int mNumIndices;
131
132 //! Pointer to the indices array. Size of the array is given in numIndices.
133 unsigned int* mIndices;
134
135#ifdef __cplusplus
136
137 //! Default constructor
138 aiFace()
139 : mNumIndices( 0 )
140 , mIndices( NULL )
141 {
142 }
143
144 //! Default destructor. Delete the index array
145 ~aiFace()
146 {
147 delete [] mIndices;
148 }
149
150 //! Copy constructor. Copy the index array
151 aiFace( const aiFace& o)
152 : mIndices( NULL )
153 {
154 *this = o;
155 }
156
157 //! Assignment operator. Copy the index array
158 aiFace& operator = ( const aiFace& o)
159 {
160 if (&o == this)
161 return *this;
162
163 delete[] mIndices;
164 mNumIndices = o.mNumIndices;
165 if (mNumIndices) {
166 mIndices = new unsigned int[mNumIndices];
167 ::memcpy( mIndices, o.mIndices, mNumIndices * sizeof( unsigned int));
168 }
169 else {
170 mIndices = NULL;
171 }
172 return *this;
173 }
174
175 //! Comparison operator. Checks whether the index array
176 //! of two faces is identical
177 bool operator== (const aiFace& o) const
178 {
179 if (mIndices == o.mIndices)return true;
180 else if (mIndices && mNumIndices == o.mNumIndices)
181 {
182 for (unsigned int i = 0;i < this->mNumIndices;++i)
183 if (mIndices[i] != o.mIndices[i])return false;
184 return true;
185 }
186 return false;
187 }
188
189 //! Inverse comparison operator. Checks whether the index
190 //! array of two faces is NOT identical
191 bool operator != (const aiFace& o) const
192 {
193 return !(*this == o);
194 }
195#endif // __cplusplus
196}; // struct aiFace
197
198
199// ---------------------------------------------------------------------------
200/** @brief A single influence of a bone on a vertex.
201 */
202struct aiVertexWeight
203{
204 //! Index of the vertex which is influenced by the bone.
205 unsigned int mVertexId;
206
207 //! The strength of the influence in the range (0...1).
208 //! The influence from all bones at one vertex amounts to 1.
209 float mWeight;
210
211#ifdef __cplusplus
212
213 //! Default constructor
214 aiVertexWeight() { }
215
216 //! Initialisation from a given index and vertex weight factor
217 //! \param pID ID
218 //! \param pWeight Vertex weight factor
219 aiVertexWeight( unsigned int pID, float pWeight)
220 : mVertexId( pID), mWeight( pWeight)
221 { /* nothing to do here */ }
222
223#endif // __cplusplus
224};
225
226
227// ---------------------------------------------------------------------------
228/** @brief A single bone of a mesh.
229 *
230 * A bone has a name by which it can be found in the frame hierarchy and by
231 * which it can be addressed by animations. In addition it has a number of
232 * influences on vertices.
233 */
234struct aiBone
235{
236 //! The name of the bone.
237 C_STRUCT aiString mName;
238
239 //! The number of vertices affected by this bone
240 //! The maximum value for this member is #AI_MAX_BONE_WEIGHTS.
241 unsigned int mNumWeights;
242
243 //! The vertices affected by this bone
244 C_STRUCT aiVertexWeight* mWeights;
245
246 //! Matrix that transforms from mesh space to bone space in bind pose
247 C_STRUCT aiMatrix4x4 mOffsetMatrix;
248
249#ifdef __cplusplus
250
251 //! Default constructor
252 aiBone()
253 : mName()
254 , mNumWeights( 0 )
255 , mWeights( NULL )
256 {
257 }
258
259 //! Copy constructor
260 aiBone(const aiBone& other)
261 : mName( other.mName )
262 , mNumWeights( other.mNumWeights )
263 , mOffsetMatrix( other.mOffsetMatrix )
264 {
265 if (other.mWeights && other.mNumWeights)
266 {
267 mWeights = new aiVertexWeight[mNumWeights];
268 ::memcpy(mWeights,other.mWeights,mNumWeights * sizeof(aiVertexWeight));
269 }
270 }
271
272 //! Destructor - deletes the array of vertex weights
273 ~aiBone()
274 {
275 delete [] mWeights;
276 }
277#endif // __cplusplus
278};
279
280
281// ---------------------------------------------------------------------------
282/** @brief Enumerates the types of geometric primitives supported by Assimp.
283 *
284 * @see aiFace Face data structure
285 * @see aiProcess_SortByPType Per-primitive sorting of meshes
286 * @see aiProcess_Triangulate Automatic triangulation
287 * @see AI_CONFIG_PP_SBP_REMOVE Removal of specific primitive types.
288 */
289enum aiPrimitiveType
290{
291 /** A point primitive.
292 *
293 * This is just a single vertex in the virtual world,
294 * #aiFace contains just one index for such a primitive.
295 */
296 aiPrimitiveType_POINT = 0x1,
297
298 /** A line primitive.
299 *
300 * This is a line defined through a start and an end position.
301 * #aiFace contains exactly two indices for such a primitive.
302 */
303 aiPrimitiveType_LINE = 0x2,
304
305 /** A triangular primitive.
306 *
307 * A triangle consists of three indices.
308 */
309 aiPrimitiveType_TRIANGLE = 0x4,
310
311 /** A higher-level polygon with more than 3 edges.
312 *
313 * A triangle is a polygon, but polygon in this context means
314 * "all polygons that are not triangles". The "Triangulate"-Step
315 * is provided for your convenience, it splits all polygons in
316 * triangles (which are much easier to handle).
317 */
318 aiPrimitiveType_POLYGON = 0x8,
319
320
321 /** This value is not used. It is just here to force the
322 * compiler to map this enum to a 32 Bit integer.
323 */
324#ifndef SWIG
325 _aiPrimitiveType_Force32Bit = INT_MAX
326#endif
327}; //! enum aiPrimitiveType
328
329// Get the #aiPrimitiveType flag for a specific number of face indices
330#define AI_PRIMITIVE_TYPE_FOR_N_INDICES(n) \
331 ((n) > 3 ? aiPrimitiveType_POLYGON : (aiPrimitiveType)(1u << ((n)-1)))
332
333
334
335// ---------------------------------------------------------------------------
336/** @brief NOT CURRENTLY IN USE. An AnimMesh is an attachment to an #aiMesh stores per-vertex
337 * animations for a particular frame.
338 *
339 * You may think of an #aiAnimMesh as a `patch` for the host mesh, which
340 * replaces only certain vertex data streams at a particular time.
341 * Each mesh stores n attached attached meshes (#aiMesh::mAnimMeshes).
342 * The actual relationship between the time line and anim meshes is
343 * established by #aiMeshAnim, which references singular mesh attachments
344 * by their ID and binds them to a time offset.
345*/
346struct aiAnimMesh
347{
348 /** Replacement for aiMesh::mVertices. If this array is non-NULL,
349 * it *must* contain mNumVertices entries. The corresponding
350 * array in the host mesh must be non-NULL as well - animation
351 * meshes may neither add or nor remove vertex components (if
352 * a replacement array is NULL and the corresponding source
353 * array is not, the source data is taken instead)*/
354 C_STRUCT aiVector3D* mVertices;
355
356 /** Replacement for aiMesh::mNormals. */
357 C_STRUCT aiVector3D* mNormals;
358
359 /** Replacement for aiMesh::mTangents. */
360 C_STRUCT aiVector3D* mTangents;
361
362 /** Replacement for aiMesh::mBitangents. */
363 C_STRUCT aiVector3D* mBitangents;
364
365 /** Replacement for aiMesh::mColors */
366 C_STRUCT aiColor4D* mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
367
368 /** Replacement for aiMesh::mTextureCoords */
369 C_STRUCT aiVector3D* mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
370
371 /** The number of vertices in the aiAnimMesh, and thus the length of all
372 * the member arrays.
373 *
374 * This has always the same value as the mNumVertices property in the
375 * corresponding aiMesh. It is duplicated here merely to make the length
376 * of the member arrays accessible even if the aiMesh is not known, e.g.
377 * from language bindings.
378 */
379 unsigned int mNumVertices;
380
381 /**
382 * Weight of the AnimMesh.
383 */
384 float mWeight;
385
386#ifdef __cplusplus
387
388 aiAnimMesh()
389 : mVertices( NULL )
390 , mNormals( NULL )
391 , mTangents( NULL )
392 , mBitangents( NULL )
393 , mNumVertices( 0 )
394 , mWeight( 0.0f )
395 {
396 // fixme consider moving this to the ctor initializer list as well
397 for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++){
398 mTextureCoords[a] = NULL;
399 }
400 for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) {
401 mColors[a] = NULL;
402 }
403 }
404
405 ~aiAnimMesh()
406 {
407 delete [] mVertices;
408 delete [] mNormals;
409 delete [] mTangents;
410 delete [] mBitangents;
411 for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
412 delete [] mTextureCoords[a];
413 }
414 for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) {
415 delete [] mColors[a];
416 }
417 }
418
419 /** Check whether the anim mesh overrides the vertex positions
420 * of its host mesh*/
421 bool HasPositions() const {
422 return mVertices != NULL;
423 }
424
425 /** Check whether the anim mesh overrides the vertex normals
426 * of its host mesh*/
427 bool HasNormals() const {
428 return mNormals != NULL;
429 }
430
431 /** Check whether the anim mesh overrides the vertex tangents
432 * and bitangents of its host mesh. As for aiMesh,
433 * tangents and bitangents always go together. */
434 bool HasTangentsAndBitangents() const {
435 return mTangents != NULL;
436 }
437
438 /** Check whether the anim mesh overrides a particular
439 * set of vertex colors on his host mesh.
440 * @param pIndex 0<index<AI_MAX_NUMBER_OF_COLOR_SETS */
441 bool HasVertexColors( unsigned int pIndex) const {
442 return pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS ? false : mColors[pIndex] != NULL;
443 }
444
445 /** Check whether the anim mesh overrides a particular
446 * set of texture coordinates on his host mesh.
447 * @param pIndex 0<index<AI_MAX_NUMBER_OF_TEXTURECOORDS */
448 bool HasTextureCoords( unsigned int pIndex) const {
449 return pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS ? false : mTextureCoords[pIndex] != NULL;
450 }
451
452#endif
453};
454
455// ---------------------------------------------------------------------------
456/** @brief Enumerates the methods of mesh morphing supported by Assimp.
457 */
458enum aiMorphingMethod
459{
460 /** Interpolation between morph targets */
461 aiMorphingMethod_VERTEX_BLEND = 0x1,
462
463 /** Normalized morphing between morph targets */
464 aiMorphingMethod_MORPH_NORMALIZED = 0x2,
465
466 /** Relative morphing between morph targets */
467 aiMorphingMethod_MORPH_RELATIVE = 0x3,
468
469 /** This value is not used. It is just here to force the
470 * compiler to map this enum to a 32 Bit integer.
471 */
472#ifndef SWIG
473 _aiMorphingMethod_Force32Bit = INT_MAX
474#endif
475}; //! enum aiMorphingMethod
476
477// ---------------------------------------------------------------------------
478/** @brief A mesh represents a geometry or model with a single material.
479*
480* It usually consists of a number of vertices and a series of primitives/faces
481* referencing the vertices. In addition there might be a series of bones, each
482* of them addressing a number of vertices with a certain weight. Vertex data
483* is presented in channels with each channel containing a single per-vertex
484* information such as a set of texture coords or a normal vector.
485* If a data pointer is non-null, the corresponding data stream is present.
486* From C++-programs you can also use the comfort functions Has*() to
487* test for the presence of various data streams.
488*
489* A Mesh uses only a single material which is referenced by a material ID.
490* @note The mPositions member is usually not optional. However, vertex positions
491* *could* be missing if the #AI_SCENE_FLAGS_INCOMPLETE flag is set in
492* @code
493* aiScene::mFlags
494* @endcode
495*/
496struct aiMesh
497{
498 /** Bitwise combination of the members of the #aiPrimitiveType enum.
499 * This specifies which types of primitives are present in the mesh.
500 * The "SortByPrimitiveType"-Step can be used to make sure the
501 * output meshes consist of one primitive type each.
502 */
503 unsigned int mPrimitiveTypes;
504
505 /** The number of vertices in this mesh.
506 * This is also the size of all of the per-vertex data arrays.
507 * The maximum value for this member is #AI_MAX_VERTICES.
508 */
509 unsigned int mNumVertices;
510
511 /** The number of primitives (triangles, polygons, lines) in this mesh.
512 * This is also the size of the mFaces array.
513 * The maximum value for this member is #AI_MAX_FACES.
514 */
515 unsigned int mNumFaces;
516
517 /** Vertex positions.
518 * This array is always present in a mesh. The array is
519 * mNumVertices in size.
520 */
521 C_STRUCT aiVector3D* mVertices;
522
523 /** Vertex normals.
524 * The array contains normalized vectors, NULL if not present.
525 * The array is mNumVertices in size. Normals are undefined for
526 * point and line primitives. A mesh consisting of points and
527 * lines only may not have normal vectors. Meshes with mixed
528 * primitive types (i.e. lines and triangles) may have normals,
529 * but the normals for vertices that are only referenced by
530 * point or line primitives are undefined and set to QNaN (WARN:
531 * qNaN compares to inequal to *everything*, even to qNaN itself.
532 * Using code like this to check whether a field is qnan is:
533 * @code
534 * #define IS_QNAN(f) (f != f)
535 * @endcode
536 * still dangerous because even 1.f == 1.f could evaluate to false! (
537 * remember the subtleties of IEEE754 artithmetics). Use stuff like
538 * @c fpclassify instead.
539 * @note Normal vectors computed by Assimp are always unit-length.
540 * However, this needn't apply for normals that have been taken
541 * directly from the model file.
542 */
543 C_STRUCT aiVector3D* mNormals;
544
545 /** Vertex tangents.
546 * The tangent of a vertex points in the direction of the positive
547 * X texture axis. The array contains normalized vectors, NULL if
548 * not present. The array is mNumVertices in size. A mesh consisting
549 * of points and lines only may not have normal vectors. Meshes with
550 * mixed primitive types (i.e. lines and triangles) may have
551 * normals, but the normals for vertices that are only referenced by
552 * point or line primitives are undefined and set to qNaN. See
553 * the #mNormals member for a detailed discussion of qNaNs.
554 * @note If the mesh contains tangents, it automatically also
555 * contains bitangents.
556 */
557 C_STRUCT aiVector3D* mTangents;
558
559 /** Vertex bitangents.
560 * The bitangent of a vertex points in the direction of the positive
561 * Y texture axis. The array contains normalized vectors, NULL if not
562 * present. The array is mNumVertices in size.
563 * @note If the mesh contains tangents, it automatically also contains
564 * bitangents.
565 */
566 C_STRUCT aiVector3D* mBitangents;
567
568 /** Vertex color sets.
569 * A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex
570 * colors per vertex. NULL if not present. Each array is
571 * mNumVertices in size if present.
572 */
573 C_STRUCT aiColor4D* mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
574
575 /** Vertex texture coords, also known as UV channels.
576 * A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
577 * vertex. NULL if not present. The array is mNumVertices in size.
578 */
579 C_STRUCT aiVector3D* mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
580
581 /** Specifies the number of components for a given UV channel.
582 * Up to three channels are supported (UVW, for accessing volume
583 * or cube maps). If the value is 2 for a given channel n, the
584 * component p.z of mTextureCoords[n][p] is set to 0.0f.
585 * If the value is 1 for a given channel, p.y is set to 0.0f, too.
586 * @note 4D coords are not supported
587 */
588 unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS];
589
590 /** The faces the mesh is constructed from.
591 * Each face refers to a number of vertices by their indices.
592 * This array is always present in a mesh, its size is given
593 * in mNumFaces. If the #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
594 * is NOT set each face references an unique set of vertices.
595 */
596 C_STRUCT aiFace* mFaces;
597
598 /** The number of bones this mesh contains.
599 * Can be 0, in which case the mBones array is NULL.
600 */
601 unsigned int mNumBones;
602
603 /** The bones of this mesh.
604 * A bone consists of a name by which it can be found in the
605 * frame hierarchy and a set of vertex weights.
606 */
607 C_STRUCT aiBone** mBones;
608
609 /** The material used by this mesh.
610 * A mesh uses only a single material. If an imported model uses
611 * multiple materials, the import splits up the mesh. Use this value
612 * as index into the scene's material list.
613 */
614 unsigned int mMaterialIndex;
615
616 /** Name of the mesh. Meshes can be named, but this is not a
617 * requirement and leaving this field empty is totally fine.
618 * There are mainly three uses for mesh names:
619 * - some formats name nodes and meshes independently.
620 * - importers tend to split meshes up to meet the
621 * one-material-per-mesh requirement. Assigning
622 * the same (dummy) name to each of the result meshes
623 * aids the caller at recovering the original mesh
624 * partitioning.
625 * - Vertex animations refer to meshes by their names.
626 **/
627 C_STRUCT aiString mName;
628
629
630 /** The number of attachment meshes. Note! Currently only works with Collada loader. */
631 unsigned int mNumAnimMeshes;
632
633 /** Attachment meshes for this mesh, for vertex-based animation.
634 * Attachment meshes carry replacement data for some of the
635 * mesh'es vertex components (usually positions, normals).
636 * Note! Currently only works with Collada loader.*/
637 C_STRUCT aiAnimMesh** mAnimMeshes;
638
639 /**
640 * Method of morphing when animeshes are specified.
641 */
642 unsigned int mMethod;
643
644#ifdef __cplusplus
645
646 //! Default constructor. Initializes all members to 0
647 aiMesh()
648 : mPrimitiveTypes( 0 )
649 , mNumVertices( 0 )
650 , mNumFaces( 0 )
651 , mVertices( NULL )
652 , mNormals( NULL )
653 , mTangents( NULL )
654 , mBitangents( NULL )
655 , mFaces( NULL )
656 , mNumBones( 0 )
657 , mBones( NULL )
658 , mMaterialIndex( 0 )
659 , mNumAnimMeshes( 0 )
660 , mAnimMeshes( NULL )
661 , mMethod( 0 )
662 {
663 for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++)
664 {
665 mNumUVComponents[a] = 0;
666 mTextureCoords[a] = NULL;
667 }
668
669 for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++)
670 mColors[a] = NULL;
671 }
672
673 //! Deletes all storage allocated for the mesh
674 ~aiMesh()
675 {
676 delete [] mVertices;
677 delete [] mNormals;
678 delete [] mTangents;
679 delete [] mBitangents;
680 for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) {
681 delete [] mTextureCoords[a];
682 }
683 for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) {
684 delete [] mColors[a];
685 }
686
687 // DO NOT REMOVE THIS ADDITIONAL CHECK
688 if (mNumBones && mBones) {
689 for( unsigned int a = 0; a < mNumBones; a++) {
690 delete mBones[a];
691 }
692 delete [] mBones;
693 }
694
695 if (mNumAnimMeshes && mAnimMeshes) {
696 for( unsigned int a = 0; a < mNumAnimMeshes; a++) {
697 delete mAnimMeshes[a];
698 }
699 delete [] mAnimMeshes;
700 }
701
702 delete [] mFaces;
703 }
704
705 //! Check whether the mesh contains positions. Provided no special
706 //! scene flags are set, this will always be true
707 bool HasPositions() const
708 { return mVertices != NULL && mNumVertices > 0; }
709
710 //! Check whether the mesh contains faces. If no special scene flags
711 //! are set this should always return true
712 bool HasFaces() const
713 { return mFaces != NULL && mNumFaces > 0; }
714
715 //! Check whether the mesh contains normal vectors
716 bool HasNormals() const
717 { return mNormals != NULL && mNumVertices > 0; }
718
719 //! Check whether the mesh contains tangent and bitangent vectors
720 //! It is not possible that it contains tangents and no bitangents
721 //! (or the other way round). The existence of one of them
722 //! implies that the second is there, too.
723 bool HasTangentsAndBitangents() const
724 { return mTangents != NULL && mBitangents != NULL && mNumVertices > 0; }
725
726 //! Check whether the mesh contains a vertex color set
727 //! \param pIndex Index of the vertex color set
728 bool HasVertexColors( unsigned int pIndex) const
729 {
730 if( pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS)
731 return false;
732 else
733 return mColors[pIndex] != NULL && mNumVertices > 0;
734 }
735
736 //! Check whether the mesh contains a texture coordinate set
737 //! \param pIndex Index of the texture coordinates set
738 bool HasTextureCoords( unsigned int pIndex) const
739 {
740 if( pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS)
741 return false;
742 else
743 return mTextureCoords[pIndex] != NULL && mNumVertices > 0;
744 }
745
746 //! Get the number of UV channels the mesh contains
747 unsigned int GetNumUVChannels() const
748 {
749 unsigned int n = 0;
750 while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n])++n;
751 return n;
752 }
753
754 //! Get the number of vertex color channels the mesh contains
755 unsigned int GetNumColorChannels() const
756 {
757 unsigned int n = 0;
758 while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n])++n;
759 return n;
760 }
761
762 //! Check whether the mesh contains bones
763 inline bool HasBones() const
764 { return mBones != NULL && mNumBones > 0; }
765
766#endif // __cplusplus
767};
768
769#ifdef __cplusplus
770}
771#endif //! extern "C"
772#endif // AI_MESH_H_INC
773
774