vrshoot

diff libs/assimp/LWOFileData.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/assimp/LWOFileData.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,699 @@
     1.4 +/*
     1.5 +Open Asset Import Library (assimp)
     1.6 +----------------------------------------------------------------------
     1.7 +
     1.8 +Copyright (c) 2006-2012, assimp team
     1.9 +All rights reserved.
    1.10 +
    1.11 +Redistribution and use of this software in source and binary forms, 
    1.12 +with or without modification, are permitted provided that the 
    1.13 +following conditions are met:
    1.14 +
    1.15 +* Redistributions of source code must retain the above
    1.16 +  copyright notice, this list of conditions and the
    1.17 +  following disclaimer.
    1.18 +
    1.19 +* Redistributions in binary form must reproduce the above
    1.20 +  copyright notice, this list of conditions and the
    1.21 +  following disclaimer in the documentation and/or other
    1.22 +  materials provided with the distribution.
    1.23 +
    1.24 +* Neither the name of the assimp team, nor the names of its
    1.25 +  contributors may be used to endorse or promote products
    1.26 +  derived from this software without specific prior
    1.27 +  written permission of the assimp team.
    1.28 +
    1.29 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    1.30 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    1.31 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.32 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    1.33 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.34 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    1.35 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.36 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    1.37 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    1.38 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    1.39 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.40 +
    1.41 +----------------------------------------------------------------------
    1.42 +*/
    1.43 +
    1.44 +/** @file LWOFileData.h
    1.45 + *  @brief Defines chunk constants used by the LWO file format
    1.46 +
    1.47 +The chunks are taken from the official LightWave SDK headers.
    1.48 + 
    1.49 +*/
    1.50 +#ifndef AI_LWO_FILEDATA_INCLUDED
    1.51 +#define AI_LWO_FILEDATA_INCLUDED
    1.52 +
    1.53 +// STL headers
    1.54 +#include <vector>
    1.55 +#include <list>
    1.56 +
    1.57 +// public ASSIMP headers
    1.58 +#include "assimp/mesh.h"
    1.59 +
    1.60 +// internal headers
    1.61 +#include "IFF.h"
    1.62 +#include "LWOAnimation.h"
    1.63 +
    1.64 +namespace Assimp {
    1.65 +namespace LWO {
    1.66 +
    1.67 +#define AI_LWO_FOURCC_LWOB AI_IFF_FOURCC('L','W','O','B')
    1.68 +#define AI_LWO_FOURCC_LWO2 AI_IFF_FOURCC('L','W','O','2')
    1.69 +#define AI_LWO_FOURCC_LXOB AI_IFF_FOURCC('L','X','O','B')
    1.70 +
    1.71 +// chunks specific to the LWOB format
    1.72 +#define AI_LWO_SRFS  AI_IFF_FOURCC('S','R','F','S')
    1.73 +#define AI_LWO_FLAG  AI_IFF_FOURCC('F','L','A','G')
    1.74 +#define AI_LWO_VLUM  AI_IFF_FOURCC('V','L','U','M')
    1.75 +#define AI_LWO_VDIF  AI_IFF_FOURCC('V','D','I','F')
    1.76 +#define AI_LWO_VSPC  AI_IFF_FOURCC('V','S','P','C')
    1.77 +#define AI_LWO_RFLT  AI_IFF_FOURCC('R','F','L','T')
    1.78 +#define AI_LWO_BTEX  AI_IFF_FOURCC('B','T','E','X')
    1.79 +#define AI_LWO_CTEX  AI_IFF_FOURCC('C','T','E','X')
    1.80 +#define AI_LWO_DTEX  AI_IFF_FOURCC('D','T','E','X')
    1.81 +#define AI_LWO_LTEX  AI_IFF_FOURCC('L','T','E','X')
    1.82 +#define AI_LWO_RTEX  AI_IFF_FOURCC('R','T','E','X')
    1.83 +#define AI_LWO_STEX  AI_IFF_FOURCC('S','T','E','X')
    1.84 +#define AI_LWO_TTEX  AI_IFF_FOURCC('T','T','E','X')
    1.85 +#define AI_LWO_TFLG  AI_IFF_FOURCC('T','F','L','G')
    1.86 +#define AI_LWO_TSIZ  AI_IFF_FOURCC('T','S','I','Z')
    1.87 +#define AI_LWO_TCTR  AI_IFF_FOURCC('T','C','T','R')
    1.88 +#define AI_LWO_TFAL  AI_IFF_FOURCC('T','F','A','L')
    1.89 +#define AI_LWO_TVEL  AI_IFF_FOURCC('T','V','E','L')
    1.90 +#define AI_LWO_TCLR  AI_IFF_FOURCC('T','C','L','R')
    1.91 +#define AI_LWO_TVAL  AI_IFF_FOURCC('T','V','A','L')
    1.92 +#define AI_LWO_TAMP  AI_IFF_FOURCC('T','A','M','P')
    1.93 +#define AI_LWO_TIMG  AI_IFF_FOURCC('T','I','M','G')
    1.94 +#define AI_LWO_TAAS  AI_IFF_FOURCC('T','A','A','S')
    1.95 +#define AI_LWO_TREF  AI_IFF_FOURCC('T','R','E','F')
    1.96 +#define AI_LWO_TOPC  AI_IFF_FOURCC('T','O','P','C')
    1.97 +#define AI_LWO_SDAT  AI_IFF_FOURCC('S','D','A','T')
    1.98 +#define AI_LWO_TFP0  AI_IFF_FOURCC('T','F','P','0')
    1.99 +#define AI_LWO_TFP1  AI_IFF_FOURCC('T','F','P','1')
   1.100 +
   1.101 +
   1.102 +/* top-level chunks */
   1.103 +#define AI_LWO_LAYR  AI_IFF_FOURCC('L','A','Y','R')
   1.104 +#define AI_LWO_TAGS  AI_IFF_FOURCC('T','A','G','S')
   1.105 +#define AI_LWO_PNTS  AI_IFF_FOURCC('P','N','T','S')
   1.106 +#define AI_LWO_BBOX  AI_IFF_FOURCC('B','B','O','X')
   1.107 +#define AI_LWO_VMAP  AI_IFF_FOURCC('V','M','A','P')
   1.108 +#define AI_LWO_VMAD  AI_IFF_FOURCC('V','M','A','D')
   1.109 +#define AI_LWO_POLS  AI_IFF_FOURCC('P','O','L','S')
   1.110 +#define AI_LWO_PTAG  AI_IFF_FOURCC('P','T','A','G')
   1.111 +#define AI_LWO_ENVL  AI_IFF_FOURCC('E','N','V','L')
   1.112 +#define AI_LWO_CLIP  AI_IFF_FOURCC('C','L','I','P')
   1.113 +#define AI_LWO_SURF  AI_IFF_FOURCC('S','U','R','F')
   1.114 +#define AI_LWO_DESC  AI_IFF_FOURCC('D','E','S','C')
   1.115 +#define AI_LWO_TEXT  AI_IFF_FOURCC('T','E','X','T')
   1.116 +#define AI_LWO_ICON  AI_IFF_FOURCC('I','C','O','N')
   1.117 +
   1.118 +/* polygon types */
   1.119 +#define AI_LWO_FACE  AI_IFF_FOURCC('F','A','C','E')
   1.120 +#define AI_LWO_CURV  AI_IFF_FOURCC('C','U','R','V')
   1.121 +#define AI_LWO_PTCH  AI_IFF_FOURCC('P','T','C','H')
   1.122 +#define AI_LWO_MBAL  AI_IFF_FOURCC('M','B','A','L')
   1.123 +#define AI_LWO_BONE  AI_IFF_FOURCC('B','O','N','E')
   1.124 +#define AI_LWO_SUBD  AI_IFF_FOURCC('S','U','B','D')
   1.125 +
   1.126 +/* polygon tags */
   1.127 +#define AI_LWO_SURF  AI_IFF_FOURCC('S','U','R','F')
   1.128 +#define AI_LWO_PART  AI_IFF_FOURCC('P','A','R','T')
   1.129 +#define AI_LWO_SMGP  AI_IFF_FOURCC('S','M','G','P')
   1.130 +
   1.131 +/* envelopes */
   1.132 +#define AI_LWO_PRE   AI_IFF_FOURCC('P','R','E',' ')
   1.133 +#define AI_LWO_POST  AI_IFF_FOURCC('P','O','S','T')
   1.134 +#define AI_LWO_KEY   AI_IFF_FOURCC('K','E','Y',' ')
   1.135 +#define AI_LWO_SPAN  AI_IFF_FOURCC('S','P','A','N')
   1.136 +#define AI_LWO_TCB   AI_IFF_FOURCC('T','C','B',' ')
   1.137 +#define AI_LWO_HERM  AI_IFF_FOURCC('H','E','R','M')
   1.138 +#define AI_LWO_BEZI  AI_IFF_FOURCC('B','E','Z','I')
   1.139 +#define AI_LWO_BEZ2  AI_IFF_FOURCC('B','E','Z','2')
   1.140 +#define AI_LWO_LINE  AI_IFF_FOURCC('L','I','N','E')
   1.141 +#define AI_LWO_STEP  AI_IFF_FOURCC('S','T','E','P')
   1.142 +
   1.143 +/* clips */
   1.144 +#define AI_LWO_STIL  AI_IFF_FOURCC('S','T','I','L')
   1.145 +#define AI_LWO_ISEQ  AI_IFF_FOURCC('I','S','E','Q')
   1.146 +#define AI_LWO_ANIM  AI_IFF_FOURCC('A','N','I','M')
   1.147 +#define AI_LWO_XREF  AI_IFF_FOURCC('X','R','E','F')
   1.148 +#define AI_LWO_STCC  AI_IFF_FOURCC('S','T','C','C')
   1.149 +#define AI_LWO_TIME  AI_IFF_FOURCC('T','I','M','E')
   1.150 +#define AI_LWO_CONT  AI_IFF_FOURCC('C','O','N','T')
   1.151 +#define AI_LWO_BRIT  AI_IFF_FOURCC('B','R','I','T')
   1.152 +#define AI_LWO_SATR  AI_IFF_FOURCC('S','A','T','R')
   1.153 +#define AI_LWO_HUE   AI_IFF_FOURCC('H','U','E',' ')
   1.154 +#define AI_LWO_GAMM  AI_IFF_FOURCC('G','A','M','M')
   1.155 +#define AI_LWO_NEGA  AI_IFF_FOURCC('N','E','G','A')
   1.156 +#define AI_LWO_IFLT  AI_IFF_FOURCC('I','F','L','T')
   1.157 +#define AI_LWO_PFLT  AI_IFF_FOURCC('P','F','L','T')
   1.158 +
   1.159 +/* surfaces */
   1.160 +#define AI_LWO_COLR  AI_IFF_FOURCC('C','O','L','R')
   1.161 +#define AI_LWO_LUMI  AI_IFF_FOURCC('L','U','M','I')
   1.162 +#define AI_LWO_DIFF  AI_IFF_FOURCC('D','I','F','F')
   1.163 +#define AI_LWO_SPEC  AI_IFF_FOURCC('S','P','E','C')
   1.164 +#define AI_LWO_GLOS  AI_IFF_FOURCC('G','L','O','S')
   1.165 +#define AI_LWO_REFL  AI_IFF_FOURCC('R','E','F','L')
   1.166 +#define AI_LWO_RFOP  AI_IFF_FOURCC('R','F','O','P')
   1.167 +#define AI_LWO_RIMG  AI_IFF_FOURCC('R','I','M','G')
   1.168 +#define AI_LWO_RSAN  AI_IFF_FOURCC('R','S','A','N')
   1.169 +#define AI_LWO_TRAN  AI_IFF_FOURCC('T','R','A','N')
   1.170 +#define AI_LWO_TROP  AI_IFF_FOURCC('T','R','O','P')
   1.171 +#define AI_LWO_TIMG  AI_IFF_FOURCC('T','I','M','G')
   1.172 +#define AI_LWO_RIND  AI_IFF_FOURCC('R','I','N','D')
   1.173 +#define AI_LWO_TRNL  AI_IFF_FOURCC('T','R','N','L')
   1.174 +#define AI_LWO_BUMP  AI_IFF_FOURCC('B','U','M','P')
   1.175 +#define AI_LWO_SMAN  AI_IFF_FOURCC('S','M','A','N')
   1.176 +#define AI_LWO_SIDE  AI_IFF_FOURCC('S','I','D','E')
   1.177 +#define AI_LWO_CLRH  AI_IFF_FOURCC('C','L','R','H')
   1.178 +#define AI_LWO_CLRF  AI_IFF_FOURCC('C','L','R','F')
   1.179 +#define AI_LWO_ADTR  AI_IFF_FOURCC('A','D','T','R')
   1.180 +#define AI_LWO_SHRP  AI_IFF_FOURCC('S','H','R','P')
   1.181 +#define AI_LWO_LINE  AI_IFF_FOURCC('L','I','N','E')
   1.182 +#define AI_LWO_LSIZ  AI_IFF_FOURCC('L','S','I','Z')
   1.183 +#define AI_LWO_ALPH  AI_IFF_FOURCC('A','L','P','H')
   1.184 +#define AI_LWO_AVAL  AI_IFF_FOURCC('A','V','A','L')
   1.185 +#define AI_LWO_GVAL  AI_IFF_FOURCC('G','V','A','L')
   1.186 +#define AI_LWO_BLOK  AI_IFF_FOURCC('B','L','O','K')
   1.187 +#define AI_LWO_VCOL  AI_IFF_FOURCC('V','C','O','L')
   1.188 +
   1.189 +/* texture layer */
   1.190 +#define AI_LWO_TYPE  AI_IFF_FOURCC('T','Y','P','E')
   1.191 +#define AI_LWO_CHAN  AI_IFF_FOURCC('C','H','A','N')
   1.192 +#define AI_LWO_NAME  AI_IFF_FOURCC('N','A','M','E')
   1.193 +#define AI_LWO_ENAB  AI_IFF_FOURCC('E','N','A','B')
   1.194 +#define AI_LWO_OPAC  AI_IFF_FOURCC('O','P','A','C')
   1.195 +#define AI_LWO_FLAG  AI_IFF_FOURCC('F','L','A','G')
   1.196 +#define AI_LWO_PROJ  AI_IFF_FOURCC('P','R','O','J')
   1.197 +#define AI_LWO_STCK  AI_IFF_FOURCC('S','T','C','K')
   1.198 +#define AI_LWO_TAMP  AI_IFF_FOURCC('T','A','M','P')
   1.199 +
   1.200 +/* texture coordinates */
   1.201 +#define AI_LWO_TMAP  AI_IFF_FOURCC('T','M','A','P')
   1.202 +#define AI_LWO_AXIS  AI_IFF_FOURCC('A','X','I','S')
   1.203 +#define AI_LWO_CNTR  AI_IFF_FOURCC('C','N','T','R')
   1.204 +#define AI_LWO_SIZE  AI_IFF_FOURCC('S','I','Z','E')
   1.205 +#define AI_LWO_ROTA  AI_IFF_FOURCC('R','O','T','A')
   1.206 +#define AI_LWO_OREF  AI_IFF_FOURCC('O','R','E','F')
   1.207 +#define AI_LWO_FALL  AI_IFF_FOURCC('F','A','L','L')
   1.208 +#define AI_LWO_CSYS  AI_IFF_FOURCC('C','S','Y','S')
   1.209 +
   1.210 +/* image map */
   1.211 +#define AI_LWO_IMAP  AI_IFF_FOURCC('I','M','A','P')
   1.212 +#define AI_LWO_IMAG  AI_IFF_FOURCC('I','M','A','G')
   1.213 +#define AI_LWO_WRAP  AI_IFF_FOURCC('W','R','A','P')
   1.214 +#define AI_LWO_WRPW  AI_IFF_FOURCC('W','R','P','W')
   1.215 +#define AI_LWO_WRPH  AI_IFF_FOURCC('W','R','P','H')
   1.216 +#define AI_LWO_VMAP  AI_IFF_FOURCC('V','M','A','P')
   1.217 +#define AI_LWO_AAST  AI_IFF_FOURCC('A','A','S','T')
   1.218 +#define AI_LWO_PIXB  AI_IFF_FOURCC('P','I','X','B')
   1.219 +
   1.220 +/* procedural */
   1.221 +#define AI_LWO_PROC  AI_IFF_FOURCC('P','R','O','C')
   1.222 +#define AI_LWO_COLR  AI_IFF_FOURCC('C','O','L','R')
   1.223 +#define AI_LWO_VALU  AI_IFF_FOURCC('V','A','L','U')
   1.224 +#define AI_LWO_FUNC  AI_IFF_FOURCC('F','U','N','C')
   1.225 +#define AI_LWO_FTPS  AI_IFF_FOURCC('F','T','P','S')
   1.226 +#define AI_LWO_ITPS  AI_IFF_FOURCC('I','T','P','S')
   1.227 +#define AI_LWO_ETPS  AI_IFF_FOURCC('E','T','P','S')
   1.228 +
   1.229 +/* gradient */
   1.230 +#define AI_LWO_GRAD  AI_IFF_FOURCC('G','R','A','D')
   1.231 +#define AI_LWO_GRST  AI_IFF_FOURCC('G','R','S','T')
   1.232 +#define AI_LWO_GREN  AI_IFF_FOURCC('G','R','E','N')
   1.233 +#define AI_LWO_PNAM  AI_IFF_FOURCC('P','N','A','M')
   1.234 +#define AI_LWO_INAM  AI_IFF_FOURCC('I','N','A','M')
   1.235 +#define AI_LWO_GRPT  AI_IFF_FOURCC('G','R','P','T')
   1.236 +#define AI_LWO_FKEY  AI_IFF_FOURCC('F','K','E','Y')
   1.237 +#define AI_LWO_IKEY  AI_IFF_FOURCC('I','K','E','Y')
   1.238 +
   1.239 +/* shader */
   1.240 +#define AI_LWO_SHDR  AI_IFF_FOURCC('S','H','D','R')
   1.241 +#define AI_LWO_DATA  AI_IFF_FOURCC('D','A','T','A')
   1.242 +
   1.243 +
   1.244 +/* VMAP types */
   1.245 +#define AI_LWO_TXUV  AI_IFF_FOURCC('T','X','U','V')
   1.246 +#define AI_LWO_RGB   AI_IFF_FOURCC('R','G','B',' ')
   1.247 +#define AI_LWO_RGBA  AI_IFF_FOURCC('R','G','B','A')
   1.248 +#define AI_LWO_WGHT  AI_IFF_FOURCC('W','G','H','T')
   1.249 +
   1.250 +#define AI_LWO_MNVW  AI_IFF_FOURCC('M','N','V','W')
   1.251 +#define AI_LWO_MORF  AI_IFF_FOURCC('M','O','R','F')
   1.252 +#define AI_LWO_SPOT  AI_IFF_FOURCC('S','P','O','T')
   1.253 +#define AI_LWO_PICK  AI_IFF_FOURCC('P','I','C','K')
   1.254 +
   1.255 +// MODO extension - per-vertex normal vectors
   1.256 +#define AI_LWO_MODO_NORM AI_IFF_FOURCC('N', 'O', 'R', 'M')
   1.257 +
   1.258 +
   1.259 +// ---------------------------------------------------------------------------
   1.260 +/** \brief Data structure for a face in a LWO file
   1.261 + *
   1.262 + * \note We can't use the code in SmoothingGroups.inl here - the mesh
   1.263 + *   structures of 3DS/ASE and LWO are too different. 
   1.264 + */
   1.265 +struct Face : public aiFace
   1.266 +{
   1.267 +	//! Default construction
   1.268 +	Face() 
   1.269 +		: surfaceIndex	(0)
   1.270 +		, smoothGroup	(0)
   1.271 +		, type			(AI_LWO_FACE)
   1.272 +	{}
   1.273 +
   1.274 +	//! Construction from given type
   1.275 +	Face(uint32_t _type) 
   1.276 +		: surfaceIndex	(0)
   1.277 +		, smoothGroup	(0)
   1.278 +		, type			(_type)
   1.279 +	{}
   1.280 +
   1.281 +	//! Copy construction
   1.282 +	Face(const Face& f) : aiFace() {
   1.283 +		*this = f;
   1.284 +	}
   1.285 +
   1.286 +	//! Zero-based index into tags chunk
   1.287 +	unsigned int surfaceIndex;
   1.288 +
   1.289 +	//! Smooth group this face is assigned to
   1.290 +	unsigned int smoothGroup;
   1.291 +
   1.292 +	//! Type of face
   1.293 +	uint32_t type;
   1.294 +
   1.295 +
   1.296 +	//! Assignment operator
   1.297 +	Face& operator=(const LWO::Face& f)	{
   1.298 +		aiFace::operator =(f);
   1.299 +		surfaceIndex	= f.surfaceIndex;
   1.300 +		smoothGroup		= f.smoothGroup;
   1.301 +		type            = f.type;
   1.302 +		return *this;
   1.303 +	}
   1.304 +};
   1.305 +
   1.306 +// ---------------------------------------------------------------------------
   1.307 +/** \brief Base structure for all vertex map representations
   1.308 + */
   1.309 +struct VMapEntry
   1.310 +{
   1.311 +	VMapEntry(unsigned int _dims)
   1.312 +		:  dims(_dims)
   1.313 +	{}
   1.314 +
   1.315 +	virtual ~VMapEntry() {}
   1.316 +
   1.317 +	//! allocates memory for the vertex map
   1.318 +	virtual void Allocate(unsigned int num)
   1.319 +	{
   1.320 +		if (!rawData.empty())
   1.321 +			return; // return if already allocated
   1.322 +
   1.323 +		const unsigned int m = num*dims;
   1.324 +		rawData.reserve(m + (m>>2u)); // 25% as  extra storage for VMADs
   1.325 +		rawData.resize(m,0.f);
   1.326 +		abAssigned.resize(num,false);
   1.327 +	}
   1.328 +
   1.329 +	std::string name;
   1.330 +	unsigned int dims;
   1.331 +
   1.332 +	std::vector<float> rawData;
   1.333 +	std::vector<bool> abAssigned;
   1.334 +};
   1.335 +
   1.336 +// ---------------------------------------------------------------------------
   1.337 +/** \brief Represents an extra vertex color channel
   1.338 + */
   1.339 +struct VColorChannel : public VMapEntry
   1.340 +{
   1.341 +	VColorChannel()
   1.342 +		: VMapEntry(4)
   1.343 +	{}
   1.344 +
   1.345 +	//! need to overwrite this function - the alpha channel must
   1.346 +	//! be initialized to 1.0 by default
   1.347 +	virtual void Allocate(unsigned int num)
   1.348 +	{
   1.349 +		if (!rawData.empty())
   1.350 +			return; // return if already allocated
   1.351 +
   1.352 +		register unsigned int m = num*dims;
   1.353 +		rawData.reserve(m + (m>>2u)); // 25% as  extra storage for VMADs
   1.354 +		rawData.resize(m);
   1.355 +
   1.356 +		for (aiColor4D* p = (aiColor4D*)&rawData[0]; p < (aiColor4D*)&rawData[m-1]; ++p)
   1.357 +			p->a = 1.f;
   1.358 +
   1.359 +		abAssigned.resize(num,false);
   1.360 +	}
   1.361 +};
   1.362 +
   1.363 +// ---------------------------------------------------------------------------
   1.364 +/** \brief Represents an extra vertex UV channel
   1.365 + */
   1.366 +struct UVChannel : public VMapEntry
   1.367 +{
   1.368 +	UVChannel()
   1.369 +		: VMapEntry(2)
   1.370 +	{}
   1.371 +};
   1.372 +
   1.373 +// ---------------------------------------------------------------------------
   1.374 +/** \brief Represents a weight map 
   1.375 + */
   1.376 +struct WeightChannel : public VMapEntry
   1.377 +{
   1.378 +	WeightChannel()
   1.379 +		: VMapEntry(1)
   1.380 +	{}
   1.381 +};
   1.382 +
   1.383 +// ---------------------------------------------------------------------------
   1.384 +/** \brief Represents a vertex-normals channel (MODO extension)
   1.385 + */
   1.386 +struct NormalChannel : public VMapEntry
   1.387 +{
   1.388 +	NormalChannel()
   1.389 +		: VMapEntry(3)
   1.390 +	{}
   1.391 +};
   1.392 +
   1.393 +// ---------------------------------------------------------------------------
   1.394 +/** \brief Data structure for a LWO file texture
   1.395 + */
   1.396 +struct Texture
   1.397 +{
   1.398 +	// we write the enum values out here to make debugging easier ...
   1.399 +	enum BlendType
   1.400 +	{
   1.401 +		Normal			= 0,
   1.402 +		Subtractive		= 1,
   1.403 +		Difference		= 2,
   1.404 +		Multiply		= 3,
   1.405 +		Divide			= 4,
   1.406 +		Alpha			= 5,
   1.407 +		TextureDispl	= 6,
   1.408 +		Additive		= 7
   1.409 +	};
   1.410 +
   1.411 +	enum MappingMode
   1.412 +	{
   1.413 +		Planar			= 0,
   1.414 +		Cylindrical		= 1,
   1.415 +		Spherical		= 2,
   1.416 +		Cubic			= 3,
   1.417 +		FrontProjection	= 4,
   1.418 +		UV				= 5
   1.419 +	};
   1.420 +
   1.421 +	enum Axes
   1.422 +	{
   1.423 +		AXIS_X			= 0,
   1.424 +		AXIS_Y			= 1,
   1.425 +		AXIS_Z			= 2
   1.426 +	};
   1.427 +
   1.428 +	enum Wrap
   1.429 +	{
   1.430 +		RESET			= 0,
   1.431 +		REPEAT			= 1,
   1.432 +		MIRROR			= 2,
   1.433 +		EDGE			= 3
   1.434 +	};
   1.435 +
   1.436 +	Texture()
   1.437 +		: mClipIdx(UINT_MAX)
   1.438 +		, mStrength			(1.0f)
   1.439 +		, mUVChannelIndex	("unknown")
   1.440 +		, mRealUVIndex		(UINT_MAX)
   1.441 +		, enabled			(true)
   1.442 +		, blendType			(Additive)
   1.443 +		, bCanUse			(true)
   1.444 +		, mapMode			(UV)
   1.445 +		, majorAxis			(AXIS_X)
   1.446 +		, wrapAmountH		(1.0f)
   1.447 +		, wrapAmountW		(1.0f)
   1.448 +		, wrapModeWidth		(REPEAT)
   1.449 +		, wrapModeHeight	(REPEAT)
   1.450 +		, ordinal			("\x00")
   1.451 +	{}
   1.452 +
   1.453 +	//! File name of the texture
   1.454 +	std::string mFileName;
   1.455 +
   1.456 +	//! Clip index
   1.457 +	unsigned int mClipIdx;
   1.458 +
   1.459 +	//! Strength of the texture - blend factor
   1.460 +	float mStrength;
   1.461 +
   1.462 +	uint32_t type; // type of the texture
   1.463 +
   1.464 +	//! Name of the corresponding UV channel
   1.465 +	std::string mUVChannelIndex;
   1.466 +	unsigned int mRealUVIndex;
   1.467 +
   1.468 +	//! is the texture enabled?
   1.469 +	bool enabled;
   1.470 +
   1.471 +	//! blend type
   1.472 +	BlendType blendType;
   1.473 +
   1.474 +	//! are we able to use the texture?
   1.475 +	bool bCanUse;
   1.476 +
   1.477 +	//! mapping mode
   1.478 +	MappingMode mapMode;
   1.479 +
   1.480 +	//! major axis for planar, cylindrical, spherical projections
   1.481 +	Axes majorAxis;
   1.482 +
   1.483 +	//! wrap amount for cylindrical and spherical projections
   1.484 +	float wrapAmountH,wrapAmountW;
   1.485 +
   1.486 +	//! wrapping mode for the texture
   1.487 +	Wrap wrapModeWidth,wrapModeHeight;
   1.488 +
   1.489 +	//! ordinal string of the texture
   1.490 +	std::string ordinal;
   1.491 +};
   1.492 +
   1.493 +// ---------------------------------------------------------------------------
   1.494 +/** \brief Data structure for a LWO file clip
   1.495 + */
   1.496 +struct Clip
   1.497 +{
   1.498 +	enum Type
   1.499 +	{
   1.500 +		 STILL, SEQ, REF, UNSUPPORTED
   1.501 +	} type;
   1.502 +
   1.503 +	Clip()
   1.504 +		: type	 (UNSUPPORTED)
   1.505 +		, idx	 (0)
   1.506 +		, negate (false)
   1.507 +	{}
   1.508 +
   1.509 +	//! path to the base texture -
   1.510 +	std::string path;
   1.511 +
   1.512 +	//! reference to another CLIP
   1.513 +	unsigned int clipRef;
   1.514 +
   1.515 +	//! index of the clip
   1.516 +	unsigned int idx;
   1.517 +
   1.518 +	//! Negate the clip?
   1.519 +	bool negate;
   1.520 +};
   1.521 +
   1.522 +
   1.523 +// ---------------------------------------------------------------------------
   1.524 +/** \brief Data structure for a LWO file shader
   1.525 + *
   1.526 + *  Later
   1.527 + */
   1.528 +struct Shader
   1.529 +{
   1.530 +	Shader()
   1.531 +		:	ordinal			("\x00")
   1.532 +		,	functionName	("unknown")
   1.533 +		,	enabled			(true)
   1.534 +	{}
   1.535 +
   1.536 +	std::string ordinal;
   1.537 +	std::string functionName;
   1.538 +	bool enabled;
   1.539 +};
   1.540 +
   1.541 +typedef std::list < Texture >		TextureList;
   1.542 +typedef std::list < Shader >		ShaderList;
   1.543 +
   1.544 +// ---------------------------------------------------------------------------
   1.545 +/** \brief Data structure for a LWO file surface (= material)
   1.546 + */
   1.547 +struct Surface
   1.548 +{
   1.549 +	Surface()
   1.550 +		: mColor				(0.78431f,0.78431f,0.78431f)
   1.551 +		, bDoubleSided			(false)
   1.552 +		, mDiffuseValue			(1.f)
   1.553 +		, mSpecularValue		(0.f)
   1.554 +		, mTransparency			(0.f)
   1.555 +		, mGlossiness			(0.4f)
   1.556 +		, mLuminosity			(0.f)
   1.557 +		, mColorHighlights		(0.f)
   1.558 +		, mMaximumSmoothAngle	(0.f) // 0 == not specified, no smoothing
   1.559 +		, mVCMap				("")
   1.560 +		, mVCMapType			(AI_LWO_RGBA)
   1.561 +		, mIOR					(1.f) // vakuum
   1.562 +		, mBumpIntensity		(1.f)
   1.563 +		, mWireframe			(false)
   1.564 +		, mAdditiveTransparency (0.f)
   1.565 +	{}
   1.566 +
   1.567 +	//! Name of the surface
   1.568 +	std::string mName;
   1.569 +
   1.570 +	//! Color of the surface
   1.571 +	aiColor3D mColor;
   1.572 +
   1.573 +	//! true for two-sided materials
   1.574 +	bool bDoubleSided;
   1.575 +
   1.576 +	//! Various material parameters
   1.577 +	float mDiffuseValue,mSpecularValue,mTransparency,mGlossiness,mLuminosity,mColorHighlights;
   1.578 +
   1.579 +	//! Maximum angle between two adjacent triangles
   1.580 +	//! that they can be smoothed - in degrees
   1.581 +	float mMaximumSmoothAngle;
   1.582 +
   1.583 +	//! Vertex color map to be used to color the surface
   1.584 +	std::string mVCMap;
   1.585 +	uint32_t mVCMapType;
   1.586 +
   1.587 +	//! Names of the special shaders to be applied to the surface
   1.588 +	ShaderList mShaders;
   1.589 +
   1.590 +	//! Textures - the first entry in the list is evaluated first
   1.591 +	TextureList mColorTextures, // color textures are added to both diffuse and specular texture stacks
   1.592 +		mDiffuseTextures,
   1.593 +		mSpecularTextures,
   1.594 +		mOpacityTextures,
   1.595 +		mBumpTextures,
   1.596 +		mGlossinessTextures,
   1.597 +		mReflectionTextures;
   1.598 +
   1.599 +	//! Index of refraction
   1.600 +	float mIOR;
   1.601 +
   1.602 +	//! Bump intensity scaling
   1.603 +	float mBumpIntensity;
   1.604 +
   1.605 +	//! Wireframe flag
   1.606 +	bool mWireframe;
   1.607 +
   1.608 +	//! Intensity of additive blending
   1.609 +	float mAdditiveTransparency;
   1.610 +};
   1.611 +
   1.612 +// ---------------------------------------------------------------------------
   1.613 +#define AI_LWO_VALIDATE_CHUNK_LENGTH(length,name,size) \
   1.614 +	if (length < size) \
   1.615 +	{ \
   1.616 +		throw DeadlyImportError("LWO: "#name" chunk is too small"); \
   1.617 +	} \
   1.618 +
   1.619 +
   1.620 +// some typedefs ... to make life with loader monsters like this easier
   1.621 +typedef std::vector	<	aiVector3D		>	PointList;
   1.622 +typedef std::vector	<	LWO::Face		>	FaceList;
   1.623 +typedef std::vector	<	LWO::Surface	>	SurfaceList;
   1.624 +typedef std::vector	<	std::string		>	TagList;
   1.625 +typedef std::vector	<	unsigned int	>	TagMappingTable;
   1.626 +typedef std::vector	<	unsigned int	>	ReferrerList;
   1.627 +typedef std::vector	<	WeightChannel	>	WeightChannelList;
   1.628 +typedef std::vector	<	VColorChannel	>	VColorChannelList;
   1.629 +typedef std::vector	<	UVChannel		>	UVChannelList;
   1.630 +typedef std::vector	<	Clip			>	ClipList;
   1.631 +typedef std::vector	<	Envelope		>	EnvelopeList;
   1.632 +typedef std::vector <   unsigned int    >   SortedRep;
   1.633 +
   1.634 +// ---------------------------------------------------------------------------
   1.635 +/** \brief Represents a layer in the file
   1.636 + */
   1.637 +struct Layer
   1.638 +{
   1.639 +	Layer()
   1.640 +		: mFaceIDXOfs	(0)
   1.641 +		, mPointIDXOfs	(0)
   1.642 +		, mParent		(0x0)
   1.643 +		, mIndex		(0xffff)
   1.644 +		, skip			(false)
   1.645 +	{}
   1.646 +
   1.647 +	/** Temporary point list from the file */
   1.648 +	PointList mTempPoints;
   1.649 +
   1.650 +	/** Lists for every point the index of another point
   1.651 +	    that has been copied from *this* point or UINT_MAX if
   1.652 +		no copy of the point has been made */
   1.653 +	ReferrerList mPointReferrers;
   1.654 +
   1.655 +	/** Weight channel list from the file */
   1.656 +	WeightChannelList mWeightChannels;
   1.657 +
   1.658 +	/** Subdivision weight channel list from the file */
   1.659 +	WeightChannelList mSWeightChannels;
   1.660 +
   1.661 +	/** Vertex color list from the file */
   1.662 +	VColorChannelList mVColorChannels;
   1.663 +
   1.664 +	/** UV channel list from the file */
   1.665 +	UVChannelList mUVChannels;
   1.666 +
   1.667 +	/** Normal vector channel from the file */
   1.668 +	NormalChannel mNormals;
   1.669 +
   1.670 +	/** Temporary face list from the file*/
   1.671 +	FaceList mFaces;
   1.672 +
   1.673 +	/** Current face indexing offset from the beginning of the buffers*/
   1.674 +	unsigned int mFaceIDXOfs;
   1.675 +
   1.676 +	/** Current point indexing offset from the beginning of the buffers*/
   1.677 +	unsigned int mPointIDXOfs;
   1.678 +
   1.679 +	/** Parent index */
   1.680 +	uint16_t mParent;
   1.681 +
   1.682 +	/** Index of the layer */
   1.683 +	uint16_t mIndex;
   1.684 +
   1.685 +	/** Name of the layer */
   1.686 +	std::string mName;
   1.687 +
   1.688 +	/** Pivot point of the layer */
   1.689 +	aiVector3D mPivot;
   1.690 +
   1.691 +	/** Skip this layer? */
   1.692 +	bool skip;
   1.693 +};
   1.694 +
   1.695 +typedef std::list<LWO::Layer>		LayerList;
   1.696 +
   1.697 +
   1.698 +}}
   1.699 +
   1.700 +
   1.701 +#endif // !! AI_LWO_FILEDATA_INCLUDED
   1.702 +