vrshoot

view libs/assimp/ASELoader.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line source
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
5 Copyright (c) 2006-2012, assimp team
6 All rights reserved.
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:
12 * Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the
14 following disclaimer.
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.
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.
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.
38 ----------------------------------------------------------------------
39 */
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
47 #include "BaseImporter.h"
48 #include "assimp/types.h"
50 struct aiNode;
51 #include "ASEParser.h"
53 namespace Assimp {
56 // --------------------------------------------------------------------------------
57 /** Importer class for the 3DS ASE ASCII format.
58 *
59 */
60 class ASEImporter : public BaseImporter {
61 public:
62 ASEImporter();
63 ~ASEImporter();
66 public:
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;
75 protected:
77 // -------------------------------------------------------------------
78 /** Return importer meta information.
79 * See #BaseImporter::GetInfo for the details
80 */
81 const aiImporterDesc* GetInfo () const;
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);
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);
100 private:
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);
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);
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);
127 // -------------------------------------------------------------------
128 /** Convert a material to a aiMaterial object
129 * \param mat Input material
130 */
131 void ConvertMaterial(ASE::Material& mat);
134 // -------------------------------------------------------------------
135 /** Setup the final material indices for each mesh
136 */
137 void BuildMaterialIndices();
140 // -------------------------------------------------------------------
141 /** Build the node graph
142 */
143 void BuildNodes(std::vector<ASE::BaseNode*>& nodes);
146 // -------------------------------------------------------------------
147 /** Build output cameras
148 */
149 void BuildCameras();
152 // -------------------------------------------------------------------
153 /** Build output lights
154 */
155 void BuildLights();
158 // -------------------------------------------------------------------
159 /** Build output animations
160 */
161 void BuildAnimations(const std::vector<ASE::BaseNode*>& nodes);
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);
173 void AddNodes(const std::vector<ASE::BaseNode*>& nodes,
174 aiNode* pcParent,const char* szName,
175 const aiMatrix4x4& matrix);
177 void AddMeshes(const ASE::BaseNode* snode,aiNode* node);
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();
186 protected:
188 /** Parser instance */
189 ASE::Parser* mParser;
191 /** Buffer to hold the loaded file */
192 char* mBuffer;
194 /** Scene to be filled */
195 aiScene* pcScene;
197 /** Config options: Recompute the normals in every case - WA
198 for 3DS Max broken ASE normal export */
199 bool configRecomputeNormals;
200 bool noSkeletonMesh;
201 };
203 } // end of namespace Assimp
205 #endif // AI_3DSIMPORTER_H_INC