1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
4 
5 Copyright (c) 2006-2019, assimp team
6 
7 
8 All rights reserved.
9 
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the
12 following conditions are met:
13 
14 * Redistributions of source code must retain the above
15   copyright notice, this list of conditions and the
16   following disclaimer.
17 
18 * Redistributions in binary form must reproduce the above
19   copyright notice, this list of conditions and the
20   following disclaimer in the documentation and/or other
21   materials provided with the distribution.
22 
23 * Neither the name of the assimp team, nor the names of its
24   contributors may be used to endorse or promote products
25   derived from this software without specific prior
26   written permission of the assimp team.
27 
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 
40 ----------------------------------------------------------------------
41 */
42 
43 /** @file LWOFileData.h
44  *  @brief Defines chunk constants used by the LWO file format
45 
46 The chunks are taken from the official LightWave SDK headers.
47 
48 */
49 #ifndef AI_LWO_FILEDATA_INCLUDED
50 #define AI_LWO_FILEDATA_INCLUDED
51 
52 // STL headers
53 #include <vector>
54 #include <list>
55 
56 // public ASSIMP headers
57 #include <assimp/mesh.h>
58 
59 // internal headers
60 #include "Common/IFF.h"
61 #include "LWO/LWOAnimation.h"
62 
63 namespace Assimp {
64 namespace LWO {
65 
66 #define AI_LWO_FOURCC_LWOB AI_IFF_FOURCC('L','W','O','B')
67 #define AI_LWO_FOURCC_LWO2 AI_IFF_FOURCC('L','W','O','2')
68 #define AI_LWO_FOURCC_LXOB AI_IFF_FOURCC('L','X','O','B')
69 
70 // chunks specific to the LWOB format
71 #define AI_LWO_SRFS  AI_IFF_FOURCC('S','R','F','S')
72 #define AI_LWO_FLAG  AI_IFF_FOURCC('F','L','A','G')
73 #define AI_LWO_VLUM  AI_IFF_FOURCC('V','L','U','M')
74 #define AI_LWO_VDIF  AI_IFF_FOURCC('V','D','I','F')
75 #define AI_LWO_VSPC  AI_IFF_FOURCC('V','S','P','C')
76 #define AI_LWO_RFLT  AI_IFF_FOURCC('R','F','L','T')
77 #define AI_LWO_BTEX  AI_IFF_FOURCC('B','T','E','X')
78 #define AI_LWO_CTEX  AI_IFF_FOURCC('C','T','E','X')
79 #define AI_LWO_DTEX  AI_IFF_FOURCC('D','T','E','X')
80 #define AI_LWO_LTEX  AI_IFF_FOURCC('L','T','E','X')
81 #define AI_LWO_RTEX  AI_IFF_FOURCC('R','T','E','X')
82 #define AI_LWO_STEX  AI_IFF_FOURCC('S','T','E','X')
83 #define AI_LWO_TTEX  AI_IFF_FOURCC('T','T','E','X')
84 #define AI_LWO_TFLG  AI_IFF_FOURCC('T','F','L','G')
85 #define AI_LWO_TSIZ  AI_IFF_FOURCC('T','S','I','Z')
86 #define AI_LWO_TCTR  AI_IFF_FOURCC('T','C','T','R')
87 #define AI_LWO_TFAL  AI_IFF_FOURCC('T','F','A','L')
88 #define AI_LWO_TVEL  AI_IFF_FOURCC('T','V','E','L')
89 #define AI_LWO_TCLR  AI_IFF_FOURCC('T','C','L','R')
90 #define AI_LWO_TVAL  AI_IFF_FOURCC('T','V','A','L')
91 #define AI_LWO_TAMP  AI_IFF_FOURCC('T','A','M','P')
92 #define AI_LWO_TIMG  AI_IFF_FOURCC('T','I','M','G')
93 #define AI_LWO_TAAS  AI_IFF_FOURCC('T','A','A','S')
94 #define AI_LWO_TREF  AI_IFF_FOURCC('T','R','E','F')
95 #define AI_LWO_TOPC  AI_IFF_FOURCC('T','O','P','C')
96 #define AI_LWO_SDAT  AI_IFF_FOURCC('S','D','A','T')
97 #define AI_LWO_TFP0  AI_IFF_FOURCC('T','F','P','0')
98 #define AI_LWO_TFP1  AI_IFF_FOURCC('T','F','P','1')
99 
100 
101 /* top-level chunks */
102 #define AI_LWO_LAYR  AI_IFF_FOURCC('L','A','Y','R')
103 #define AI_LWO_TAGS  AI_IFF_FOURCC('T','A','G','S')
104 #define AI_LWO_PNTS  AI_IFF_FOURCC('P','N','T','S')
105 #define AI_LWO_BBOX  AI_IFF_FOURCC('B','B','O','X')
106 #define AI_LWO_VMAP  AI_IFF_FOURCC('V','M','A','P')
107 #define AI_LWO_VMAD  AI_IFF_FOURCC('V','M','A','D')
108 #define AI_LWO_POLS  AI_IFF_FOURCC('P','O','L','S')
109 #define AI_LWO_PTAG  AI_IFF_FOURCC('P','T','A','G')
110 #define AI_LWO_ENVL  AI_IFF_FOURCC('E','N','V','L')
111 #define AI_LWO_CLIP  AI_IFF_FOURCC('C','L','I','P')
112 #define AI_LWO_SURF  AI_IFF_FOURCC('S','U','R','F')
113 #define AI_LWO_DESC  AI_IFF_FOURCC('D','E','S','C')
114 #define AI_LWO_TEXT  AI_IFF_FOURCC('T','E','X','T')
115 #define AI_LWO_ICON  AI_IFF_FOURCC('I','C','O','N')
116 
117 /* polygon types */
118 #define AI_LWO_FACE  AI_IFF_FOURCC('F','A','C','E')
119 #define AI_LWO_CURV  AI_IFF_FOURCC('C','U','R','V')
120 #define AI_LWO_PTCH  AI_IFF_FOURCC('P','T','C','H')
121 #define AI_LWO_MBAL  AI_IFF_FOURCC('M','B','A','L')
122 #define AI_LWO_BONE  AI_IFF_FOURCC('B','O','N','E')
123 #define AI_LWO_SUBD  AI_IFF_FOURCC('S','U','B','D')
124 
125 /* polygon tags */
126 #define AI_LWO_SURF  AI_IFF_FOURCC('S','U','R','F')
127 #define AI_LWO_PART  AI_IFF_FOURCC('P','A','R','T')
128 #define AI_LWO_SMGP  AI_IFF_FOURCC('S','M','G','P')
129 
130 /* envelopes */
131 #define AI_LWO_PRE   AI_IFF_FOURCC('P','R','E',' ')
132 #define AI_LWO_POST  AI_IFF_FOURCC('P','O','S','T')
133 #define AI_LWO_KEY   AI_IFF_FOURCC('K','E','Y',' ')
134 #define AI_LWO_SPAN  AI_IFF_FOURCC('S','P','A','N')
135 #define AI_LWO_TCB   AI_IFF_FOURCC('T','C','B',' ')
136 #define AI_LWO_HERM  AI_IFF_FOURCC('H','E','R','M')
137 #define AI_LWO_BEZI  AI_IFF_FOURCC('B','E','Z','I')
138 #define AI_LWO_BEZ2  AI_IFF_FOURCC('B','E','Z','2')
139 #define AI_LWO_LINE  AI_IFF_FOURCC('L','I','N','E')
140 #define AI_LWO_STEP  AI_IFF_FOURCC('S','T','E','P')
141 
142 /* clips */
143 #define AI_LWO_STIL  AI_IFF_FOURCC('S','T','I','L')
144 #define AI_LWO_ISEQ  AI_IFF_FOURCC('I','S','E','Q')
145 #define AI_LWO_ANIM  AI_IFF_FOURCC('A','N','I','M')
146 #define AI_LWO_XREF  AI_IFF_FOURCC('X','R','E','F')
147 #define AI_LWO_STCC  AI_IFF_FOURCC('S','T','C','C')
148 #define AI_LWO_TIME  AI_IFF_FOURCC('T','I','M','E')
149 #define AI_LWO_CONT  AI_IFF_FOURCC('C','O','N','T')
150 #define AI_LWO_BRIT  AI_IFF_FOURCC('B','R','I','T')
151 #define AI_LWO_SATR  AI_IFF_FOURCC('S','A','T','R')
152 #define AI_LWO_HUE   AI_IFF_FOURCC('H','U','E',' ')
153 #define AI_LWO_GAMM  AI_IFF_FOURCC('G','A','M','M')
154 #define AI_LWO_NEGA  AI_IFF_FOURCC('N','E','G','A')
155 #define AI_LWO_IFLT  AI_IFF_FOURCC('I','F','L','T')
156 #define AI_LWO_PFLT  AI_IFF_FOURCC('P','F','L','T')
157 
158 /* surfaces */
159 #define AI_LWO_COLR  AI_IFF_FOURCC('C','O','L','R')
160 #define AI_LWO_LUMI  AI_IFF_FOURCC('L','U','M','I')
161 #define AI_LWO_DIFF  AI_IFF_FOURCC('D','I','F','F')
162 #define AI_LWO_SPEC  AI_IFF_FOURCC('S','P','E','C')
163 #define AI_LWO_GLOS  AI_IFF_FOURCC('G','L','O','S')
164 #define AI_LWO_REFL  AI_IFF_FOURCC('R','E','F','L')
165 #define AI_LWO_RFOP  AI_IFF_FOURCC('R','F','O','P')
166 #define AI_LWO_RIMG  AI_IFF_FOURCC('R','I','M','G')
167 #define AI_LWO_RSAN  AI_IFF_FOURCC('R','S','A','N')
168 #define AI_LWO_TRAN  AI_IFF_FOURCC('T','R','A','N')
169 #define AI_LWO_TROP  AI_IFF_FOURCC('T','R','O','P')
170 #define AI_LWO_TIMG  AI_IFF_FOURCC('T','I','M','G')
171 #define AI_LWO_RIND  AI_IFF_FOURCC('R','I','N','D')
172 #define AI_LWO_TRNL  AI_IFF_FOURCC('T','R','N','L')
173 #define AI_LWO_BUMP  AI_IFF_FOURCC('B','U','M','P')
174 #define AI_LWO_SMAN  AI_IFF_FOURCC('S','M','A','N')
175 #define AI_LWO_SIDE  AI_IFF_FOURCC('S','I','D','E')
176 #define AI_LWO_CLRH  AI_IFF_FOURCC('C','L','R','H')
177 #define AI_LWO_CLRF  AI_IFF_FOURCC('C','L','R','F')
178 #define AI_LWO_ADTR  AI_IFF_FOURCC('A','D','T','R')
179 #define AI_LWO_SHRP  AI_IFF_FOURCC('S','H','R','P')
180 #define AI_LWO_LINE  AI_IFF_FOURCC('L','I','N','E')
181 #define AI_LWO_LSIZ  AI_IFF_FOURCC('L','S','I','Z')
182 #define AI_LWO_ALPH  AI_IFF_FOURCC('A','L','P','H')
183 #define AI_LWO_AVAL  AI_IFF_FOURCC('A','V','A','L')
184 #define AI_LWO_GVAL  AI_IFF_FOURCC('G','V','A','L')
185 #define AI_LWO_BLOK  AI_IFF_FOURCC('B','L','O','K')
186 #define AI_LWO_VCOL  AI_IFF_FOURCC('V','C','O','L')
187 
188 /* texture layer */
189 #define AI_LWO_TYPE  AI_IFF_FOURCC('T','Y','P','E')
190 #define AI_LWO_CHAN  AI_IFF_FOURCC('C','H','A','N')
191 #define AI_LWO_NAME  AI_IFF_FOURCC('N','A','M','E')
192 #define AI_LWO_ENAB  AI_IFF_FOURCC('E','N','A','B')
193 #define AI_LWO_OPAC  AI_IFF_FOURCC('O','P','A','C')
194 #define AI_LWO_FLAG  AI_IFF_FOURCC('F','L','A','G')
195 #define AI_LWO_PROJ  AI_IFF_FOURCC('P','R','O','J')
196 #define AI_LWO_STCK  AI_IFF_FOURCC('S','T','C','K')
197 #define AI_LWO_TAMP  AI_IFF_FOURCC('T','A','M','P')
198 
199 /* texture coordinates */
200 #define AI_LWO_TMAP  AI_IFF_FOURCC('T','M','A','P')
201 #define AI_LWO_AXIS  AI_IFF_FOURCC('A','X','I','S')
202 #define AI_LWO_CNTR  AI_IFF_FOURCC('C','N','T','R')
203 #define AI_LWO_SIZE  AI_IFF_FOURCC('S','I','Z','E')
204 #define AI_LWO_ROTA  AI_IFF_FOURCC('R','O','T','A')
205 #define AI_LWO_OREF  AI_IFF_FOURCC('O','R','E','F')
206 #define AI_LWO_FALL  AI_IFF_FOURCC('F','A','L','L')
207 #define AI_LWO_CSYS  AI_IFF_FOURCC('C','S','Y','S')
208 
209 /* image map */
210 #define AI_LWO_IMAP  AI_IFF_FOURCC('I','M','A','P')
211 #define AI_LWO_IMAG  AI_IFF_FOURCC('I','M','A','G')
212 #define AI_LWO_WRAP  AI_IFF_FOURCC('W','R','A','P')
213 #define AI_LWO_WRPW  AI_IFF_FOURCC('W','R','P','W')
214 #define AI_LWO_WRPH  AI_IFF_FOURCC('W','R','P','H')
215 #define AI_LWO_VMAP  AI_IFF_FOURCC('V','M','A','P')
216 #define AI_LWO_AAST  AI_IFF_FOURCC('A','A','S','T')
217 #define AI_LWO_PIXB  AI_IFF_FOURCC('P','I','X','B')
218 
219 /* procedural */
220 #define AI_LWO_PROC  AI_IFF_FOURCC('P','R','O','C')
221 #define AI_LWO_COLR  AI_IFF_FOURCC('C','O','L','R')
222 #define AI_LWO_VALU  AI_IFF_FOURCC('V','A','L','U')
223 #define AI_LWO_FUNC  AI_IFF_FOURCC('F','U','N','C')
224 #define AI_LWO_FTPS  AI_IFF_FOURCC('F','T','P','S')
225 #define AI_LWO_ITPS  AI_IFF_FOURCC('I','T','P','S')
226 #define AI_LWO_ETPS  AI_IFF_FOURCC('E','T','P','S')
227 
228 /* gradient */
229 #define AI_LWO_GRAD  AI_IFF_FOURCC('G','R','A','D')
230 #define AI_LWO_GRST  AI_IFF_FOURCC('G','R','S','T')
231 #define AI_LWO_GREN  AI_IFF_FOURCC('G','R','E','N')
232 #define AI_LWO_PNAM  AI_IFF_FOURCC('P','N','A','M')
233 #define AI_LWO_INAM  AI_IFF_FOURCC('I','N','A','M')
234 #define AI_LWO_GRPT  AI_IFF_FOURCC('G','R','P','T')
235 #define AI_LWO_FKEY  AI_IFF_FOURCC('F','K','E','Y')
236 #define AI_LWO_IKEY  AI_IFF_FOURCC('I','K','E','Y')
237 
238 /* shader */
239 #define AI_LWO_SHDR  AI_IFF_FOURCC('S','H','D','R')
240 #define AI_LWO_DATA  AI_IFF_FOURCC('D','A','T','A')
241 
242 
243 /* VMAP types */
244 #define AI_LWO_TXUV  AI_IFF_FOURCC('T','X','U','V')
245 #define AI_LWO_RGB   AI_IFF_FOURCC('R','G','B',' ')
246 #define AI_LWO_RGBA  AI_IFF_FOURCC('R','G','B','A')
247 #define AI_LWO_WGHT  AI_IFF_FOURCC('W','G','H','T')
248 
249 #define AI_LWO_MNVW  AI_IFF_FOURCC('M','N','V','W')
250 #define AI_LWO_MORF  AI_IFF_FOURCC('M','O','R','F')
251 #define AI_LWO_SPOT  AI_IFF_FOURCC('S','P','O','T')
252 #define AI_LWO_PICK  AI_IFF_FOURCC('P','I','C','K')
253 
254 // MODO extension - per-vertex normal vectors
255 #define AI_LWO_MODO_NORM AI_IFF_FOURCC('N', 'O', 'R', 'M')
256 
257 
258 // ---------------------------------------------------------------------------
259 /** \brief Data structure for a face in a LWO file
260  *
261  * \note We can't use the code in SmoothingGroups.inl here - the mesh
262  *   structures of 3DS/ASE and LWO are too different.
263  */
264 struct Face : public aiFace {
265     //! Default construction
FaceFace266     Face() AI_NO_EXCEPT
267     : surfaceIndex( 0 )
268     , smoothGroup( 0 )
269     , type( AI_LWO_FACE ) {
270         // empty
271     }
272 
273     //! Construction from given type
FaceFace274     explicit Face(uint32_t _type)
275         : surfaceIndex  (0)
276         , smoothGroup   (0)
277         , type          (_type)
278     {}
279 
280     //! Copy construction
FaceFace281     Face(const Face& f) : aiFace() {
282         *this = f;
283     }
284 
285     //! Zero-based index into tags chunk
286     unsigned int surfaceIndex;
287 
288     //! Smooth group this face is assigned to
289     unsigned int smoothGroup;
290 
291     //! Type of face
292     uint32_t type;
293 
294 
295     //! Assignment operator
296     Face& operator=(const LWO::Face& f) {
297         aiFace::operator =(f);
298         surfaceIndex    = f.surfaceIndex;
299         smoothGroup     = f.smoothGroup;
300         type            = f.type;
301         return *this;
302     }
303 };
304 
305 // ---------------------------------------------------------------------------
306 /** \brief Base structure for all vertex map representations
307  */
308 struct VMapEntry
309 {
VMapEntryVMapEntry310     explicit VMapEntry(unsigned int _dims)
311         :  dims(_dims)
312     {}
313 
~VMapEntryVMapEntry314     virtual ~VMapEntry() {}
315 
316     //! allocates memory for the vertex map
AllocateVMapEntry317     virtual void Allocate(unsigned int num)
318     {
319         if (!rawData.empty())
320             return; // return if already allocated
321 
322         const unsigned int m = num*dims;
323         rawData.reserve(m + (m>>2u)); // 25% as  extra storage for VMADs
324         rawData.resize(m,0.f);
325         abAssigned.resize(num,false);
326     }
327 
328     std::string name;
329     unsigned int dims;
330 
331     std::vector<float> rawData;
332     std::vector<bool> abAssigned;
333 };
334 
335 // ---------------------------------------------------------------------------
336 /** \brief Represents an extra vertex color channel
337  */
338 struct VColorChannel : public VMapEntry
339 {
VColorChannelVColorChannel340     VColorChannel()
341         : VMapEntry(4)
342     {}
343 
344     //! need to overwrite this function - the alpha channel must
345     //! be initialized to 1.0 by default
AllocateVColorChannel346     virtual void Allocate(unsigned int num)
347     {
348         if (!rawData.empty())
349             return; // return if already allocated
350 
351         unsigned int m = num*dims;
352         rawData.reserve(m + (m>>2u)); // 25% as  extra storage for VMADs
353         rawData.resize(m);
354 
355         for (aiColor4D* p = (aiColor4D*)&rawData[0]; p < (aiColor4D*)&rawData[m-1]; ++p)
356             p->a = 1.f;
357 
358         abAssigned.resize(num,false);
359     }
360 };
361 
362 // ---------------------------------------------------------------------------
363 /** \brief Represents an extra vertex UV channel
364  */
365 struct UVChannel : public VMapEntry
366 {
UVChannelUVChannel367     UVChannel()
368         : VMapEntry(2)
369     {}
370 };
371 
372 // ---------------------------------------------------------------------------
373 /** \brief Represents a weight map
374  */
375 struct WeightChannel : public VMapEntry
376 {
WeightChannelWeightChannel377     WeightChannel()
378         : VMapEntry(1)
379     {}
380 };
381 
382 // ---------------------------------------------------------------------------
383 /** \brief Represents a vertex-normals channel (MODO extension)
384  */
385 struct NormalChannel : public VMapEntry
386 {
NormalChannelNormalChannel387     NormalChannel()
388         : VMapEntry(3)
389     {}
390 };
391 
392 // ---------------------------------------------------------------------------
393 /** \brief Data structure for a LWO file texture
394  */
395 struct Texture
396 {
397     // we write the enum values out here to make debugging easier ...
398     enum BlendType
399     {
400         Normal          = 0,
401         Subtractive     = 1,
402         Difference      = 2,
403         Multiply        = 3,
404         Divide          = 4,
405         Alpha           = 5,
406         TextureDispl    = 6,
407         Additive        = 7
408     };
409 
410     enum MappingMode
411     {
412         Planar          = 0,
413         Cylindrical     = 1,
414         Spherical       = 2,
415         Cubic           = 3,
416         FrontProjection = 4,
417         UV              = 5
418     };
419 
420     enum Axes
421     {
422         AXIS_X          = 0,
423         AXIS_Y          = 1,
424         AXIS_Z          = 2
425     };
426 
427     enum Wrap
428     {
429         RESET           = 0,
430         REPEAT          = 1,
431         MIRROR          = 2,
432         EDGE            = 3
433     };
434 
TextureTexture435     Texture()
436         : mClipIdx(UINT_MAX)
437         , mStrength         (1.0f)
438         , type()
439         , mUVChannelIndex   ("unknown")
440         , mRealUVIndex      (UINT_MAX)
441         , enabled           (true)
442         , blendType         (Additive)
443         , bCanUse           (true)
444         , mapMode           (UV)
445         , majorAxis         (AXIS_X)
446         , wrapAmountH       (1.0f)
447         , wrapAmountW       (1.0f)
448         , wrapModeWidth     (REPEAT)
449         , wrapModeHeight    (REPEAT)
450         , ordinal           ("\x00")
451     {}
452 
453     //! File name of the texture
454     std::string mFileName;
455 
456     //! Clip index
457     unsigned int mClipIdx;
458 
459     //! Strength of the texture - blend factor
460     float mStrength;
461 
462     uint32_t type; // type of the texture
463 
464     //! Name of the corresponding UV channel
465     std::string mUVChannelIndex;
466     unsigned int mRealUVIndex;
467 
468     //! is the texture enabled?
469     bool enabled;
470 
471     //! blend type
472     BlendType blendType;
473 
474     //! are we able to use the texture?
475     bool bCanUse;
476 
477     //! mapping mode
478     MappingMode mapMode;
479 
480     //! major axis for planar, cylindrical, spherical projections
481     Axes majorAxis;
482 
483     //! wrap amount for cylindrical and spherical projections
484     float wrapAmountH,wrapAmountW;
485 
486     //! wrapping mode for the texture
487     Wrap wrapModeWidth,wrapModeHeight;
488 
489     //! ordinal string of the texture
490     std::string ordinal;
491 };
492 
493 // ---------------------------------------------------------------------------
494 /** \brief Data structure for a LWO file clip
495  */
496 struct Clip
497 {
498     enum Type
499     {
500          STILL, SEQ, REF, UNSUPPORTED
501     } type;
502 
ClipClip503     Clip()
504         : type   (UNSUPPORTED)
505         , clipRef()
506         , idx    (0)
507         , negate (false)
508     {}
509 
510     //! path to the base texture -
511     std::string path;
512 
513     //! reference to another CLIP
514     unsigned int clipRef;
515 
516     //! index of the clip
517     unsigned int idx;
518 
519     //! Negate the clip?
520     bool negate;
521 };
522 
523 
524 // ---------------------------------------------------------------------------
525 /** \brief Data structure for a LWO file shader
526  *
527  *  Later
528  */
529 struct Shader
530 {
ShaderShader531     Shader()
532         :   ordinal         ("\x00")
533         ,   functionName    ("unknown")
534         ,   enabled         (true)
535     {}
536 
537     std::string ordinal;
538     std::string functionName;
539     bool enabled;
540 };
541 
542 typedef std::list < Texture >       TextureList;
543 typedef std::list < Shader >        ShaderList;
544 
545 // ---------------------------------------------------------------------------
546 /** \brief Data structure for a LWO file surface (= material)
547  */
548 struct Surface
549 {
SurfaceSurface550     Surface()
551         : mColor                (0.78431f,0.78431f,0.78431f)
552         , bDoubleSided          (false)
553         , mDiffuseValue         (1.f)
554         , mSpecularValue        (0.f)
555         , mTransparency         (0.f)
556         , mGlossiness           (0.4f)
557         , mLuminosity           (0.f)
558         , mColorHighlights      (0.f)
559         , mMaximumSmoothAngle   (0.f) // 0 == not specified, no smoothing
560         , mVCMap                ("")
561         , mVCMapType            (AI_LWO_RGBA)
562         , mIOR                  (1.f) // vakuum
563         , mBumpIntensity        (1.f)
564         , mWireframe            (false)
565         , mAdditiveTransparency (0.f)
566     {}
567 
568     //! Name of the surface
569     std::string mName;
570 
571     //! Color of the surface
572     aiColor3D mColor;
573 
574     //! true for two-sided materials
575     bool bDoubleSided;
576 
577     //! Various material parameters
578     float mDiffuseValue,mSpecularValue,mTransparency,mGlossiness,mLuminosity,mColorHighlights;
579 
580     //! Maximum angle between two adjacent triangles
581     //! that they can be smoothed - in degrees
582     float mMaximumSmoothAngle;
583 
584     //! Vertex color map to be used to color the surface
585     std::string mVCMap;
586     uint32_t mVCMapType;
587 
588     //! Names of the special shaders to be applied to the surface
589     ShaderList mShaders;
590 
591     //! Textures - the first entry in the list is evaluated first
592     TextureList mColorTextures, // color textures are added to both diffuse and specular texture stacks
593         mDiffuseTextures,
594         mSpecularTextures,
595         mOpacityTextures,
596         mBumpTextures,
597         mGlossinessTextures,
598         mReflectionTextures;
599 
600     //! Index of refraction
601     float mIOR;
602 
603     //! Bump intensity scaling
604     float mBumpIntensity;
605 
606     //! Wireframe flag
607     bool mWireframe;
608 
609     //! Intensity of additive blending
610     float mAdditiveTransparency;
611 };
612 
613 // ---------------------------------------------------------------------------
614 #define AI_LWO_VALIDATE_CHUNK_LENGTH(length,name,size) \
615     if (length < size) \
616     { \
617         throw DeadlyImportError("LWO: "#name" chunk is too small"); \
618     } \
619 
620 
621 // some typedefs ... to make life with loader monsters like this easier
622 typedef std::vector <   aiVector3D      >   PointList;
623 typedef std::vector <   LWO::Face       >   FaceList;
624 typedef std::vector <   LWO::Surface    >   SurfaceList;
625 typedef std::vector <   std::string     >   TagList;
626 typedef std::vector <   unsigned int    >   TagMappingTable;
627 typedef std::vector <   unsigned int    >   ReferrerList;
628 typedef std::vector <   WeightChannel   >   WeightChannelList;
629 typedef std::vector <   VColorChannel   >   VColorChannelList;
630 typedef std::vector <   UVChannel       >   UVChannelList;
631 typedef std::vector <   Clip            >   ClipList;
632 typedef std::vector <   Envelope        >   EnvelopeList;
633 typedef std::vector <   unsigned int    >   SortedRep;
634 
635 // ---------------------------------------------------------------------------
636 /** \brief Represents a layer in the file
637  */
638 struct Layer
639 {
LayerLayer640     Layer()
641         : mFaceIDXOfs   (0)
642         , mPointIDXOfs  (0)
643         , mParent       (0x0)
644         , mIndex        (0xffff)
645         , skip          (false)
646     {}
647 
648     /** Temporary point list from the file */
649     PointList mTempPoints;
650 
651     /** Lists for every point the index of another point
652         that has been copied from *this* point or UINT_MAX if
653         no copy of the point has been made */
654     ReferrerList mPointReferrers;
655 
656     /** Weight channel list from the file */
657     WeightChannelList mWeightChannels;
658 
659     /** Subdivision weight channel list from the file */
660     WeightChannelList mSWeightChannels;
661 
662     /** Vertex color list from the file */
663     VColorChannelList mVColorChannels;
664 
665     /** UV channel list from the file */
666     UVChannelList mUVChannels;
667 
668     /** Normal vector channel from the file */
669     NormalChannel mNormals;
670 
671     /** Temporary face list from the file*/
672     FaceList mFaces;
673 
674     /** Current face indexing offset from the beginning of the buffers*/
675     unsigned int mFaceIDXOfs;
676 
677     /** Current point indexing offset from the beginning of the buffers*/
678     unsigned int mPointIDXOfs;
679 
680     /** Parent index */
681     uint16_t mParent;
682 
683     /** Index of the layer */
684     uint16_t mIndex;
685 
686     /** Name of the layer */
687     std::string mName;
688 
689     /** Pivot point of the layer */
690     aiVector3D mPivot;
691 
692     /** Skip this layer? */
693     bool skip;
694 };
695 
696 typedef std::list<LWO::Layer>       LayerList;
697 
698 
699 }}
700 
701 
702 #endif // !! AI_LWO_FILEDATA_INCLUDED
703 
704