vrshoot

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