vrshoot

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/assimp/assimp/scene.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,428 @@
     1.4 +/*
     1.5 +---------------------------------------------------------------------------
     1.6 +Open Asset Import Library (assimp)
     1.7 +---------------------------------------------------------------------------
     1.8 +
     1.9 +Copyright (c) 2006-2012, assimp team
    1.10 +
    1.11 +All rights reserved.
    1.12 +
    1.13 +Redistribution and use of this software in source and binary forms, 
    1.14 +with or without modification, are permitted provided that the following 
    1.15 +conditions are met:
    1.16 +
    1.17 +* Redistributions of source code must retain the above
    1.18 +  copyright notice, this list of conditions and the
    1.19 +  following disclaimer.
    1.20 +
    1.21 +* Redistributions in binary form must reproduce the above
    1.22 +  copyright notice, this list of conditions and the
    1.23 +  following disclaimer in the documentation and/or other
    1.24 +  materials provided with the distribution.
    1.25 +
    1.26 +* Neither the name of the assimp team, nor the names of its
    1.27 +  contributors may be used to endorse or promote products
    1.28 +  derived from this software without specific prior
    1.29 +  written permission of the assimp team.
    1.30 +
    1.31 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    1.32 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    1.33 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.34 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    1.35 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.36 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    1.37 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.38 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    1.39 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    1.40 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    1.41 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.42 +---------------------------------------------------------------------------
    1.43 +*/
    1.44 +
    1.45 +/** @file aiScene.h
    1.46 + *  @brief Defines the data structures in which the imported scene is returned.
    1.47 + */
    1.48 +#ifndef __AI_SCENE_H_INC__
    1.49 +#define __AI_SCENE_H_INC__
    1.50 +
    1.51 +#include "types.h"
    1.52 +#include "texture.h"
    1.53 +#include "mesh.h"
    1.54 +#include "light.h"
    1.55 +#include "camera.h"
    1.56 +#include "material.h"
    1.57 +#include "anim.h"
    1.58 +#include "metadata.h"
    1.59 +
    1.60 +#ifdef __cplusplus
    1.61 +extern "C" {
    1.62 +#endif
    1.63 +
    1.64 +
    1.65 +// -------------------------------------------------------------------------------
    1.66 +/** A node in the imported hierarchy. 
    1.67 + *
    1.68 + * Each node has name, a parent node (except for the root node), 
    1.69 + * a transformation relative to its parent and possibly several child nodes.
    1.70 + * Simple file formats don't support hierarchical structures - for these formats 
    1.71 + * the imported scene does consist of only a single root node without children.
    1.72 + */
    1.73 +// -------------------------------------------------------------------------------
    1.74 +struct aiNode
    1.75 +{
    1.76 +	/** The name of the node. 
    1.77 +	 *
    1.78 +	 * The name might be empty (length of zero) but all nodes which 
    1.79 +	 * need to be referenced by either bones or animations are named.
    1.80 +	 * Multiple nodes may have the same name, except for nodes which are referenced
    1.81 +	 * by bones (see #aiBone and #aiMesh::mBones). Their names *must* be unique.
    1.82 +	 * 
    1.83 +	 * Cameras and lights reference a specific node by name - if there
    1.84 +	 * are multiple nodes with this name, they are assigned to each of them.
    1.85 +	 * <br>
    1.86 +	 * There are no limitations with regard to the characters contained in
    1.87 +	 * the name string as it is usually taken directly from the source file. 
    1.88 +	 * 
    1.89 +	 * Implementations should be able to handle tokens such as whitespace, tabs,
    1.90 +	 * line feeds, quotation marks, ampersands etc.
    1.91 +	 *
    1.92 +	 * Sometimes assimp introduces new nodes not present in the source file
    1.93 +	 * into the hierarchy (usually out of necessity because sometimes the
    1.94 +	 * source hierarchy format is simply not compatible). Their names are
    1.95 +	 * surrounded by @verbatim <> @endverbatim e.g.
    1.96 +	 *  @verbatim<DummyRootNode> @endverbatim.
    1.97 +	 */
    1.98 +	C_STRUCT aiString mName;
    1.99 +
   1.100 +	/** The transformation relative to the node's parent. */
   1.101 +	C_STRUCT aiMatrix4x4 mTransformation;
   1.102 +
   1.103 +	/** Parent node. NULL if this node is the root node. */
   1.104 +	C_STRUCT aiNode* mParent;
   1.105 +
   1.106 +	/** The number of child nodes of this node. */
   1.107 +	unsigned int mNumChildren;
   1.108 +
   1.109 +	/** The child nodes of this node. NULL if mNumChildren is 0. */
   1.110 +	C_STRUCT aiNode** mChildren;
   1.111 +
   1.112 +	/** The number of meshes of this node. */
   1.113 +	unsigned int mNumMeshes;
   1.114 +
   1.115 +	/** The meshes of this node. Each entry is an index into the mesh */
   1.116 +	unsigned int* mMeshes;
   1.117 +
   1.118 +	/** Metadata associated with this node or NULL if there is no metadata.
   1.119 +	  *  Whether any metadata is generated depends on the source file format. See the
   1.120 +	  * @link importer_notes @endlink page for more information on every source file
   1.121 +	  * format. Importers that don't document any metadata don't write any. 
   1.122 +	  */
   1.123 +	C_STRUCT aiMetadata* mMetaData;
   1.124 +
   1.125 +#ifdef __cplusplus
   1.126 +	/** Constructor */
   1.127 +	aiNode() 
   1.128 +		// set all members to zero by default
   1.129 +		: mName()
   1.130 +		, mParent()
   1.131 +		, mNumChildren()
   1.132 +		, mChildren()
   1.133 +		, mNumMeshes()
   1.134 +		, mMeshes()
   1.135 +		, mMetaData()
   1.136 +	{
   1.137 +	}
   1.138 +	
   1.139 +
   1.140 +	/** Construction from a specific name */
   1.141 +	aiNode(const std::string& name) 
   1.142 +		// set all members to zero by default
   1.143 +		: mName(name)
   1.144 +		, mParent()
   1.145 +		, mNumChildren()
   1.146 +		, mChildren()
   1.147 +		, mNumMeshes()
   1.148 +		, mMeshes()
   1.149 +		, mMetaData()
   1.150 +	{
   1.151 +	}
   1.152 +
   1.153 +	/** Destructor */
   1.154 +	~aiNode()
   1.155 +	{
   1.156 +		// delete all children recursively
   1.157 +		// to make sure we won't crash if the data is invalid ...
   1.158 +		if (mChildren && mNumChildren)  
   1.159 +		{
   1.160 +			for( unsigned int a = 0; a < mNumChildren; a++)
   1.161 +				delete mChildren[a];
   1.162 +		}
   1.163 +		delete [] mChildren;
   1.164 +		delete [] mMeshes;
   1.165 +		delete mMetaData;
   1.166 +	}
   1.167 +
   1.168 +
   1.169 +	/** Searches for a node with a specific name, beginning at this
   1.170 +	 *  nodes. Normally you will call this method on the root node
   1.171 +	 *  of the scene.
   1.172 +	 * 
   1.173 +	 *  @param name Name to search for
   1.174 +	 *  @return NULL or a valid Node if the search was successful.
   1.175 +	 */
   1.176 +	inline const aiNode* FindNode(const aiString& name) const
   1.177 +	{
   1.178 +		return FindNode(name.data);
   1.179 +	}
   1.180 +
   1.181 +
   1.182 +	inline aiNode* FindNode(const aiString& name)
   1.183 +	{
   1.184 +		return FindNode(name.data);
   1.185 +	}
   1.186 +
   1.187 +
   1.188 +	/** @override
   1.189 +	 */
   1.190 +	inline const aiNode* FindNode(const char* name) const
   1.191 +	{
   1.192 +		if (!::strcmp( mName.data,name))return this;
   1.193 +		for (unsigned int i = 0; i < mNumChildren;++i)
   1.194 +		{
   1.195 +			const aiNode* const p = mChildren[i]->FindNode(name);
   1.196 +			if (p) {
   1.197 +				return p;
   1.198 +			}
   1.199 +		}
   1.200 +		// there is definitely no sub-node with this name
   1.201 +		return NULL;
   1.202 +	}
   1.203 +
   1.204 +	inline aiNode* FindNode(const char* name) 
   1.205 +	{
   1.206 +		if (!::strcmp( mName.data,name))return this;
   1.207 +		for (unsigned int i = 0; i < mNumChildren;++i)
   1.208 +		{
   1.209 +			aiNode* const p = mChildren[i]->FindNode(name);
   1.210 +			if (p) {
   1.211 +				return p;
   1.212 +			}
   1.213 +		}
   1.214 +		// there is definitely no sub-node with this name
   1.215 +		return NULL;
   1.216 +	}
   1.217 +
   1.218 +#endif // __cplusplus
   1.219 +};
   1.220 +
   1.221 +
   1.222 +// -------------------------------------------------------------------------------
   1.223 +/** @def AI_SCENE_FLAGS_INCOMPLETE
   1.224 + * Specifies that the scene data structure that was imported is not complete.
   1.225 + * This flag bypasses some internal validations and allows the import 
   1.226 + * of animation skeletons, material libraries or camera animation paths 
   1.227 + * using Assimp. Most applications won't support such data. 
   1.228 + */
   1.229 +#define AI_SCENE_FLAGS_INCOMPLETE	0x1
   1.230 +
   1.231 +/** @def AI_SCENE_FLAGS_VALIDATED
   1.232 + * This flag is set by the validation postprocess-step (aiPostProcess_ValidateDS)
   1.233 + * if the validation is successful. In a validated scene you can be sure that
   1.234 + * any cross references in the data structure (e.g. vertex indices) are valid.
   1.235 + */
   1.236 +#define AI_SCENE_FLAGS_VALIDATED	0x2
   1.237 +
   1.238 +/** @def AI_SCENE_FLAGS_VALIDATION_WARNING
   1.239 + * This flag is set by the validation postprocess-step (aiPostProcess_ValidateDS)
   1.240 + * if the validation is successful but some issues have been found.
   1.241 + * This can for example mean that a texture that does not exist is referenced 
   1.242 + * by a material or that the bone weights for a vertex don't sum to 1.0 ... .
   1.243 + * In most cases you should still be able to use the import. This flag could
   1.244 + * be useful for applications which don't capture Assimp's log output.
   1.245 + */
   1.246 +#define AI_SCENE_FLAGS_VALIDATION_WARNING  	0x4
   1.247 +
   1.248 +/** @def AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
   1.249 + * This flag is currently only set by the aiProcess_JoinIdenticalVertices step.
   1.250 + * It indicates that the vertices of the output meshes aren't in the internal
   1.251 + * verbose format anymore. In the verbose format all vertices are unique,
   1.252 + * no vertex is ever referenced by more than one face.
   1.253 + */
   1.254 +#define AI_SCENE_FLAGS_NON_VERBOSE_FORMAT  	0x8
   1.255 +
   1.256 + /** @def AI_SCENE_FLAGS_TERRAIN
   1.257 + * Denotes pure height-map terrain data. Pure terrains usually consist of quads, 
   1.258 + * sometimes triangles, in a regular grid. The x,y coordinates of all vertex 
   1.259 + * positions refer to the x,y coordinates on the terrain height map, the z-axis
   1.260 + * stores the elevation at a specific point.
   1.261 + *
   1.262 + * TER (Terragen) and HMP (3D Game Studio) are height map formats.
   1.263 + * @note Assimp is probably not the best choice for loading *huge* terrains -
   1.264 + * fully triangulated data takes extremely much free store and should be avoided
   1.265 + * as long as possible (typically you'll do the triangulation when you actually
   1.266 + * need to render it).
   1.267 + */
   1.268 +#define AI_SCENE_FLAGS_TERRAIN 0x10
   1.269 +
   1.270 +
   1.271 +// -------------------------------------------------------------------------------
   1.272 +/** The root structure of the imported data. 
   1.273 + * 
   1.274 + *  Everything that was imported from the given file can be accessed from here.
   1.275 + *  Objects of this class are generally maintained and owned by Assimp, not
   1.276 + *  by the caller. You shouldn't want to instance it, nor should you ever try to
   1.277 + *  delete a given scene on your own.
   1.278 + */
   1.279 +// -------------------------------------------------------------------------------
   1.280 +struct aiScene
   1.281 +{
   1.282 +
   1.283 +	/** Any combination of the AI_SCENE_FLAGS_XXX flags. By default 
   1.284 +	* this value is 0, no flags are set. Most applications will
   1.285 +	* want to reject all scenes with the AI_SCENE_FLAGS_INCOMPLETE 
   1.286 +	* bit set.
   1.287 +	*/
   1.288 +	unsigned int mFlags;
   1.289 +
   1.290 +
   1.291 +	/** The root node of the hierarchy. 
   1.292 +	* 
   1.293 +	* There will always be at least the root node if the import
   1.294 +	* was successful (and no special flags have been set). 
   1.295 +	* Presence of further nodes depends on the format and content 
   1.296 +	* of the imported file.
   1.297 +	*/
   1.298 +	C_STRUCT aiNode* mRootNode;
   1.299 +
   1.300 +
   1.301 +
   1.302 +	/** The number of meshes in the scene. */
   1.303 +	unsigned int mNumMeshes;
   1.304 +
   1.305 +	/** The array of meshes. 
   1.306 +	*
   1.307 +	* Use the indices given in the aiNode structure to access 
   1.308 +	* this array. The array is mNumMeshes in size. If the
   1.309 +	* AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always 
   1.310 +	* be at least ONE material.
   1.311 +	*/
   1.312 +	C_STRUCT aiMesh** mMeshes;
   1.313 +
   1.314 +
   1.315 +
   1.316 +	/** The number of materials in the scene. */
   1.317 +	unsigned int mNumMaterials;
   1.318 +
   1.319 +	/** The array of materials. 
   1.320 +	* 
   1.321 +	* Use the index given in each aiMesh structure to access this
   1.322 +	* array. The array is mNumMaterials in size. If the
   1.323 +	* AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always 
   1.324 +	* be at least ONE material.
   1.325 +	*/
   1.326 +	C_STRUCT aiMaterial** mMaterials;
   1.327 +
   1.328 +
   1.329 +
   1.330 +	/** The number of animations in the scene. */
   1.331 +	unsigned int mNumAnimations; 
   1.332 +
   1.333 +	/** The array of animations. 
   1.334 +	*
   1.335 +	* All animations imported from the given file are listed here.
   1.336 +	* The array is mNumAnimations in size.
   1.337 +	*/
   1.338 +	C_STRUCT aiAnimation** mAnimations;
   1.339 +
   1.340 +
   1.341 +
   1.342 +	/** The number of textures embedded into the file */
   1.343 +	unsigned int mNumTextures;
   1.344 +
   1.345 +	/** The array of embedded textures.
   1.346 +	* 
   1.347 +	* Not many file formats embed their textures into the file.
   1.348 +	* An example is Quake's MDL format (which is also used by
   1.349 +	* some GameStudio versions)
   1.350 +	*/
   1.351 +	C_STRUCT aiTexture** mTextures;
   1.352 +
   1.353 +
   1.354 +	/** The number of light sources in the scene. Light sources
   1.355 +	* are fully optional, in most cases this attribute will be 0 
   1.356 +        */
   1.357 +	unsigned int mNumLights;
   1.358 +
   1.359 +	/** The array of light sources.
   1.360 +	* 
   1.361 +	* All light sources imported from the given file are
   1.362 +	* listed here. The array is mNumLights in size.
   1.363 +	*/
   1.364 +	C_STRUCT aiLight** mLights;
   1.365 +
   1.366 +
   1.367 +	/** The number of cameras in the scene. Cameras
   1.368 +	* are fully optional, in most cases this attribute will be 0 
   1.369 +        */
   1.370 +	unsigned int mNumCameras;
   1.371 +
   1.372 +	/** The array of cameras.
   1.373 +	* 
   1.374 +	* All cameras imported from the given file are listed here.
   1.375 +	* The array is mNumCameras in size. The first camera in the
   1.376 +	* array (if existing) is the default camera view into
   1.377 +	* the scene.
   1.378 +	*/
   1.379 +	C_STRUCT aiCamera** mCameras;
   1.380 +
   1.381 +#ifdef __cplusplus
   1.382 +
   1.383 +	//! Default constructor - set everything to 0/NULL
   1.384 +	aiScene();
   1.385 +
   1.386 +	//! Destructor
   1.387 +	~aiScene();
   1.388 +
   1.389 +	//! Check whether the scene contains meshes
   1.390 +	//! Unless no special scene flags are set this will always be true.
   1.391 +	inline bool HasMeshes() const 
   1.392 +		{ return mMeshes != NULL && mNumMeshes > 0; }
   1.393 +
   1.394 +	//! Check whether the scene contains materials
   1.395 +	//! Unless no special scene flags are set this will always be true.
   1.396 +	inline bool HasMaterials() const 
   1.397 +		{ return mMaterials != NULL && mNumMaterials > 0; }
   1.398 +
   1.399 +	//! Check whether the scene contains lights
   1.400 +	inline bool HasLights() const 
   1.401 +		{ return mLights != NULL && mNumLights > 0; }
   1.402 +
   1.403 +	//! Check whether the scene contains textures
   1.404 +	inline bool HasTextures() const 
   1.405 +		{ return mTextures != NULL && mNumTextures > 0; }
   1.406 +
   1.407 +	//! Check whether the scene contains cameras
   1.408 +	inline bool HasCameras() const 
   1.409 +		{ return mCameras != NULL && mNumCameras > 0; }
   1.410 +
   1.411 +	//! Check whether the scene contains animations
   1.412 +	inline bool HasAnimations() const 
   1.413 +		{ return mAnimations != NULL && mNumAnimations > 0; }
   1.414 +
   1.415 +#endif // __cplusplus
   1.416 +
   1.417 +
   1.418 +	/**  Internal data, do not touch */
   1.419 +#ifdef __cplusplus
   1.420 +	void* mPrivate;
   1.421 +#else
   1.422 +	char* mPrivate;
   1.423 +#endif
   1.424 +
   1.425 +};
   1.426 +
   1.427 +#ifdef __cplusplus
   1.428 +} //! namespace Assimp
   1.429 +#endif
   1.430 +
   1.431 +#endif // __AI_SCENE_H_INC__