vrshoot

view 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 source
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
5 Copyright (c) 2006-2008, assimp team
6 All rights reserved.
8 Redistribution and use of this software in source and binary forms,
9 with or without modification, are permitted provided that the
10 following conditions are met:
12 * Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the
14 following disclaimer.
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the
18 following disclaimer in the documentation and/or other
19 materials provided with the distribution.
21 * Neither the name of the assimp team, nor the names of its
22 contributors may be used to endorse or promote products
23 derived from this software without specific prior
24 written permission of the assimp team.
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 ----------------------------------------------------------------------
39 */
40 #ifndef ASSIMP_Q3BSPFILEDATA_H_INC
41 #define ASSIMP_Q3BSPFILEDATA_H_INC
43 #include <vector>
45 namespace Assimp
46 {
47 namespace Q3BSP
48 {
50 static const unsigned int CE_BSP_LIGHTMAPWIDTH = 128;
51 static const unsigned int CE_BSP_LIGHTMAPHEIGHT = 128;
53 static const unsigned int CE_BSP_LIGHTMAPSIZE = 128*128*3; ///< = 128( width ) * 128 ( height ) * 3 ( channels / RGB ).
54 static const int VERION_Q3LEVEL = 46; ///< Supported version.
56 /// Geometric type enumeration
57 enum Q3BSPGeoType
58 {
59 Polygon = 1,
60 Patch,
61 TriangleMesh,
62 Billboard
63 };
65 /// Integer vector.
66 struct ceVec3i
67 {
68 int x, y, z;
69 ceVec3i(): x( 0 ), y( 0 ), z( 0 ) { /* empty */ }
70 ceVec3i( int iX, int iY=0, int iZ=0) : x( iX ), y( iY ), z( iZ ) { /* empty */ }
71 };
73 /// Fileheader
74 struct sQ3BSPHeader
75 {
76 char strID[ 4 ]; //!< Should be "IBSP"
77 int iVersion; //!< 46 for standard levels
78 };
80 /// Descripes an entry.
81 struct sQ3BSPLump
82 {
83 int iOffset; ///< Offset from startpointer of file
84 int iSize; ///< Size fo part
85 };
87 struct vec2f
88 {
89 float x,y;
90 };
92 struct vec3f
93 {
94 float x, y, z;
95 };
97 /// Vertex of a Q3 level
98 struct sQ3BSPVertex
99 {
100 vec3f vPosition; ///< Position of vertex
101 vec2f vTexCoord; ///< (u,v) Texturecoordinate of detailtexture
102 vec2f vLightmap; ///< (u,v) Texturecoordinate of lightmap
103 vec3f vNormal; ///< vertex normale
104 unsigned char bColor[ 4 ]; ///< Color in RGBA
105 };
107 /// A face in bsp format info
108 struct sQ3BSPFace
109 {
110 int iTextureID; ///< Index in texture array
111 int iEffect; ///< Index in effectarray (-1 = no effect)
112 int iType; ///< 1=Polygon, 2=Patch, 3=Mesh, 4=Billboard
113 int iVertexIndex; ///< Start index of polygon
114 int iNumOfVerts; ///< Number of vertices
115 int iFaceVertexIndex; ///< Index of first mesh vertex
116 int iNumOfFaceVerts; ///< Anzahl der Meshvertices
117 int iLightmapID; ///< Index to the lightmap array
118 int iLMapCorner[ 2 ]; ///< Die Ecke der Lightmap in der Textur
119 int iLMapSize[ 2 ]; ///< Size of the lightmap stored on the texture
120 vec3f vLMapPos; ///< 3D-Ursprung der Lightmap
121 vec3f vLMapVecs[ 2 ]; ///< 3D-s-t-Vektoren
122 vec3f vNormal; ///< Polygonnormale
123 int patchWidth, patchHeight; ///< bezier patch
124 };
126 /// A quake3 texture name.
127 struct sQ3BSPTexture
128 {
129 char strName[ 64 ]; ///< Name of the texture without extention
130 int iFlags; ///< Not used
131 int iContents; ///< Not used
132 };
134 /// A lightmap of the level, size 128 x 128, RGB components.
135 struct sQ3BSPLightmap
136 {
137 unsigned char bLMapData[ CE_BSP_LIGHTMAPSIZE ];
138 sQ3BSPLightmap()
139 {
140 memset(bLMapData, 0, CE_BSP_LIGHTMAPSIZE );
141 }
142 };
144 struct SubPatch
145 {
146 std::vector<size_t> indices;
147 int lightmapID;
148 };
150 enum eLumps
151 {
152 kEntities = 0,
153 kTextures,
154 kPlanes,
155 kNodes,
156 kLeafs,
157 kLeafFaces,
158 kLeafBrushes,
159 kModels,
160 kBrushes,
161 kBrushSides,
162 kVertices,
163 kMeshVerts,
164 kShaders,
165 kFaces,
166 kLightmaps,
167 kLightVolumes,
168 kVisData,
169 kMaxLumps
170 };
172 struct Q3BSPModel
173 {
174 std::vector<unsigned char> m_Data;
175 std::vector<sQ3BSPLump*> m_Lumps;
176 std::vector<sQ3BSPVertex*> m_Vertices;
177 std::vector<sQ3BSPFace*> m_Faces;
178 std::vector<int> m_Indices;
179 std::vector<sQ3BSPTexture*> m_Textures;
180 std::vector<sQ3BSPLightmap*> m_Lightmaps;
181 std::vector<char> m_EntityData;
182 std::string m_ModelName;
184 Q3BSPModel() :
185 m_Data(),
186 m_Lumps(),
187 m_Vertices(),
188 m_Faces(),
189 m_Indices(),
190 m_Textures(),
191 m_Lightmaps(),
192 m_EntityData(),
193 m_ModelName( "" )
194 {
195 // empty
196 }
198 ~Q3BSPModel()
199 {
200 for ( unsigned int i=0; i<m_Lumps.size(); i++ )
201 if ( NULL != m_Lumps[i] )
202 delete m_Lumps[i];
204 for ( unsigned int i=0; i<m_Vertices.size(); i++ )
205 if ( NULL != m_Vertices[ i ] )
206 delete m_Vertices[ i ];
207 for ( unsigned int i=0; i<m_Faces.size(); i++ )
208 if ( NULL != m_Faces[ i ] )
209 delete m_Faces[ i ];
210 for ( unsigned int i=0; i<m_Textures.size(); i++ )
211 if ( NULL != m_Textures[ i ] )
212 delete m_Textures[ i ];
213 for ( unsigned int i=0; i<m_Lightmaps.size(); i++ )
214 if ( NULL != m_Lightmaps[ i ] )
215 delete m_Lightmaps[ i ];
217 m_Lumps.clear();
218 m_Vertices.clear();
219 m_Faces.clear();
220 m_Textures.clear();
221 m_Lightmaps.clear();
222 }
223 };
225 } // Namespace Q3BSP
226 } // Namespace Assimp
228 #endif // ASSIMP_Q3BSPFILEDATA_H_INC