Path Tracer
scene.h
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2020, assimp team
7 
8 
9 
10 All rights reserved.
11 
12 Redistribution and use of this software in source and binary forms,
13 with or without modification, are permitted provided that the following
14 conditions are met:
15 
16 * Redistributions of source code must retain the above
17  copyright notice, this list of conditions and the
18  following disclaimer.
19 
20 * Redistributions in binary form must reproduce the above
21  copyright notice, this list of conditions and the
22  following disclaimer in the documentation and/or other
23  materials provided with the distribution.
24 
25 * Neither the name of the assimp team, nor the names of its
26  contributors may be used to endorse or promote products
27  derived from this software without specific prior
28  written permission of the assimp team.
29 
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ---------------------------------------------------------------------------
42 */
43 
47 #pragma once
48 #ifndef AI_SCENE_H_INC
49 #define AI_SCENE_H_INC
50 
51 #ifdef __GNUC__
52 # pragma GCC system_header
53 #endif
54 
55 #include <assimp/types.h>
56 #include <assimp/texture.h>
57 #include <assimp/mesh.h>
58 #include <assimp/light.h>
59 #include <assimp/camera.h>
60 #include <assimp/material.h>
61 #include <assimp/anim.h>
62 #include <assimp/metadata.h>
63 
64 #ifdef __cplusplus
65 # include <cstdlib>
66 extern "C" {
67 #endif
68 
69 #ifdef __GNUC__
70 #pragma GCC diagnostic push
71 #pragma GCC diagnostic ignored "-Wattributes"
72 #endif
73 
74 // -------------------------------------------------------------------------------
83 // -------------------------------------------------------------------------------
84 struct ASSIMP_API aiNode
85 {
108  C_STRUCT aiString mName;
109 
111  C_STRUCT aiMatrix4x4 mTransformation;
112 
114  C_STRUCT aiNode* mParent;
115 
117  unsigned int mNumChildren;
118 
120  C_STRUCT aiNode** mChildren;
121 
123  unsigned int mNumMeshes;
124 
128  unsigned int* mMeshes;
129 
135  C_STRUCT aiMetadata* mMetaData;
136 
137 #ifdef __cplusplus
138 
139  aiNode();
140 
142  explicit aiNode(const std::string& name);
143 
145  ~aiNode();
146 
154  inline
155  const aiNode* FindNode(const aiString& name) const {
156  return FindNode(name.data);
157  }
158 
159  inline
160  aiNode* FindNode(const aiString& name) {
161  return FindNode(name.data);
162  }
163 
164  const aiNode* FindNode(const char* name) const;
165 
166  aiNode* FindNode(const char* name);
167 
173  void addChildren(unsigned int numChildren, aiNode **children);
174 #endif // __cplusplus
175 };
176 
177 #ifdef __GNUC__
178 #pragma GCC diagnostic pop
179 #endif
180 
181 // -------------------------------------------------------------------------------
188 #define AI_SCENE_FLAGS_INCOMPLETE 0x1
189 
195 #define AI_SCENE_FLAGS_VALIDATED 0x2
196 
205 #define AI_SCENE_FLAGS_VALIDATION_WARNING 0x4
206 
213 #define AI_SCENE_FLAGS_NON_VERBOSE_FORMAT 0x8
214 
227 #define AI_SCENE_FLAGS_TERRAIN 0x10
228 
235 #define AI_SCENE_FLAGS_ALLOW_SHARED 0x20
236 
237 // -------------------------------------------------------------------------------
245 // -------------------------------------------------------------------------------
246 struct aiScene
247 {
253  unsigned int mFlags;
254 
262  C_STRUCT aiNode* mRootNode;
263 
265  unsigned int mNumMeshes;
266 
274  C_STRUCT aiMesh** mMeshes;
275 
277  unsigned int mNumMaterials;
278 
286  C_STRUCT aiMaterial** mMaterials;
287 
289  unsigned int mNumAnimations;
290 
297 
299  unsigned int mNumTextures;
300 
307  C_STRUCT aiTexture** mTextures;
308 
312  unsigned int mNumLights;
313 
319  C_STRUCT aiLight** mLights;
320 
324  unsigned int mNumCameras;
325 
333  C_STRUCT aiCamera** mCameras;
334 
343 
344 
345 #ifdef __cplusplus
346 
348  ASSIMP_API aiScene();
349 
351  ASSIMP_API ~aiScene();
352 
355  inline bool HasMeshes() const {
356  return mMeshes != nullptr && mNumMeshes > 0;
357  }
358 
361  inline bool HasMaterials() const {
362  return mMaterials != nullptr && mNumMaterials > 0;
363  }
364 
366  inline bool HasLights() const {
367  return mLights != nullptr && mNumLights > 0;
368  }
369 
371  inline bool HasTextures() const {
372  return mTextures != nullptr && mNumTextures > 0;
373  }
374 
376  inline bool HasCameras() const {
377  return mCameras != nullptr && mNumCameras > 0;
378  }
379 
381  inline bool HasAnimations() const {
382  return mAnimations != nullptr && mNumAnimations > 0;
383  }
384 
386  static const char* GetShortFilename(const char* filename) {
387  const char* lastSlash = strrchr(filename, '/');
388  if (lastSlash == nullptr) {
389  lastSlash = strrchr(filename, '\\');
390  }
391  const char* shortFilename = lastSlash != nullptr ? lastSlash + 1 : filename;
392  return shortFilename;
393  }
394 
396  const aiTexture* GetEmbeddedTexture(const char* filename) const {
397  // lookup using texture ID (if referenced like: "*1", "*2", etc.)
398  if ('*' == *filename) {
399  int index = std::atoi(filename + 1);
400  if (0 > index || mNumTextures <= static_cast<unsigned>(index))
401  return nullptr;
402  return mTextures[index];
403  }
404  // lookup using filename
405  const char* shortFilename = GetShortFilename(filename);
406  for (unsigned int i = 0; i < mNumTextures; i++) {
407  const char* shortTextureFilename = GetShortFilename(mTextures[i]->mFilename.C_Str());
408  if (strcmp(shortTextureFilename, shortFilename) == 0) {
409  return mTextures[i];
410  }
411  }
412  return nullptr;
413  }
414 #endif // __cplusplus
415 
417 #ifdef __cplusplus
418  void* mPrivate;
419 #else
420  char* mPrivate;
421 #endif
422 
423 };
424 
425 #ifdef __cplusplus
426 }
427 #endif
428 
429 #endif // AI_SCENE_H_INC
anim.h
Defines the data structures in which the imported animations are returned.
aiTexture
Definition: texture.h:135
aiScene::mNumMeshes
unsigned int mNumMeshes
Definition: scene.h:265
types.h
aiNode
Definition: scene.h:85
aiLight
Definition: light.h:119
aiScene::mMetaData
C_STRUCT aiMetadata * mMetaData
The global metadata assigned to the scene itself.
Definition: scene.h:342
aiScene::mCameras
C_STRUCT aiCamera ** mCameras
Definition: scene.h:333
aiNode::mMeshes
unsigned int * mMeshes
Definition: scene.h:128
aiScene::mPrivate
char * mPrivate
Definition: scene.h:420
aiCamera
Definition: camera.h:104
aiScene::mTextures
C_STRUCT aiTexture ** mTextures
Definition: scene.h:307
light.h
Defines the aiLight data structure.
aiScene::mNumTextures
unsigned int mNumTextures
Definition: scene.h:299
material.h
Defines the material system of the library.
aiScene::mMeshes
C_STRUCT aiMesh ** mMeshes
Definition: scene.h:274
aiScene::mLights
C_STRUCT aiLight ** mLights
Definition: scene.h:319
aiScene::mNumLights
unsigned int mNumLights
Definition: scene.h:312
aiMaterial
Data structure for a material.
Definition: material.h:672
aiScene::mRootNode
C_STRUCT aiNode * mRootNode
Definition: scene.h:262
mesh.h
Declares the data structures in which the imported geometry is returned by ASSIMP: aiMesh,...
aiScene::mFlags
unsigned int mFlags
Definition: scene.h:253
aiString
Definition: types.h:266
camera.h
Defines the aiCamera data structure.
aiNode::mNumChildren
unsigned int mNumChildren
Definition: scene.h:117
aiString::data
char data[MAXLEN]
Definition: types.h:390
aiMetadata
Definition: metadata.h:146
aiScene::mNumCameras
unsigned int mNumCameras
Definition: scene.h:324
texture.h
Defines texture helper structures for the library.
aiScene::mMaterials
C_STRUCT aiMaterial ** mMaterials
Definition: scene.h:286
metadata.h
Defines the data structures for holding node meta information.
aiAnimation
Definition: anim.h:398
aiMatrix4x4
Definition: matrix4x4.h:266
aiNode::mNumMeshes
unsigned int mNumMeshes
Definition: scene.h:123
aiScene::mAnimations
C_STRUCT aiAnimation ** mAnimations
Definition: scene.h:296
aiScene::mNumAnimations
unsigned int mNumAnimations
Definition: scene.h:289
aiScene::mNumMaterials
unsigned int mNumMaterials
Definition: scene.h:277
aiScene
Definition: scene.h:247
aiMesh
enum aiMorphingMethod
Definition: mesh.h:575