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