1 /* 2 Open Asset Import Library (assimp) 3 ---------------------------------------------------------------------- 4 5 Copyright (c) 2006-2012, assimp team 6 All rights reserved. 7 8 Redistribution and use of this software in source and binary forms, 9 with or without modification, are permitted provided that the 10 following conditions are met: 11 12 * Redistributions of source code must retain the above 13 copyright notice, this list of conditions and the 14 following disclaimer. 15 16 * Redistributions in binary form must reproduce the above 17 copyright notice, this list of conditions and the 18 following disclaimer in the documentation and/or other 19 materials provided with the distribution. 20 21 * Neither the name of the assimp team, nor the names of its 22 contributors may be used to endorse or promote products 23 derived from this software without specific prior 24 written permission of the assimp team. 25 26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 38 ---------------------------------------------------------------------- 39 */ 40 41 /** @file ASELoader.h 42 * @brief Definition of the .ASE importer class. 43 */ 44 #ifndef AI_ASELOADER_H_INCLUDED 45 #define AI_ASELOADER_H_INCLUDED 46 47 #include "BaseImporter.h" 48 #include "../include/assimp/types.h" 49 50 struct aiNode; 51 #include "ASEParser.h" 52 53 namespace Assimp { 54 55 56 // -------------------------------------------------------------------------------- 57 /** Importer class for the 3DS ASE ASCII format. 58 * 59 */ 60 class ASEImporter : public BaseImporter { 61 public: 62 ASEImporter(); 63 ~ASEImporter(); 64 65 66 public: 67 68 // ------------------------------------------------------------------- 69 /** Returns whether the class can handle the format of the given file. 70 * See BaseImporter::CanRead() for details. 71 */ 72 bool CanRead( const std::string& pFile, IOSystem* pIOHandler, 73 bool checkSig) const; 74 75 protected: 76 77 // ------------------------------------------------------------------- 78 /** Called by Importer::GetExtensionList() for each loaded importer. 79 * See BaseImporter::GetExtensionList() for details 80 */ 81 void GetExtensionList(std::set<std::string>& extensions); 82 83 84 // ------------------------------------------------------------------- 85 /** Imports the given file into the given scene structure. 86 * See BaseImporter::InternReadFile() for details 87 */ 88 void InternReadFile( const std::string& pFile, aiScene* pScene, 89 IOSystem* pIOHandler); 90 91 92 // ------------------------------------------------------------------- 93 /** Called prior to ReadFile(). 94 * The function is a request to the importer to update its configuration 95 * basing on the Importer's configuration property list. 96 */ 97 void SetupProperties(const Importer* pImp); 98 99 100 private: 101 102 // ------------------------------------------------------------------- 103 /** Generate normal vectors basing on smoothing groups 104 * (in some cases the normal are already contained in the file) 105 * \param mesh Mesh to work on 106 * \return false if the normals have been recomputed 107 */ 108 bool GenerateNormals(ASE::Mesh& mesh); 109 110 111 // ------------------------------------------------------------------- 112 /** Create valid vertex/normal/UV/color/face lists. 113 * All elements are unique, faces have only one set of indices 114 * after this step occurs. 115 * \param mesh Mesh to work on 116 */ 117 void BuildUniqueRepresentation(ASE::Mesh& mesh); 118 119 120 /** Create one-material-per-mesh meshes ;-) 121 * \param mesh Mesh to work with 122 * \param Receives the list of all created meshes 123 */ 124 void ConvertMeshes(ASE::Mesh& mesh, std::vector<aiMesh*>& avOut); 125 126 127 // ------------------------------------------------------------------- 128 /** Convert a material to a aiMaterial object 129 * \param mat Input material 130 */ 131 void ConvertMaterial(ASE::Material& mat); 132 133 134 // ------------------------------------------------------------------- 135 /** Setup the final material indices for each mesh 136 */ 137 void BuildMaterialIndices(); 138 139 140 // ------------------------------------------------------------------- 141 /** Build the node graph 142 */ 143 void BuildNodes(std::vector<ASE::BaseNode*>& nodes); 144 145 146 // ------------------------------------------------------------------- 147 /** Build output cameras 148 */ 149 void BuildCameras(); 150 151 152 // ------------------------------------------------------------------- 153 /** Build output lights 154 */ 155 void BuildLights(); 156 157 158 // ------------------------------------------------------------------- 159 /** Build output animations 160 */ 161 void BuildAnimations(const std::vector<ASE::BaseNode*>& nodes); 162 163 164 // ------------------------------------------------------------------- 165 /** Add sub nodes to a node 166 * \param pcParent parent node to be filled 167 * \param szName Name of the parent node 168 * \param matrix Current transform 169 */ 170 void AddNodes(const std::vector<ASE::BaseNode*>& nodes, 171 aiNode* pcParent,const char* szName); 172 173 void AddNodes(const std::vector<ASE::BaseNode*>& nodes, 174 aiNode* pcParent,const char* szName, 175 const aiMatrix4x4& matrix); 176 177 void AddMeshes(const ASE::BaseNode* snode,aiNode* node); 178 179 // ------------------------------------------------------------------- 180 /** Generate a default material and add it to the parser's list 181 * Called if no material has been found in the file (rare for ASE, 182 * but not impossible) 183 */ 184 void GenerateDefaultMaterial(); 185 186 protected: 187 188 /** Parser instance */ 189 ASE::Parser* mParser; 190 191 /** Buffer to hold the loaded file */ 192 char* mBuffer; 193 194 /** Scene to be filled */ 195 aiScene* pcScene; 196 197 /** Config options: Recompute the normals in every case - WA 198 for 3DS Max broken ASE normal export */ 199 bool configRecomputeNormals; 200 }; 201 202 } // end of namespace Assimp 203 204 #endif // AI_3DSIMPORTER_H_INC 205