BRE12
scene.h
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2012, assimp team
7 
8 All rights reserved.
9 
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:
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 
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 */
41 
45 #ifndef __AI_SCENE_H_INC__
46 #define __AI_SCENE_H_INC__
47 
48 #include "types.h"
49 #include "texture.h"
50 #include "mesh.h"
51 #include "light.h"
52 #include "camera.h"
53 #include "material.h"
54 #include "anim.h"
55 #include "metadata.h"
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 
62 // -------------------------------------------------------------------------------
70 // -------------------------------------------------------------------------------
71 struct aiNode
72 {
95  C_STRUCT aiString mName;
96 
98  C_STRUCT aiMatrix4x4 mTransformation;
99 
101  C_STRUCT aiNode* mParent;
102 
104  unsigned int mNumChildren;
105 
107  C_STRUCT aiNode** mChildren;
108 
110  unsigned int mNumMeshes;
111 
113  unsigned int* mMeshes;
114 
120  C_STRUCT aiMetadata* mMetaData;
121 
122 #ifdef __cplusplus
123 
124  aiNode()
125  // set all members to zero by default
126  : mName("")
127  , mParent(NULL)
128  , mNumChildren(0)
129  , mChildren(NULL)
130  , mNumMeshes(0)
131  , mMeshes(NULL)
132  , mMetaData(NULL)
133  {
134  }
135 
136 
138  aiNode(const std::string& name)
139  // set all members to zero by default
140  : mName(name)
141  , mParent(NULL)
142  , mNumChildren(0)
143  , mChildren(NULL)
144  , mNumMeshes(0)
145  , mMeshes(NULL)
146  , mMetaData(NULL)
147  {
148  }
149 
151  ~aiNode()
152  {
153  // delete all children recursively
154  // to make sure we won't crash if the data is invalid ...
155  if (mChildren && mNumChildren)
156  {
157  for( unsigned int a = 0; a < mNumChildren; a++)
158  delete mChildren[a];
159  }
160  delete [] mChildren;
161  delete [] mMeshes;
162  delete mMetaData;
163  }
164 
165 
173  inline const aiNode* FindNode(const aiString& name) const
174  {
175  return FindNode(name.data);
176  }
177 
178 
179  inline aiNode* FindNode(const aiString& name)
180  {
181  return FindNode(name.data);
182  }
183 
184 
187  inline const aiNode* FindNode(const char* name) const
188  {
189  if (!::strcmp( mName.data,name))return this;
190  for (unsigned int i = 0; i < mNumChildren;++i)
191  {
192  const aiNode* const p = mChildren[i]->FindNode(name);
193  if (p) {
194  return p;
195  }
196  }
197  // there is definitely no sub-node with this name
198  return NULL;
199  }
200 
201  inline aiNode* FindNode(const char* name)
202  {
203  if (!::strcmp( mName.data,name))return this;
204  for (unsigned int i = 0; i < mNumChildren;++i)
205  {
206  aiNode* const p = mChildren[i]->FindNode(name);
207  if (p) {
208  return p;
209  }
210  }
211  // there is definitely no sub-node with this name
212  return NULL;
213  }
214 
215 #endif // __cplusplus
216 };
217 
218 
219 // -------------------------------------------------------------------------------
226 #define AI_SCENE_FLAGS_INCOMPLETE 0x1
227 
233 #define AI_SCENE_FLAGS_VALIDATED 0x2
234 
243 #define AI_SCENE_FLAGS_VALIDATION_WARNING 0x4
244 
251 #define AI_SCENE_FLAGS_NON_VERBOSE_FORMAT 0x8
252 
265 #define AI_SCENE_FLAGS_TERRAIN 0x10
266 
267 
268 // -------------------------------------------------------------------------------
276 // -------------------------------------------------------------------------------
277 struct aiScene
278 {
279 
285  unsigned int mFlags;
286 
287 
295  C_STRUCT aiNode* mRootNode;
296 
297 
298 
300  unsigned int mNumMeshes;
301 
309  C_STRUCT aiMesh** mMeshes;
310 
311 
312 
314  unsigned int mNumMaterials;
315 
323  C_STRUCT aiMaterial** mMaterials;
324 
325 
326 
328  unsigned int mNumAnimations;
329 
335  C_STRUCT aiAnimation** mAnimations;
336 
337 
338 
340  unsigned int mNumTextures;
341 
348  C_STRUCT aiTexture** mTextures;
349 
350 
354  unsigned int mNumLights;
355 
361  C_STRUCT aiLight** mLights;
362 
363 
367  unsigned int mNumCameras;
368 
376  C_STRUCT aiCamera** mCameras;
377 
378 #ifdef __cplusplus
379 
381  ASSIMP_API aiScene();
382 
384  ASSIMP_API ~aiScene();
385 
388  inline bool HasMeshes() const
389  { return mMeshes != NULL && mNumMeshes > 0; }
390 
393  inline bool HasMaterials() const
394  { return mMaterials != NULL && mNumMaterials > 0; }
395 
397  inline bool HasLights() const
398  { return mLights != NULL && mNumLights > 0; }
399 
401  inline bool HasTextures() const
402  { return mTextures != NULL && mNumTextures > 0; }
403 
405  inline bool HasCameras() const
406  { return mCameras != NULL && mNumCameras > 0; }
407 
409  inline bool HasAnimations() const
410  { return mAnimations != NULL && mNumAnimations > 0; }
411 
412 #endif // __cplusplus
413 
414 
416 #ifdef __cplusplus
417  void* mPrivate;
418 #else
419  char* mPrivate;
420 #endif
421 
422 };
423 
424 #ifdef __cplusplus
425 }
426 #endif
427 
428 #endif // __AI_SCENE_H_INC__
Basic data types and primitives, such as vectors or colors.
Defines the material system of the library.
Definition: matrix4x4.h:236
A mesh represents a geometry or model with a single material.
Definition: mesh.h:467
Helper structure to describe a light source.
Definition: light.h:100
Defines the aiCamera data structure.
Helper structure to describe a virtual camera.
Definition: camera.h:98
Defines the data structures for holding node meta information.
Declares the data structures in which the imported geometry is returned by ASSIMP: aiMesh...
Defines texture helper structures for the library.
Defines the aiLight data structure.
Represents an UTF-8 string, zero byte terminated.
Definition: types.h:251
Defines the data structures in which the imported animations are returned.
Helper structure to describe an embedded texture.
Definition: texture.h:120
char data[MAXLEN]
String buffer.
Definition: types.h:366
Container for holding metadata.
Definition: metadata.h:125