vrshoot

view libs/assimp/assimp/scene.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 aiScene.h
43 * @brief Defines the data structures in which the imported scene is returned.
44 */
45 #ifndef __AI_SCENE_H_INC__
46 #define __AI_SCENE_H_INC__
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"
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
62 // -------------------------------------------------------------------------------
63 /** A node in the imported hierarchy.
64 *
65 * Each node has name, a parent node (except for the root node),
66 * a transformation relative to its parent and possibly several child nodes.
67 * Simple file formats don't support hierarchical structures - for these formats
68 * the imported scene does consist of only a single root node without children.
69 */
70 // -------------------------------------------------------------------------------
71 struct aiNode
72 {
73 /** The name of the node.
74 *
75 * The name might be empty (length of zero) but all nodes which
76 * need to be referenced by either bones or animations are named.
77 * Multiple nodes may have the same name, except for nodes which are referenced
78 * by bones (see #aiBone and #aiMesh::mBones). Their names *must* be unique.
79 *
80 * Cameras and lights reference a specific node by name - if there
81 * are multiple nodes with this name, they are assigned to each of them.
82 * <br>
83 * There are no limitations with regard to the characters contained in
84 * the name string as it is usually taken directly from the source file.
85 *
86 * Implementations should be able to handle tokens such as whitespace, tabs,
87 * line feeds, quotation marks, ampersands etc.
88 *
89 * Sometimes assimp introduces new nodes not present in the source file
90 * into the hierarchy (usually out of necessity because sometimes the
91 * source hierarchy format is simply not compatible). Their names are
92 * surrounded by @verbatim <> @endverbatim e.g.
93 * @verbatim<DummyRootNode> @endverbatim.
94 */
95 C_STRUCT aiString mName;
97 /** The transformation relative to the node's parent. */
98 C_STRUCT aiMatrix4x4 mTransformation;
100 /** Parent node. NULL if this node is the root node. */
101 C_STRUCT aiNode* mParent;
103 /** The number of child nodes of this node. */
104 unsigned int mNumChildren;
106 /** The child nodes of this node. NULL if mNumChildren is 0. */
107 C_STRUCT aiNode** mChildren;
109 /** The number of meshes of this node. */
110 unsigned int mNumMeshes;
112 /** The meshes of this node. Each entry is an index into the mesh */
113 unsigned int* mMeshes;
115 /** Metadata associated with this node or NULL if there is no metadata.
116 * Whether any metadata is generated depends on the source file format. See the
117 * @link importer_notes @endlink page for more information on every source file
118 * format. Importers that don't document any metadata don't write any.
119 */
120 C_STRUCT aiMetadata* mMetaData;
122 #ifdef __cplusplus
123 /** Constructor */
124 aiNode()
125 // set all members to zero by default
126 : mName()
127 , mParent()
128 , mNumChildren()
129 , mChildren()
130 , mNumMeshes()
131 , mMeshes()
132 , mMetaData()
133 {
134 }
137 /** Construction from a specific name */
138 aiNode(const std::string& name)
139 // set all members to zero by default
140 : mName(name)
141 , mParent()
142 , mNumChildren()
143 , mChildren()
144 , mNumMeshes()
145 , mMeshes()
146 , mMetaData()
147 {
148 }
150 /** Destructor */
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 }
166 /** Searches for a node with a specific name, beginning at this
167 * nodes. Normally you will call this method on the root node
168 * of the scene.
169 *
170 * @param name Name to search for
171 * @return NULL or a valid Node if the search was successful.
172 */
173 inline const aiNode* FindNode(const aiString& name) const
174 {
175 return FindNode(name.data);
176 }
179 inline aiNode* FindNode(const aiString& name)
180 {
181 return FindNode(name.data);
182 }
185 /** @override
186 */
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 }
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 }
215 #endif // __cplusplus
216 };
219 // -------------------------------------------------------------------------------
220 /** @def AI_SCENE_FLAGS_INCOMPLETE
221 * Specifies that the scene data structure that was imported is not complete.
222 * This flag bypasses some internal validations and allows the import
223 * of animation skeletons, material libraries or camera animation paths
224 * using Assimp. Most applications won't support such data.
225 */
226 #define AI_SCENE_FLAGS_INCOMPLETE 0x1
228 /** @def AI_SCENE_FLAGS_VALIDATED
229 * This flag is set by the validation postprocess-step (aiPostProcess_ValidateDS)
230 * if the validation is successful. In a validated scene you can be sure that
231 * any cross references in the data structure (e.g. vertex indices) are valid.
232 */
233 #define AI_SCENE_FLAGS_VALIDATED 0x2
235 /** @def AI_SCENE_FLAGS_VALIDATION_WARNING
236 * This flag is set by the validation postprocess-step (aiPostProcess_ValidateDS)
237 * if the validation is successful but some issues have been found.
238 * This can for example mean that a texture that does not exist is referenced
239 * by a material or that the bone weights for a vertex don't sum to 1.0 ... .
240 * In most cases you should still be able to use the import. This flag could
241 * be useful for applications which don't capture Assimp's log output.
242 */
243 #define AI_SCENE_FLAGS_VALIDATION_WARNING 0x4
245 /** @def AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
246 * This flag is currently only set by the aiProcess_JoinIdenticalVertices step.
247 * It indicates that the vertices of the output meshes aren't in the internal
248 * verbose format anymore. In the verbose format all vertices are unique,
249 * no vertex is ever referenced by more than one face.
250 */
251 #define AI_SCENE_FLAGS_NON_VERBOSE_FORMAT 0x8
253 /** @def AI_SCENE_FLAGS_TERRAIN
254 * Denotes pure height-map terrain data. Pure terrains usually consist of quads,
255 * sometimes triangles, in a regular grid. The x,y coordinates of all vertex
256 * positions refer to the x,y coordinates on the terrain height map, the z-axis
257 * stores the elevation at a specific point.
258 *
259 * TER (Terragen) and HMP (3D Game Studio) are height map formats.
260 * @note Assimp is probably not the best choice for loading *huge* terrains -
261 * fully triangulated data takes extremely much free store and should be avoided
262 * as long as possible (typically you'll do the triangulation when you actually
263 * need to render it).
264 */
265 #define AI_SCENE_FLAGS_TERRAIN 0x10
268 // -------------------------------------------------------------------------------
269 /** The root structure of the imported data.
270 *
271 * Everything that was imported from the given file can be accessed from here.
272 * Objects of this class are generally maintained and owned by Assimp, not
273 * by the caller. You shouldn't want to instance it, nor should you ever try to
274 * delete a given scene on your own.
275 */
276 // -------------------------------------------------------------------------------
277 struct aiScene
278 {
280 /** Any combination of the AI_SCENE_FLAGS_XXX flags. By default
281 * this value is 0, no flags are set. Most applications will
282 * want to reject all scenes with the AI_SCENE_FLAGS_INCOMPLETE
283 * bit set.
284 */
285 unsigned int mFlags;
288 /** The root node of the hierarchy.
289 *
290 * There will always be at least the root node if the import
291 * was successful (and no special flags have been set).
292 * Presence of further nodes depends on the format and content
293 * of the imported file.
294 */
295 C_STRUCT aiNode* mRootNode;
299 /** The number of meshes in the scene. */
300 unsigned int mNumMeshes;
302 /** The array of meshes.
303 *
304 * Use the indices given in the aiNode structure to access
305 * this array. The array is mNumMeshes in size. If the
306 * AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always
307 * be at least ONE material.
308 */
309 C_STRUCT aiMesh** mMeshes;
313 /** The number of materials in the scene. */
314 unsigned int mNumMaterials;
316 /** The array of materials.
317 *
318 * Use the index given in each aiMesh structure to access this
319 * array. The array is mNumMaterials in size. If the
320 * AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always
321 * be at least ONE material.
322 */
323 C_STRUCT aiMaterial** mMaterials;
327 /** The number of animations in the scene. */
328 unsigned int mNumAnimations;
330 /** The array of animations.
331 *
332 * All animations imported from the given file are listed here.
333 * The array is mNumAnimations in size.
334 */
335 C_STRUCT aiAnimation** mAnimations;
339 /** The number of textures embedded into the file */
340 unsigned int mNumTextures;
342 /** The array of embedded textures.
343 *
344 * Not many file formats embed their textures into the file.
345 * An example is Quake's MDL format (which is also used by
346 * some GameStudio versions)
347 */
348 C_STRUCT aiTexture** mTextures;
351 /** The number of light sources in the scene. Light sources
352 * are fully optional, in most cases this attribute will be 0
353 */
354 unsigned int mNumLights;
356 /** The array of light sources.
357 *
358 * All light sources imported from the given file are
359 * listed here. The array is mNumLights in size.
360 */
361 C_STRUCT aiLight** mLights;
364 /** The number of cameras in the scene. Cameras
365 * are fully optional, in most cases this attribute will be 0
366 */
367 unsigned int mNumCameras;
369 /** The array of cameras.
370 *
371 * All cameras imported from the given file are listed here.
372 * The array is mNumCameras in size. The first camera in the
373 * array (if existing) is the default camera view into
374 * the scene.
375 */
376 C_STRUCT aiCamera** mCameras;
378 #ifdef __cplusplus
380 //! Default constructor - set everything to 0/NULL
381 aiScene();
383 //! Destructor
384 ~aiScene();
386 //! Check whether the scene contains meshes
387 //! Unless no special scene flags are set this will always be true.
388 inline bool HasMeshes() const
389 { return mMeshes != NULL && mNumMeshes > 0; }
391 //! Check whether the scene contains materials
392 //! Unless no special scene flags are set this will always be true.
393 inline bool HasMaterials() const
394 { return mMaterials != NULL && mNumMaterials > 0; }
396 //! Check whether the scene contains lights
397 inline bool HasLights() const
398 { return mLights != NULL && mNumLights > 0; }
400 //! Check whether the scene contains textures
401 inline bool HasTextures() const
402 { return mTextures != NULL && mNumTextures > 0; }
404 //! Check whether the scene contains cameras
405 inline bool HasCameras() const
406 { return mCameras != NULL && mNumCameras > 0; }
408 //! Check whether the scene contains animations
409 inline bool HasAnimations() const
410 { return mAnimations != NULL && mNumAnimations > 0; }
412 #endif // __cplusplus
415 /** Internal data, do not touch */
416 #ifdef __cplusplus
417 void* mPrivate;
418 #else
419 char* mPrivate;
420 #endif
422 };
424 #ifdef __cplusplus
425 } //! namespace Assimp
426 #endif
428 #endif // __AI_SCENE_H_INC__