vrshoot

diff libs/assimp/Q3BSPFileData.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/Q3BSPFileData.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,228 @@
     1.4 +/*
     1.5 +Open Asset Import Library (assimp)
     1.6 +----------------------------------------------------------------------
     1.7 +
     1.8 +Copyright (c) 2006-2008, 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 +#ifndef ASSIMP_Q3BSPFILEDATA_H_INC
    1.44 +#define ASSIMP_Q3BSPFILEDATA_H_INC
    1.45 +
    1.46 +#include <vector>
    1.47 +
    1.48 +namespace Assimp
    1.49 +{
    1.50 +namespace Q3BSP
    1.51 +{
    1.52 +
    1.53 +static const unsigned int CE_BSP_LIGHTMAPWIDTH = 128;
    1.54 +static const unsigned int CE_BSP_LIGHTMAPHEIGHT = 128;
    1.55 +
    1.56 +static const unsigned int CE_BSP_LIGHTMAPSIZE = 128*128*3;	///< = 128( width ) * 128 ( height ) * 3 ( channels / RGB ).
    1.57 +static const int VERION_Q3LEVEL = 46;						///< Supported version.
    1.58 +
    1.59 +///	Geometric type enumeration
    1.60 +enum Q3BSPGeoType
    1.61 +{
    1.62 +	Polygon = 1,
    1.63 +	Patch, 
    1.64 +	TriangleMesh,
    1.65 +	Billboard 
    1.66 +};
    1.67 +
    1.68 +///	Integer vector.
    1.69 +struct ceVec3i 
    1.70 +{
    1.71 +    int x, y, z;
    1.72 +	ceVec3i(): x( 0 ), y( 0 ), z( 0 ) { /* empty */ }
    1.73 +	ceVec3i( int iX, int iY=0, int iZ=0) : x( iX ), y( iY ), z( iZ ) { /* empty */ }
    1.74 +};
    1.75 +
    1.76 +///	Fileheader
    1.77 +struct sQ3BSPHeader 
    1.78 +{
    1.79 +	char strID[ 4 ];	//!< Should be "IBSP"
    1.80 +	int iVersion;	//!< 46 for standard levels
    1.81 +};
    1.82 +
    1.83 +///	Descripes an entry.
    1.84 +struct sQ3BSPLump 
    1.85 +{
    1.86 +	int iOffset;	///< Offset from startpointer of file
    1.87 +	int iSize;		///< Size fo part
    1.88 +};
    1.89 +
    1.90 +struct vec2f
    1.91 +{
    1.92 +	float x,y;
    1.93 +};
    1.94 +
    1.95 +struct vec3f
    1.96 +{
    1.97 +	float x, y, z;
    1.98 +};
    1.99 +
   1.100 +///	Vertex of a Q3 level
   1.101 +struct sQ3BSPVertex 
   1.102 +{
   1.103 +	vec3f vPosition;	///< Position of vertex
   1.104 +	vec2f vTexCoord;	///< (u,v) Texturecoordinate of detailtexture
   1.105 +	vec2f vLightmap;	///< (u,v) Texturecoordinate of lightmap
   1.106 +	vec3f vNormal;		///< vertex normale
   1.107 +	unsigned char bColor[ 4 ];			///< Color in RGBA
   1.108 +};
   1.109 +
   1.110 +///	A face in bsp format info
   1.111 +struct sQ3BSPFace 
   1.112 +{
   1.113 +	int iTextureID;					///< Index in texture array
   1.114 +	int iEffect;					///< Index in effectarray (-1 = no effect)
   1.115 +	int iType;						///< 1=Polygon, 2=Patch, 3=Mesh, 4=Billboard
   1.116 +	int iVertexIndex;				///< Start index of polygon
   1.117 +	int iNumOfVerts;				///< Number of vertices
   1.118 +	int	iFaceVertexIndex;			///< Index of first mesh vertex
   1.119 +	int iNumOfFaceVerts;			///< Anzahl der Meshvertices
   1.120 +	int iLightmapID;				///< Index to the lightmap array
   1.121 +	int iLMapCorner[ 2 ];			///< Die Ecke der Lightmap in der Textur
   1.122 +	int iLMapSize[ 2 ];				///< Size of the lightmap stored on the texture
   1.123 +	vec3f vLMapPos;					///< 3D-Ursprung der Lightmap
   1.124 +	vec3f vLMapVecs[ 2 ];			///< 3D-s-t-Vektoren
   1.125 +	vec3f vNormal;					///< Polygonnormale
   1.126 +	int patchWidth, patchHeight;	///< bezier patch
   1.127 +};
   1.128 +
   1.129 +/// A quake3 texture name.
   1.130 +struct sQ3BSPTexture 
   1.131 +{
   1.132 +	char strName[ 64 ];		///< Name of the texture without extention
   1.133 +	int iFlags;				///< Not used
   1.134 +	int iContents;			///< Not used
   1.135 +};
   1.136 +
   1.137 +///	A lightmap of the level, size 128 x 128, RGB components.
   1.138 +struct sQ3BSPLightmap 
   1.139 +{
   1.140 +	unsigned char bLMapData[ CE_BSP_LIGHTMAPSIZE ];
   1.141 +	sQ3BSPLightmap() 
   1.142 +	{	
   1.143 +		memset(bLMapData, 0, CE_BSP_LIGHTMAPSIZE ); 
   1.144 +	}
   1.145 +};
   1.146 +
   1.147 +struct SubPatch
   1.148 +{
   1.149 +	std::vector<size_t> indices;
   1.150 +	int lightmapID;
   1.151 +};
   1.152 +
   1.153 +enum eLumps 
   1.154 +{
   1.155 +	kEntities = 0,
   1.156 +	kTextures,
   1.157 +	kPlanes,
   1.158 +	kNodes,
   1.159 +	kLeafs,
   1.160 +	kLeafFaces,
   1.161 +	kLeafBrushes,
   1.162 +	kModels,
   1.163 +	kBrushes,
   1.164 +	kBrushSides,
   1.165 +	kVertices,
   1.166 +	kMeshVerts,
   1.167 +	kShaders,
   1.168 +	kFaces,
   1.169 +	kLightmaps,
   1.170 +	kLightVolumes,
   1.171 +	kVisData,
   1.172 +	kMaxLumps
   1.173 +};
   1.174 +
   1.175 +struct Q3BSPModel
   1.176 +{
   1.177 +	std::vector<unsigned char> m_Data;
   1.178 +	std::vector<sQ3BSPLump*> m_Lumps;
   1.179 +	std::vector<sQ3BSPVertex*> m_Vertices;
   1.180 +	std::vector<sQ3BSPFace*> m_Faces;
   1.181 +	std::vector<int> m_Indices;
   1.182 +	std::vector<sQ3BSPTexture*> m_Textures;
   1.183 +	std::vector<sQ3BSPLightmap*> m_Lightmaps;
   1.184 +	std::vector<char> m_EntityData;
   1.185 +	std::string m_ModelName;
   1.186 +
   1.187 +	Q3BSPModel() :
   1.188 +		m_Data(),
   1.189 +		m_Lumps(),
   1.190 +		m_Vertices(),
   1.191 +		m_Faces(),
   1.192 +		m_Indices(),
   1.193 +		m_Textures(),
   1.194 +		m_Lightmaps(),
   1.195 +		m_EntityData(),
   1.196 +		m_ModelName( "" )
   1.197 +	{
   1.198 +		// empty
   1.199 +	}
   1.200 +
   1.201 +	~Q3BSPModel()
   1.202 +	{
   1.203 +		for ( unsigned int i=0; i<m_Lumps.size(); i++ )
   1.204 +			if ( NULL != m_Lumps[i] )
   1.205 +				delete m_Lumps[i];
   1.206 +		
   1.207 +		for ( unsigned int i=0; i<m_Vertices.size(); i++ )
   1.208 +			if ( NULL != m_Vertices[ i ] )
   1.209 +				delete m_Vertices[ i ];
   1.210 +		for ( unsigned int i=0; i<m_Faces.size(); i++ )
   1.211 +			if ( NULL != m_Faces[ i ] )
   1.212 +				delete m_Faces[ i ];
   1.213 +		for ( unsigned int i=0; i<m_Textures.size(); i++ )
   1.214 +			if ( NULL != m_Textures[ i ] )
   1.215 +				delete m_Textures[ i ];
   1.216 +		for ( unsigned int i=0; i<m_Lightmaps.size(); i++ )
   1.217 +			if ( NULL != m_Lightmaps[ i ] )
   1.218 +				delete m_Lightmaps[ i ];
   1.219 +
   1.220 +		m_Lumps.clear();
   1.221 +		m_Vertices.clear();
   1.222 +		m_Faces.clear();
   1.223 +		m_Textures.clear();
   1.224 +		m_Lightmaps.clear();
   1.225 +	}
   1.226 +};
   1.227 +
   1.228 +} // Namespace Q3BSP
   1.229 +} // Namespace Assimp
   1.230 +
   1.231 +#endif // ASSIMP_Q3BSPFILEDATA_H_INC