vrshoot

annotate libs/assimp/XFileHelper.h @ 2:334d17aed7de

visual studio project files
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 02 Feb 2014 18:36:38 +0200
parents
children
rev   line source
nuclear@0 1 /*
nuclear@0 2 Open Asset Import Library (assimp)
nuclear@0 3 ----------------------------------------------------------------------
nuclear@0 4
nuclear@0 5 Copyright (c) 2006-2012, assimp team
nuclear@0 6 All rights reserved.
nuclear@0 7
nuclear@0 8 Redistribution and use of this software in source and binary forms,
nuclear@0 9 with or without modification, are permitted provided that the
nuclear@0 10 following conditions are met:
nuclear@0 11
nuclear@0 12 * Redistributions of source code must retain the above
nuclear@0 13 copyright notice, this list of conditions and the
nuclear@0 14 following disclaimer.
nuclear@0 15
nuclear@0 16 * Redistributions in binary form must reproduce the above
nuclear@0 17 copyright notice, this list of conditions and the
nuclear@0 18 following disclaimer in the documentation and/or other
nuclear@0 19 materials provided with the distribution.
nuclear@0 20
nuclear@0 21 * Neither the name of the assimp team, nor the names of its
nuclear@0 22 contributors may be used to endorse or promote products
nuclear@0 23 derived from this software without specific prior
nuclear@0 24 written permission of the assimp team.
nuclear@0 25
nuclear@0 26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
nuclear@0 27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
nuclear@0 28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
nuclear@0 29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
nuclear@0 30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
nuclear@0 31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
nuclear@0 32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
nuclear@0 33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
nuclear@0 34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
nuclear@0 35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
nuclear@0 36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nuclear@0 37
nuclear@0 38 ----------------------------------------------------------------------
nuclear@0 39 */
nuclear@0 40
nuclear@0 41
nuclear@0 42 /** @file Defines the helper data structures for importing XFiles */
nuclear@0 43 #ifndef AI_XFILEHELPER_H_INC
nuclear@0 44 #define AI_XFILEHELPER_H_INC
nuclear@0 45
nuclear@0 46 #include <string>
nuclear@0 47 #include <vector>
nuclear@0 48
nuclear@0 49 #include "assimp/types.h"
nuclear@0 50 #include "assimp/quaternion.h"
nuclear@0 51 #include "assimp/mesh.h"
nuclear@0 52 #include "assimp/anim.h"
nuclear@0 53
nuclear@0 54 namespace Assimp
nuclear@0 55 {
nuclear@0 56 namespace XFile
nuclear@0 57 {
nuclear@0 58
nuclear@0 59 /** Helper structure representing a XFile mesh face */
nuclear@0 60 struct Face
nuclear@0 61 {
nuclear@0 62 std::vector<unsigned int> mIndices;
nuclear@0 63 };
nuclear@0 64
nuclear@0 65 /** Helper structure representing a texture filename inside a material and its potential source */
nuclear@0 66 struct TexEntry
nuclear@0 67 {
nuclear@0 68 std::string mName;
nuclear@0 69 bool mIsNormalMap; // true if the texname was specified in a NormalmapFilename tag
nuclear@0 70
nuclear@0 71 TexEntry() { mIsNormalMap = false; }
nuclear@0 72 TexEntry( const std::string& pName, bool pIsNormalMap = false)
nuclear@0 73 : mName( pName), mIsNormalMap( pIsNormalMap)
nuclear@0 74 { /* done */ }
nuclear@0 75 };
nuclear@0 76
nuclear@0 77 /** Helper structure representing a XFile material */
nuclear@0 78 struct Material
nuclear@0 79 {
nuclear@0 80 std::string mName;
nuclear@0 81 bool mIsReference; // if true, mName holds a name by which the actual material can be found in the material list
nuclear@0 82 aiColor4D mDiffuse;
nuclear@0 83 float mSpecularExponent;
nuclear@0 84 aiColor3D mSpecular;
nuclear@0 85 aiColor3D mEmissive;
nuclear@0 86 std::vector<TexEntry> mTextures;
nuclear@0 87
nuclear@0 88 size_t sceneIndex; ///< the index under which it was stored in the scene's material list
nuclear@0 89
nuclear@0 90 Material() { mIsReference = false; sceneIndex = SIZE_MAX; }
nuclear@0 91 };
nuclear@0 92
nuclear@0 93 /** Helper structure to represent a bone weight */
nuclear@0 94 struct BoneWeight
nuclear@0 95 {
nuclear@0 96 unsigned int mVertex;
nuclear@0 97 float mWeight;
nuclear@0 98 };
nuclear@0 99
nuclear@0 100 /** Helper structure to represent a bone in a mesh */
nuclear@0 101 struct Bone
nuclear@0 102 {
nuclear@0 103 std::string mName;
nuclear@0 104 std::vector<BoneWeight> mWeights;
nuclear@0 105 aiMatrix4x4 mOffsetMatrix;
nuclear@0 106 };
nuclear@0 107
nuclear@0 108 /** Helper structure to represent an XFile mesh */
nuclear@0 109 struct Mesh
nuclear@0 110 {
nuclear@0 111 std::vector<aiVector3D> mPositions;
nuclear@0 112 std::vector<Face> mPosFaces;
nuclear@0 113 std::vector<aiVector3D> mNormals;
nuclear@0 114 std::vector<Face> mNormFaces;
nuclear@0 115 unsigned int mNumTextures;
nuclear@0 116 std::vector<aiVector2D> mTexCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
nuclear@0 117 unsigned int mNumColorSets;
nuclear@0 118 std::vector<aiColor4D> mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
nuclear@0 119
nuclear@0 120 std::vector<unsigned int> mFaceMaterials;
nuclear@0 121 std::vector<Material> mMaterials;
nuclear@0 122
nuclear@0 123 std::vector<Bone> mBones;
nuclear@0 124
nuclear@0 125 Mesh() { mNumTextures = 0; mNumColorSets = 0; }
nuclear@0 126 };
nuclear@0 127
nuclear@0 128 /** Helper structure to represent a XFile frame */
nuclear@0 129 struct Node
nuclear@0 130 {
nuclear@0 131 std::string mName;
nuclear@0 132 aiMatrix4x4 mTrafoMatrix;
nuclear@0 133 Node* mParent;
nuclear@0 134 std::vector<Node*> mChildren;
nuclear@0 135 std::vector<Mesh*> mMeshes;
nuclear@0 136
nuclear@0 137 Node() { mParent = NULL; }
nuclear@0 138 Node( Node* pParent) { mParent = pParent; }
nuclear@0 139 ~Node()
nuclear@0 140 {
nuclear@0 141 for( unsigned int a = 0; a < mChildren.size(); a++)
nuclear@0 142 delete mChildren[a];
nuclear@0 143 for( unsigned int a = 0; a < mMeshes.size(); a++)
nuclear@0 144 delete mMeshes[a];
nuclear@0 145 }
nuclear@0 146 };
nuclear@0 147
nuclear@0 148 struct MatrixKey
nuclear@0 149 {
nuclear@0 150 double mTime;
nuclear@0 151 aiMatrix4x4 mMatrix;
nuclear@0 152 };
nuclear@0 153
nuclear@0 154 /** Helper structure representing a single animated bone in a XFile */
nuclear@0 155 struct AnimBone
nuclear@0 156 {
nuclear@0 157 std::string mBoneName;
nuclear@0 158 std::vector<aiVectorKey> mPosKeys; // either three separate key sequences for position, rotation, scaling
nuclear@0 159 std::vector<aiQuatKey> mRotKeys;
nuclear@0 160 std::vector<aiVectorKey> mScaleKeys;
nuclear@0 161 std::vector<MatrixKey> mTrafoKeys; // or a combined key sequence of transformation matrices.
nuclear@0 162 };
nuclear@0 163
nuclear@0 164 /** Helper structure to represent an animation set in a XFile */
nuclear@0 165 struct Animation
nuclear@0 166 {
nuclear@0 167 std::string mName;
nuclear@0 168 std::vector<AnimBone*> mAnims;
nuclear@0 169
nuclear@0 170 ~Animation()
nuclear@0 171 {
nuclear@0 172 for( unsigned int a = 0; a < mAnims.size(); a++)
nuclear@0 173 delete mAnims[a];
nuclear@0 174 }
nuclear@0 175 };
nuclear@0 176
nuclear@0 177 /** Helper structure analogue to aiScene */
nuclear@0 178 struct Scene
nuclear@0 179 {
nuclear@0 180 Node* mRootNode;
nuclear@0 181
nuclear@0 182 std::vector<Mesh*> mGlobalMeshes; // global meshes found outside of any frames
nuclear@0 183 std::vector<Material> mGlobalMaterials; // global materials found outside of any meshes.
nuclear@0 184
nuclear@0 185 std::vector<Animation*> mAnims;
nuclear@0 186 unsigned int mAnimTicksPerSecond;
nuclear@0 187
nuclear@0 188 Scene() { mRootNode = NULL; mAnimTicksPerSecond = 0; }
nuclear@0 189 ~Scene()
nuclear@0 190 {
nuclear@0 191 delete mRootNode;
nuclear@0 192 for( unsigned int a = 0; a < mGlobalMeshes.size(); a++)
nuclear@0 193 delete mGlobalMeshes[a];
nuclear@0 194 for( unsigned int a = 0; a < mAnims.size(); a++)
nuclear@0 195 delete mAnims[a];
nuclear@0 196 }
nuclear@0 197 };
nuclear@0 198
nuclear@0 199 } // end of namespace XFile
nuclear@0 200 } // end of namespace Assimp
nuclear@0 201
nuclear@0 202 #endif // AI_XFILEHELPER_H_INC