Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /* |
---|---|
2 | Open Asset Import Library (assimp) |
3 | ---------------------------------------------------------------------- |
4 | |
5 | Copyright (c) 2006-2017, assimp team |
6 | |
7 | All rights reserved. |
8 | |
9 | Redistribution and use of this software in source and binary forms, |
10 | with or without modification, are permitted provided that the |
11 | following 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 | |
27 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
28 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
29 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
30 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
31 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
32 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
34 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
35 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
36 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
37 | OF 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 | |
48 | namespace Assimp { |
49 | namespace Q3BSP { |
50 | |
51 | static const unsigned int CE_BSP_LIGHTMAPWIDTH = 128; |
52 | static const unsigned int CE_BSP_LIGHTMAPHEIGHT = 128; |
53 | |
54 | static const unsigned int CE_BSP_LIGHTMAPSIZE = 128*128*3; ///< = 128( width ) * 128 ( height ) * 3 ( channels / RGB ). |
55 | static const int VERION_Q3LEVEL = 46; ///< Supported version. |
56 | |
57 | /// Geometric type enumeration |
58 | enum Q3BSPGeoType { |
59 | Polygon = 1, |
60 | Patch, |
61 | TriangleMesh, |
62 | Billboard |
63 | }; |
64 | |
65 | /// Integer vector. |
66 | struct 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 |
73 | struct sQ3BSPHeader { |
74 | char strID[ 4 ]; ///< Should be "IBSP" |
75 | int iVersion; ///< 46 for standard levels |
76 | }; |
77 | |
78 | /// Describes an entry. |
79 | struct sQ3BSPLump |
80 | { |
81 | int iOffset; ///< Offset from start pointer of file |
82 | int iSize; ///< Size of part |
83 | }; |
84 | |
85 | struct vec2f |
86 | { |
87 | float x,y; |
88 | }; |
89 | |
90 | struct vec3f |
91 | { |
92 | float x, y, z; |
93 | }; |
94 | |
95 | /// Vertex of a Q3 level |
96 | struct 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 |
106 | struct 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. |
125 | struct 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. |
132 | struct sQ3BSPLightmap { |
133 | unsigned char bLMapData[ CE_BSP_LIGHTMAPSIZE ]; |
134 | sQ3BSPLightmap() { |
135 | ::memset(bLMapData, 0, CE_BSP_LIGHTMAPSIZE ); |
136 | } |
137 | }; |
138 | |
139 | struct SubPatch { |
140 | std::vector<size_t> indices; |
141 | int lightmapID; |
142 | }; |
143 | |
144 | enum 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 | |
165 | struct 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.