vrshoot

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