nuclear@0: /* nuclear@0: Open Asset Import Library (assimp) nuclear@0: ---------------------------------------------------------------------- nuclear@0: nuclear@0: Copyright (c) 2006-2012, assimp team 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 nuclear@0: following 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: nuclear@0: nuclear@0: /** @file Defines the helper data structures for importing XFiles */ nuclear@0: #ifndef AI_XFILEHELPER_H_INC nuclear@0: #define AI_XFILEHELPER_H_INC nuclear@0: nuclear@0: #include nuclear@0: #include nuclear@0: nuclear@0: #include "assimp/types.h" nuclear@0: #include "assimp/quaternion.h" nuclear@0: #include "assimp/mesh.h" nuclear@0: #include "assimp/anim.h" nuclear@0: nuclear@0: namespace Assimp nuclear@0: { nuclear@0: namespace XFile nuclear@0: { nuclear@0: nuclear@0: /** Helper structure representing a XFile mesh face */ nuclear@0: struct Face nuclear@0: { nuclear@0: std::vector mIndices; nuclear@0: }; nuclear@0: nuclear@0: /** Helper structure representing a texture filename inside a material and its potential source */ nuclear@0: struct TexEntry nuclear@0: { nuclear@0: std::string mName; nuclear@0: bool mIsNormalMap; // true if the texname was specified in a NormalmapFilename tag nuclear@0: nuclear@0: TexEntry() { mIsNormalMap = false; } nuclear@0: TexEntry( const std::string& pName, bool pIsNormalMap = false) nuclear@0: : mName( pName), mIsNormalMap( pIsNormalMap) nuclear@0: { /* done */ } nuclear@0: }; nuclear@0: nuclear@0: /** Helper structure representing a XFile material */ nuclear@0: struct Material nuclear@0: { nuclear@0: std::string mName; nuclear@0: bool mIsReference; // if true, mName holds a name by which the actual material can be found in the material list nuclear@0: aiColor4D mDiffuse; nuclear@0: float mSpecularExponent; nuclear@0: aiColor3D mSpecular; nuclear@0: aiColor3D mEmissive; nuclear@0: std::vector mTextures; nuclear@0: nuclear@0: size_t sceneIndex; ///< the index under which it was stored in the scene's material list nuclear@0: nuclear@0: Material() { mIsReference = false; sceneIndex = SIZE_MAX; } nuclear@0: }; nuclear@0: nuclear@0: /** Helper structure to represent a bone weight */ nuclear@0: struct BoneWeight nuclear@0: { nuclear@0: unsigned int mVertex; nuclear@0: float mWeight; nuclear@0: }; nuclear@0: nuclear@0: /** Helper structure to represent a bone in a mesh */ nuclear@0: struct Bone nuclear@0: { nuclear@0: std::string mName; nuclear@0: std::vector mWeights; nuclear@0: aiMatrix4x4 mOffsetMatrix; nuclear@0: }; nuclear@0: nuclear@0: /** Helper structure to represent an XFile mesh */ nuclear@0: struct Mesh nuclear@0: { nuclear@0: std::vector mPositions; nuclear@0: std::vector mPosFaces; nuclear@0: std::vector mNormals; nuclear@0: std::vector mNormFaces; nuclear@0: unsigned int mNumTextures; nuclear@0: std::vector mTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS]; nuclear@0: unsigned int mNumColorSets; nuclear@0: std::vector mColors[AI_MAX_NUMBER_OF_COLOR_SETS]; nuclear@0: nuclear@0: std::vector mFaceMaterials; nuclear@0: std::vector mMaterials; nuclear@0: nuclear@0: std::vector mBones; nuclear@0: nuclear@0: Mesh() { mNumTextures = 0; mNumColorSets = 0; } nuclear@0: }; nuclear@0: nuclear@0: /** Helper structure to represent a XFile frame */ nuclear@0: struct Node nuclear@0: { nuclear@0: std::string mName; nuclear@0: aiMatrix4x4 mTrafoMatrix; nuclear@0: Node* mParent; nuclear@0: std::vector mChildren; nuclear@0: std::vector mMeshes; nuclear@0: nuclear@0: Node() { mParent = NULL; } nuclear@0: Node( Node* pParent) { mParent = pParent; } nuclear@0: ~Node() nuclear@0: { nuclear@0: for( unsigned int a = 0; a < mChildren.size(); a++) nuclear@0: delete mChildren[a]; nuclear@0: for( unsigned int a = 0; a < mMeshes.size(); a++) nuclear@0: delete mMeshes[a]; nuclear@0: } nuclear@0: }; nuclear@0: nuclear@0: struct MatrixKey nuclear@0: { nuclear@0: double mTime; nuclear@0: aiMatrix4x4 mMatrix; nuclear@0: }; nuclear@0: nuclear@0: /** Helper structure representing a single animated bone in a XFile */ nuclear@0: struct AnimBone nuclear@0: { nuclear@0: std::string mBoneName; nuclear@0: std::vector mPosKeys; // either three separate key sequences for position, rotation, scaling nuclear@0: std::vector mRotKeys; nuclear@0: std::vector mScaleKeys; nuclear@0: std::vector mTrafoKeys; // or a combined key sequence of transformation matrices. nuclear@0: }; nuclear@0: nuclear@0: /** Helper structure to represent an animation set in a XFile */ nuclear@0: struct Animation nuclear@0: { nuclear@0: std::string mName; nuclear@0: std::vector mAnims; nuclear@0: nuclear@0: ~Animation() nuclear@0: { nuclear@0: for( unsigned int a = 0; a < mAnims.size(); a++) nuclear@0: delete mAnims[a]; nuclear@0: } nuclear@0: }; nuclear@0: nuclear@0: /** Helper structure analogue to aiScene */ nuclear@0: struct Scene nuclear@0: { nuclear@0: Node* mRootNode; nuclear@0: nuclear@0: std::vector mGlobalMeshes; // global meshes found outside of any frames nuclear@0: std::vector mGlobalMaterials; // global materials found outside of any meshes. nuclear@0: nuclear@0: std::vector mAnims; nuclear@0: unsigned int mAnimTicksPerSecond; nuclear@0: nuclear@0: Scene() { mRootNode = NULL; mAnimTicksPerSecond = 0; } nuclear@0: ~Scene() nuclear@0: { nuclear@0: delete mRootNode; nuclear@0: for( unsigned int a = 0; a < mGlobalMeshes.size(); a++) nuclear@0: delete mGlobalMeshes[a]; nuclear@0: for( unsigned int a = 0; a < mAnims.size(); a++) nuclear@0: delete mAnims[a]; nuclear@0: } nuclear@0: }; nuclear@0: nuclear@0: } // end of namespace XFile nuclear@0: } // end of namespace Assimp nuclear@0: nuclear@0: #endif // AI_XFILEHELPER_H_INC