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 /** @file LWSLoader.h
|
nuclear@0
|
42 * @brief Declaration of the LightWave scene importer class.
|
nuclear@0
|
43 */
|
nuclear@0
|
44 #ifndef AI_LWSLOADER_H_INCLUDED
|
nuclear@0
|
45 #define AI_LWSLOADER_H_INCLUDED
|
nuclear@0
|
46
|
nuclear@0
|
47 #include "LWOFileData.h"
|
nuclear@0
|
48 #include "SceneCombiner.h"
|
nuclear@0
|
49
|
nuclear@0
|
50 namespace Assimp {
|
nuclear@0
|
51 namespace LWS {
|
nuclear@0
|
52
|
nuclear@0
|
53 // ---------------------------------------------------------------------------
|
nuclear@0
|
54 /** Represents an element in a LWS file.
|
nuclear@0
|
55 *
|
nuclear@0
|
56 * This can either be a single data line - <name> <value> or a data
|
nuclear@0
|
57 * group - { name <data_line0> ... n }
|
nuclear@0
|
58 */
|
nuclear@0
|
59 class Element
|
nuclear@0
|
60 {
|
nuclear@0
|
61 public:
|
nuclear@0
|
62 Element()
|
nuclear@0
|
63 {}
|
nuclear@0
|
64
|
nuclear@0
|
65 // first: name, second: rest
|
nuclear@0
|
66 std::string tokens[2];
|
nuclear@0
|
67 std::list<Element> children;
|
nuclear@0
|
68
|
nuclear@0
|
69 //! Recursive parsing function
|
nuclear@0
|
70 void Parse (const char*& buffer);
|
nuclear@0
|
71 };
|
nuclear@0
|
72
|
nuclear@0
|
73 #define AI_LWS_MASK (0xffffffff >> 4u)
|
nuclear@0
|
74
|
nuclear@0
|
75 // ---------------------------------------------------------------------------
|
nuclear@0
|
76 /** Represents a LWS scenegraph element
|
nuclear@0
|
77 */
|
nuclear@0
|
78 struct NodeDesc
|
nuclear@0
|
79 {
|
nuclear@0
|
80 NodeDesc()
|
nuclear@0
|
81 : number (0)
|
nuclear@0
|
82 , parent (0)
|
nuclear@0
|
83 , name ("")
|
nuclear@0
|
84 , isPivotSet (false)
|
nuclear@0
|
85 , lightColor (1.f,1.f,1.f)
|
nuclear@0
|
86 , lightIntensity (1.f)
|
nuclear@0
|
87 , lightType (0)
|
nuclear@0
|
88 , lightFalloffType (0)
|
nuclear@0
|
89 , lightConeAngle (45.f)
|
nuclear@0
|
90 , parent_resolved (NULL)
|
nuclear@0
|
91 {}
|
nuclear@0
|
92
|
nuclear@0
|
93 enum {
|
nuclear@0
|
94
|
nuclear@0
|
95 OBJECT = 1,
|
nuclear@0
|
96 LIGHT = 2,
|
nuclear@0
|
97 CAMERA = 3,
|
nuclear@0
|
98 BONE = 4
|
nuclear@0
|
99 } type; // type of node
|
nuclear@0
|
100
|
nuclear@0
|
101 // if object: path
|
nuclear@0
|
102 std::string path;
|
nuclear@0
|
103 unsigned int id;
|
nuclear@0
|
104
|
nuclear@0
|
105 // number of object
|
nuclear@0
|
106 unsigned int number;
|
nuclear@0
|
107
|
nuclear@0
|
108 // index of parent index
|
nuclear@0
|
109 unsigned int parent;
|
nuclear@0
|
110
|
nuclear@0
|
111 // lights & cameras & dummies: name
|
nuclear@0
|
112 const char* name;
|
nuclear@0
|
113
|
nuclear@0
|
114 // animation channels
|
nuclear@0
|
115 std::list< LWO::Envelope > channels;
|
nuclear@0
|
116
|
nuclear@0
|
117 // position of pivot point
|
nuclear@0
|
118 aiVector3D pivotPos;
|
nuclear@0
|
119 bool isPivotSet;
|
nuclear@0
|
120
|
nuclear@0
|
121
|
nuclear@0
|
122
|
nuclear@0
|
123 // color of light source
|
nuclear@0
|
124 aiColor3D lightColor;
|
nuclear@0
|
125
|
nuclear@0
|
126 // intensity of light source
|
nuclear@0
|
127 float lightIntensity;
|
nuclear@0
|
128
|
nuclear@0
|
129 // type of light source
|
nuclear@0
|
130 unsigned int lightType;
|
nuclear@0
|
131
|
nuclear@0
|
132 // falloff type of light source
|
nuclear@0
|
133 unsigned int lightFalloffType;
|
nuclear@0
|
134
|
nuclear@0
|
135 // cone angle of (spot) light source
|
nuclear@0
|
136 float lightConeAngle;
|
nuclear@0
|
137
|
nuclear@0
|
138 // soft cone angle of (spot) light source
|
nuclear@0
|
139 float lightEdgeAngle;
|
nuclear@0
|
140
|
nuclear@0
|
141
|
nuclear@0
|
142
|
nuclear@0
|
143 // list of resolved children
|
nuclear@0
|
144 std::list< NodeDesc* > children;
|
nuclear@0
|
145
|
nuclear@0
|
146 // resolved parent node
|
nuclear@0
|
147 NodeDesc* parent_resolved;
|
nuclear@0
|
148
|
nuclear@0
|
149
|
nuclear@0
|
150 // for std::find()
|
nuclear@0
|
151 bool operator == (unsigned int num) const {
|
nuclear@0
|
152 if (!num)
|
nuclear@0
|
153 return false;
|
nuclear@0
|
154 unsigned int _type = num >> 28u;
|
nuclear@0
|
155
|
nuclear@0
|
156 return _type == static_cast<unsigned int>(type) && (num & AI_LWS_MASK) == number;
|
nuclear@0
|
157 }
|
nuclear@0
|
158 };
|
nuclear@0
|
159
|
nuclear@0
|
160 } // end namespace LWS
|
nuclear@0
|
161
|
nuclear@0
|
162 // ---------------------------------------------------------------------------
|
nuclear@0
|
163 /** LWS (LightWave Scene Format) importer class.
|
nuclear@0
|
164 *
|
nuclear@0
|
165 * This class does heavily depend on the LWO importer class. LWS files
|
nuclear@0
|
166 * contain mainly descriptions how LWO objects are composed together
|
nuclear@0
|
167 * in a scene.
|
nuclear@0
|
168 */
|
nuclear@0
|
169 class LWSImporter : public BaseImporter
|
nuclear@0
|
170 {
|
nuclear@0
|
171 public:
|
nuclear@0
|
172 LWSImporter();
|
nuclear@0
|
173 ~LWSImporter();
|
nuclear@0
|
174
|
nuclear@0
|
175
|
nuclear@0
|
176 public:
|
nuclear@0
|
177
|
nuclear@0
|
178 // -------------------------------------------------------------------
|
nuclear@0
|
179 // Check whether we can read a specific file
|
nuclear@0
|
180 bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
|
nuclear@0
|
181 bool checkSig) const;
|
nuclear@0
|
182
|
nuclear@0
|
183 protected:
|
nuclear@0
|
184
|
nuclear@0
|
185 // -------------------------------------------------------------------
|
nuclear@0
|
186 // Get list of supported extensions
|
nuclear@0
|
187 const aiImporterDesc* GetInfo () const;
|
nuclear@0
|
188
|
nuclear@0
|
189 // -------------------------------------------------------------------
|
nuclear@0
|
190 // Import file into given scene data structure
|
nuclear@0
|
191 void InternReadFile( const std::string& pFile, aiScene* pScene,
|
nuclear@0
|
192 IOSystem* pIOHandler);
|
nuclear@0
|
193
|
nuclear@0
|
194 // -------------------------------------------------------------------
|
nuclear@0
|
195 // Setup import properties
|
nuclear@0
|
196 void SetupProperties(const Importer* pImp);
|
nuclear@0
|
197
|
nuclear@0
|
198 private:
|
nuclear@0
|
199
|
nuclear@0
|
200
|
nuclear@0
|
201 // -------------------------------------------------------------------
|
nuclear@0
|
202 // Read an envelope description
|
nuclear@0
|
203 void ReadEnvelope(const LWS::Element& dad, LWO::Envelope& out );
|
nuclear@0
|
204
|
nuclear@0
|
205 // -------------------------------------------------------------------
|
nuclear@0
|
206 // Read an envelope description for the older LW file format
|
nuclear@0
|
207 void ReadEnvelope_Old(std::list< LWS::Element >::const_iterator& it,
|
nuclear@0
|
208 const std::list< LWS::Element >::const_iterator& end,
|
nuclear@0
|
209 LWS::NodeDesc& nodes,
|
nuclear@0
|
210 unsigned int version);
|
nuclear@0
|
211
|
nuclear@0
|
212 // -------------------------------------------------------------------
|
nuclear@0
|
213 // Setup a nice name for a node
|
nuclear@0
|
214 void SetupNodeName(aiNode* nd, LWS::NodeDesc& src);
|
nuclear@0
|
215
|
nuclear@0
|
216 // -------------------------------------------------------------------
|
nuclear@0
|
217 // Recursively build the scenegraph
|
nuclear@0
|
218 void BuildGraph(aiNode* nd,
|
nuclear@0
|
219 LWS::NodeDesc& src,
|
nuclear@0
|
220 std::vector<AttachmentInfo>& attach,
|
nuclear@0
|
221 BatchLoader& batch,
|
nuclear@0
|
222 aiCamera**& camOut,
|
nuclear@0
|
223 aiLight**& lightOut,
|
nuclear@0
|
224 std::vector<aiNodeAnim*>& animOut);
|
nuclear@0
|
225
|
nuclear@0
|
226 // -------------------------------------------------------------------
|
nuclear@0
|
227 // Try several dirs until we find the right location of a LWS file.
|
nuclear@0
|
228 std::string FindLWOFile(const std::string& in);
|
nuclear@0
|
229
|
nuclear@0
|
230 private:
|
nuclear@0
|
231
|
nuclear@0
|
232 bool configSpeedFlag;
|
nuclear@0
|
233 IOSystem* io;
|
nuclear@0
|
234
|
nuclear@0
|
235 double first,last,fps;
|
nuclear@0
|
236
|
nuclear@0
|
237 bool noSkeletonMesh;
|
nuclear@0
|
238 };
|
nuclear@0
|
239
|
nuclear@0
|
240 } // end of namespace Assimp
|
nuclear@0
|
241
|
nuclear@0
|
242 #endif // AI_LWSIMPORTER_H_INC
|