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