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