Warning: That file was not part of the compilation database. It may have many parsing errors.

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

Warning: That file was not part of the compilation database. It may have many parsing errors.