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