nuclear@0: /*
nuclear@0: ---------------------------------------------------------------------------
nuclear@0: Open Asset Import Library (assimp)
nuclear@0: ---------------------------------------------------------------------------
nuclear@0:
nuclear@0: Copyright (c) 2006-2018, assimp team
nuclear@0:
nuclear@0:
nuclear@0:
nuclear@0: All rights reserved.
nuclear@0:
nuclear@0: Redistribution and use of this software in source and binary forms,
nuclear@0: with or without modification, are permitted provided that the following
nuclear@0: conditions are met:
nuclear@0:
nuclear@0: * Redistributions of source code must retain the above
nuclear@0: copyright notice, this list of conditions and the
nuclear@0: following disclaimer.
nuclear@0:
nuclear@0: * Redistributions in binary form must reproduce the above
nuclear@0: copyright notice, this list of conditions and the
nuclear@0: following disclaimer in the documentation and/or other
nuclear@0: materials provided with the distribution.
nuclear@0:
nuclear@0: * Neither the name of the assimp team, nor the names of its
nuclear@0: contributors may be used to endorse or promote products
nuclear@0: derived from this software without specific prior
nuclear@0: written permission of the assimp team.
nuclear@0:
nuclear@0: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
nuclear@0: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
nuclear@0: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
nuclear@0: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
nuclear@0: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
nuclear@0: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
nuclear@0: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
nuclear@0: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
nuclear@0: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
nuclear@0: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
nuclear@0: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nuclear@0: ---------------------------------------------------------------------------
nuclear@0: */
nuclear@0:
nuclear@0: /** @file scene.h
nuclear@0: * @brief Defines the data structures in which the imported scene is returned.
nuclear@0: */
nuclear@0: #pragma once
nuclear@0: #ifndef AI_SCENE_H_INC
nuclear@0: #define AI_SCENE_H_INC
nuclear@0:
nuclear@0: #include "types.h"
nuclear@0: #include "texture.h"
nuclear@0: #include "mesh.h"
nuclear@0: #include "light.h"
nuclear@0: #include "camera.h"
nuclear@0: #include "material.h"
nuclear@0: #include "anim.h"
nuclear@0: #include "metadata.h"
nuclear@0:
nuclear@0: #ifdef __cplusplus
nuclear@0: extern "C" {
nuclear@0: #endif
nuclear@0:
nuclear@0: // -------------------------------------------------------------------------------
nuclear@0: /**
nuclear@0: * A node in the imported hierarchy.
nuclear@0: *
nuclear@0: * Each node has name, a parent node (except for the root node),
nuclear@0: * a transformation relative to its parent and possibly several child nodes.
nuclear@0: * Simple file formats don't support hierarchical structures - for these formats
nuclear@0: * the imported scene does consist of only a single root node without children.
nuclear@0: */
nuclear@0: // -------------------------------------------------------------------------------
nuclear@0: struct ASSIMP_API aiNode
nuclear@0: {
nuclear@0: /** The name of the node.
nuclear@0: *
nuclear@0: * The name might be empty (length of zero) but all nodes which
nuclear@0: * need to be referenced by either bones or animations are named.
nuclear@0: * Multiple nodes may have the same name, except for nodes which are referenced
nuclear@0: * by bones (see #aiBone and #aiMesh::mBones). Their names *must* be unique.
nuclear@0: *
nuclear@0: * Cameras and lights reference a specific node by name - if there
nuclear@0: * are multiple nodes with this name, they are assigned to each of them.
nuclear@0: *
nuclear@0: * There are no limitations with regard to the characters contained in
nuclear@0: * the name string as it is usually taken directly from the source file.
nuclear@0: *
nuclear@0: * Implementations should be able to handle tokens such as whitespace, tabs,
nuclear@0: * line feeds, quotation marks, ampersands etc.
nuclear@0: *
nuclear@0: * Sometimes assimp introduces new nodes not present in the source file
nuclear@0: * into the hierarchy (usually out of necessity because sometimes the
nuclear@0: * source hierarchy format is simply not compatible). Their names are
nuclear@0: * surrounded by @verbatim <> @endverbatim e.g.
nuclear@0: * @verbatim @endverbatim.
nuclear@0: */
nuclear@0: C_STRUCT aiString mName;
nuclear@0:
nuclear@0: /** The transformation relative to the node's parent. */
nuclear@0: C_STRUCT aiMatrix4x4 mTransformation;
nuclear@0:
nuclear@0: /** Parent node. NULL if this node is the root node. */
nuclear@0: C_STRUCT aiNode* mParent;
nuclear@0:
nuclear@0: /** The number of child nodes of this node. */
nuclear@0: unsigned int mNumChildren;
nuclear@0:
nuclear@0: /** The child nodes of this node. NULL if mNumChildren is 0. */
nuclear@0: C_STRUCT aiNode** mChildren;
nuclear@0:
nuclear@0: /** The number of meshes of this node. */
nuclear@0: unsigned int mNumMeshes;
nuclear@0:
nuclear@0: /** The meshes of this node. Each entry is an index into the
nuclear@0: * mesh list of the #aiScene.
nuclear@0: */
nuclear@0: unsigned int* mMeshes;
nuclear@0:
nuclear@0: /** Metadata associated with this node or NULL if there is no metadata.
nuclear@0: * Whether any metadata is generated depends on the source file format. See the
nuclear@0: * @link importer_notes @endlink page for more information on every source file
nuclear@0: * format. Importers that don't document any metadata don't write any.
nuclear@0: */
nuclear@0: C_STRUCT aiMetadata* mMetaData;
nuclear@0:
nuclear@0: #ifdef __cplusplus
nuclear@0: /** Constructor */
nuclear@0: aiNode();
nuclear@0:
nuclear@0: /** Construction from a specific name */
nuclear@0: explicit aiNode(const std::string& name);
nuclear@0:
nuclear@0: /** Destructor */
nuclear@0: ~aiNode();
nuclear@0:
nuclear@0: /** Searches for a node with a specific name, beginning at this
nuclear@0: * nodes. Normally you will call this method on the root node
nuclear@0: * of the scene.
nuclear@0: *
nuclear@0: * @param name Name to search for
nuclear@0: * @return NULL or a valid Node if the search was successful.
nuclear@0: */
nuclear@0: inline
nuclear@0: const aiNode* FindNode(const aiString& name) const {
nuclear@0: return FindNode(name.data);
nuclear@0: }
nuclear@0:
nuclear@0: inline
nuclear@0: aiNode* FindNode(const aiString& name) {
nuclear@0: return FindNode(name.data);
nuclear@0: }
nuclear@0:
nuclear@0: const aiNode* FindNode(const char* name) const;
nuclear@0:
nuclear@0: aiNode* FindNode(const char* name);
nuclear@0:
nuclear@0: /**
nuclear@0: * @brief Will add new children.
nuclear@0: * @param numChildren Number of children to add.
nuclear@0: * @param children The array with pointers showing to the children.
nuclear@0: */
nuclear@0: void addChildren(unsigned int numChildren, aiNode **children);
nuclear@0: #endif // __cplusplus
nuclear@0: };
nuclear@0:
nuclear@0: // -------------------------------------------------------------------------------
nuclear@0: /**
nuclear@0: * Specifies that the scene data structure that was imported is not complete.
nuclear@0: * This flag bypasses some internal validations and allows the import
nuclear@0: * of animation skeletons, material libraries or camera animation paths
nuclear@0: * using Assimp. Most applications won't support such data.
nuclear@0: */
nuclear@0: #define AI_SCENE_FLAGS_INCOMPLETE 0x1
nuclear@0:
nuclear@0: /**
nuclear@0: * This flag is set by the validation postprocess-step (aiPostProcess_ValidateDS)
nuclear@0: * if the validation is successful. In a validated scene you can be sure that
nuclear@0: * any cross references in the data structure (e.g. vertex indices) are valid.
nuclear@0: */
nuclear@0: #define AI_SCENE_FLAGS_VALIDATED 0x2
nuclear@0:
nuclear@0: /**
nuclear@0: * This flag is set by the validation postprocess-step (aiPostProcess_ValidateDS)
nuclear@0: * if the validation is successful but some issues have been found.
nuclear@0: * This can for example mean that a texture that does not exist is referenced
nuclear@0: * by a material or that the bone weights for a vertex don't sum to 1.0 ... .
nuclear@0: * In most cases you should still be able to use the import. This flag could
nuclear@0: * be useful for applications which don't capture Assimp's log output.
nuclear@0: */
nuclear@0: #define AI_SCENE_FLAGS_VALIDATION_WARNING 0x4
nuclear@0:
nuclear@0: /**
nuclear@0: * This flag is currently only set by the aiProcess_JoinIdenticalVertices step.
nuclear@0: * It indicates that the vertices of the output meshes aren't in the internal
nuclear@0: * verbose format anymore. In the verbose format all vertices are unique,
nuclear@0: * no vertex is ever referenced by more than one face.
nuclear@0: */
nuclear@0: #define AI_SCENE_FLAGS_NON_VERBOSE_FORMAT 0x8
nuclear@0:
nuclear@0: /**
nuclear@0: * Denotes pure height-map terrain data. Pure terrains usually consist of quads,
nuclear@0: * sometimes triangles, in a regular grid. The x,y coordinates of all vertex
nuclear@0: * positions refer to the x,y coordinates on the terrain height map, the z-axis
nuclear@0: * stores the elevation at a specific point.
nuclear@0: *
nuclear@0: * TER (Terragen) and HMP (3D Game Studio) are height map formats.
nuclear@0: * @note Assimp is probably not the best choice for loading *huge* terrains -
nuclear@0: * fully triangulated data takes extremely much free store and should be avoided
nuclear@0: * as long as possible (typically you'll do the triangulation when you actually
nuclear@0: * need to render it).
nuclear@0: */
nuclear@0: #define AI_SCENE_FLAGS_TERRAIN 0x10
nuclear@0:
nuclear@0: /**
nuclear@0: * Specifies that the scene data can be shared between structures. For example:
nuclear@0: * one vertex in few faces. \ref AI_SCENE_FLAGS_NON_VERBOSE_FORMAT can not be
nuclear@0: * used for this because \ref AI_SCENE_FLAGS_NON_VERBOSE_FORMAT has internal
nuclear@0: * meaning about postprocessing steps.
nuclear@0: */
nuclear@0: #define AI_SCENE_FLAGS_ALLOW_SHARED 0x20
nuclear@0:
nuclear@0: // -------------------------------------------------------------------------------
nuclear@0: /** The root structure of the imported data.
nuclear@0: *
nuclear@0: * Everything that was imported from the given file can be accessed from here.
nuclear@0: * Objects of this class are generally maintained and owned by Assimp, not
nuclear@0: * by the caller. You shouldn't want to instance it, nor should you ever try to
nuclear@0: * delete a given scene on your own.
nuclear@0: */
nuclear@0: // -------------------------------------------------------------------------------
nuclear@0: struct aiScene
nuclear@0: {
nuclear@0: /** Any combination of the AI_SCENE_FLAGS_XXX flags. By default
nuclear@0: * this value is 0, no flags are set. Most applications will
nuclear@0: * want to reject all scenes with the AI_SCENE_FLAGS_INCOMPLETE
nuclear@0: * bit set.
nuclear@0: */
nuclear@0: unsigned int mFlags;
nuclear@0:
nuclear@0: /** The root node of the hierarchy.
nuclear@0: *
nuclear@0: * There will always be at least the root node if the import
nuclear@0: * was successful (and no special flags have been set).
nuclear@0: * Presence of further nodes depends on the format and content
nuclear@0: * of the imported file.
nuclear@0: */
nuclear@0: C_STRUCT aiNode* mRootNode;
nuclear@0:
nuclear@0: /** The number of meshes in the scene. */
nuclear@0: unsigned int mNumMeshes;
nuclear@0:
nuclear@0: /** The array of meshes.
nuclear@0: *
nuclear@0: * Use the indices given in the aiNode structure to access
nuclear@0: * this array. The array is mNumMeshes in size. If the
nuclear@0: * AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always
nuclear@0: * be at least ONE material.
nuclear@0: */
nuclear@0: C_STRUCT aiMesh** mMeshes;
nuclear@0:
nuclear@0: /** The number of materials in the scene. */
nuclear@0: unsigned int mNumMaterials;
nuclear@0:
nuclear@0: /** The array of materials.
nuclear@0: *
nuclear@0: * Use the index given in each aiMesh structure to access this
nuclear@0: * array. The array is mNumMaterials in size. If the
nuclear@0: * AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always
nuclear@0: * be at least ONE material.
nuclear@0: */
nuclear@0: C_STRUCT aiMaterial** mMaterials;
nuclear@0:
nuclear@0: /** The number of animations in the scene. */
nuclear@0: unsigned int mNumAnimations;
nuclear@0:
nuclear@0: /** The array of animations.
nuclear@0: *
nuclear@0: * All animations imported from the given file are listed here.
nuclear@0: * The array is mNumAnimations in size.
nuclear@0: */
nuclear@0: C_STRUCT aiAnimation** mAnimations;
nuclear@0:
nuclear@0: /** The number of textures embedded into the file */
nuclear@0: unsigned int mNumTextures;
nuclear@0:
nuclear@0: /** The array of embedded textures.
nuclear@0: *
nuclear@0: * Not many file formats embed their textures into the file.
nuclear@0: * An example is Quake's MDL format (which is also used by
nuclear@0: * some GameStudio versions)
nuclear@0: */
nuclear@0: C_STRUCT aiTexture** mTextures;
nuclear@0:
nuclear@0: /** The number of light sources in the scene. Light sources
nuclear@0: * are fully optional, in most cases this attribute will be 0
nuclear@0: */
nuclear@0: unsigned int mNumLights;
nuclear@0:
nuclear@0: /** The array of light sources.
nuclear@0: *
nuclear@0: * All light sources imported from the given file are
nuclear@0: * listed here. The array is mNumLights in size.
nuclear@0: */
nuclear@0: C_STRUCT aiLight** mLights;
nuclear@0:
nuclear@0: /** The number of cameras in the scene. Cameras
nuclear@0: * are fully optional, in most cases this attribute will be 0
nuclear@0: */
nuclear@0: unsigned int mNumCameras;
nuclear@0:
nuclear@0: /** The array of cameras.
nuclear@0: *
nuclear@0: * All cameras imported from the given file are listed here.
nuclear@0: * The array is mNumCameras in size. The first camera in the
nuclear@0: * array (if existing) is the default camera view into
nuclear@0: * the scene.
nuclear@0: */
nuclear@0: C_STRUCT aiCamera** mCameras;
nuclear@0:
nuclear@0: /**
nuclear@0: * @brief The global metadata assigned to the scene itself.
nuclear@0: *
nuclear@0: * This data contains global metadata which belongs to the scene like
nuclear@0: * unit-conversions, versions, vendors or other model-specific data. This
nuclear@0: * can be used to store format-specific metadata as well.
nuclear@0: */
nuclear@0: C_STRUCT aiMetadata* mMetaData;
nuclear@0:
nuclear@0:
nuclear@0: #ifdef __cplusplus
nuclear@0:
nuclear@0: //! Default constructor - set everything to 0/NULL
nuclear@0: ASSIMP_API aiScene();
nuclear@0:
nuclear@0: //! Destructor
nuclear@0: ASSIMP_API ~aiScene();
nuclear@0:
nuclear@0: //! Check whether the scene contains meshes
nuclear@0: //! Unless no special scene flags are set this will always be true.
nuclear@0: inline bool HasMeshes() const {
nuclear@0: return mMeshes != NULL && mNumMeshes > 0;
nuclear@0: }
nuclear@0:
nuclear@0: //! Check whether the scene contains materials
nuclear@0: //! Unless no special scene flags are set this will always be true.
nuclear@0: inline bool HasMaterials() const {
nuclear@0: return mMaterials != NULL && mNumMaterials > 0;
nuclear@0: }
nuclear@0:
nuclear@0: //! Check whether the scene contains lights
nuclear@0: inline bool HasLights() const {
nuclear@0: return mLights != NULL && mNumLights > 0;
nuclear@0: }
nuclear@0:
nuclear@0: //! Check whether the scene contains textures
nuclear@0: inline bool HasTextures() const {
nuclear@0: return mTextures != NULL && mNumTextures > 0;
nuclear@0: }
nuclear@0:
nuclear@0: //! Check whether the scene contains cameras
nuclear@0: inline bool HasCameras() const {
nuclear@0: return mCameras != NULL && mNumCameras > 0;
nuclear@0: }
nuclear@0:
nuclear@0: //! Check whether the scene contains animations
nuclear@0: inline bool HasAnimations() const {
nuclear@0: return mAnimations != NULL && mNumAnimations > 0;
nuclear@0: }
nuclear@0:
nuclear@0: //! Returns a short filename from a full path
nuclear@0: static const char* GetShortFilename(const char* filename) {
nuclear@0: const char* lastSlash = strrchr(filename, '/');
nuclear@0: if (lastSlash == 0) {
nuclear@0: lastSlash = strrchr(filename, '\\');
nuclear@0: }
nuclear@0: const char* shortFilename = lastSlash != 0 ? lastSlash + 1 : filename;
nuclear@0: return shortFilename;
nuclear@0: }
nuclear@0:
nuclear@0: //! Returns an embedded texture
nuclear@0: const aiTexture* GetEmbeddedTexture(const char* filename) const {
nuclear@0: const char* shortFilename = GetShortFilename(filename);
nuclear@0: for (unsigned int i = 0; i < mNumTextures; i++) {
nuclear@0: const char* shortTextureFilename = GetShortFilename(mTextures[i]->mFilename.C_Str());
nuclear@0: if (strcmp(shortTextureFilename, shortFilename) == 0) {
nuclear@0: return mTextures[i];
nuclear@0: }
nuclear@0: }
nuclear@0: return 0;
nuclear@0: }
nuclear@0: #endif // __cplusplus
nuclear@0:
nuclear@0: /** Internal data, do not touch */
nuclear@0: #ifdef __cplusplus
nuclear@0: void* mPrivate;
nuclear@0: #else
nuclear@0: char* mPrivate;
nuclear@0: #endif
nuclear@0:
nuclear@0: };
nuclear@0:
nuclear@0: #ifdef __cplusplus
nuclear@0: } //! namespace Assimp
nuclear@0: #endif
nuclear@0:
nuclear@0: #endif // AI_SCENE_H_INC