25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

LWOFileData.h 20 KiB

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