q3files.h (8660B)
1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 5 This file is part of Quake III Arena source code. 6 7 Quake III Arena source code is free software; you can redistribute it 8 and/or modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the License, 10 or (at your option) any later version. 11 12 Quake III Arena source code is distributed in the hope that it will be 13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Foobar; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 =========================================================================== 21 */ 22 #ifndef __QFILES_H__ 23 #define __QFILES_H__ 24 25 // 26 // qfiles.h: quake file formats 27 // This file must be identical in the quake and utils directories 28 // 29 30 // surface geometry should not exceed these limits 31 #define SHADER_MAX_VERTEXES 1000 32 #define SHADER_MAX_INDEXES (6*SHADER_MAX_VERTEXES) 33 34 35 // the maximum size of game reletive pathnames 36 #define MAX_QPATH 64 37 38 39 /* 40 ======================================================================== 41 42 PCX files are used for 8 bit images 43 44 ======================================================================== 45 * 46 47 typedef struct { 48 char manufacturer; 49 char version; 50 char encoding; 51 char bits_per_pixel; 52 unsigned short xmin,ymin,xmax,ymax; 53 unsigned short hres,vres; 54 unsigned char palette[48]; 55 char reserved; 56 char color_planes; 57 unsigned short bytes_per_line; 58 unsigned short palette_type; 59 char filler[58]; 60 unsigned char data; // unbounded 61 } pcx_t; 62 63 64 /* 65 ======================================================================== 66 67 TGA files are used for 24/32 bit images 68 69 ======================================================================== 70 * 71 72 typedef struct _TargaHeader { 73 unsigned char id_length, colormap_type, image_type; 74 unsigned short colormap_index, colormap_length; 75 unsigned char colormap_size; 76 unsigned short x_origin, y_origin, width, height; 77 unsigned char pixel_size, attributes; 78 } TargaHeader; 79 80 81 */ 82 83 /* 84 ======================================================================== 85 86 .MD3 triangle model file format 87 88 ======================================================================== 89 */ 90 91 #define MD3_IDENT (('3'<<24)+('P'<<16)+('D'<<8)+'I') 92 #define MD3_VERSION 15 93 94 // limits 95 #define MD3_MAX_LODS 4 96 #define MD3_MAX_TRIANGLES 8192 // per surface 97 #define MD3_MAX_VERTS 4096 // per surface 98 #define MD3_MAX_SHADERS 256 // per surface 99 #define MD3_MAX_FRAMES 1024 // per model 100 #define MD3_MAX_SURFACES 32 // per model 101 #define MD3_MAX_TAGS 16 // per frame 102 103 // vertex scales 104 #define MD3_XYZ_SCALE (1.0/64) 105 106 typedef struct md3Frame_s { 107 vec3_t bounds[2]; 108 vec3_t localOrigin; 109 float radius; 110 char name[16]; 111 } md3Frame_t; 112 113 typedef struct md3Tag_s { 114 char name[MAX_QPATH]; // tag name 115 vec3_t origin; 116 vec3_t axis[3]; 117 } md3Tag_t; 118 119 /* 120 ** md3Surface_t 121 ** 122 ** CHUNK SIZE 123 ** header sizeof( md3Surface_t ) 124 ** shaders sizeof( md3Shader_t ) * numShaders 125 ** triangles[0] sizeof( md3Triangle_t ) * numTriangles 126 ** st sizeof( md3St_t ) * numVerts 127 ** XyzNormals sizeof( md3XyzNormal_t ) * numVerts * numFrames 128 */ 129 130 typedef struct { 131 int ident; // 132 133 char name[MAX_QPATH]; // polyset name 134 135 int flags; 136 int numFrames; // all surfaces in a model should have the same 137 138 int numShaders; // all surfaces in a model should have the same 139 int numVerts; 140 141 int numTriangles; 142 int ofsTriangles; 143 144 int ofsShaders; // offset from start of md3Surface_t 145 int ofsSt; // texture coords are common for all frames 146 int ofsXyzNormals; // numVerts * numFrames 147 148 int ofsEnd; // next surface follows 149 } md3Surface_t; 150 151 typedef struct { 152 char name[MAX_QPATH]; 153 int shaderIndex; // for in-game use 154 } md3Shader_t; 155 156 typedef struct { 157 int indexes[3]; 158 } md3Triangle_t; 159 160 typedef struct { 161 float st[2]; 162 } md3St_t; 163 164 typedef struct { 165 short xyz[3]; 166 short normal; 167 } md3XyzNormal_t; 168 169 typedef struct { 170 int ident; 171 int version; 172 173 char name[MAX_QPATH]; // model name 174 175 int flags; 176 177 int numFrames; 178 int numTags; 179 int numSurfaces; 180 181 int numSkins; 182 183 int ofsFrames; // offset for first frame 184 int ofsTags; // numFrames * numTags 185 int ofsSurfaces; // first surface, others follow 186 187 int ofsEnd; // end of file 188 } md3Header_t; 189 190 191 192 /* 193 ============================================================================== 194 195 .BSP file format 196 197 ============================================================================== 198 */ 199 200 201 #define Q3_BSP_IDENT (('P'<<24)+('S'<<16)+('B'<<8)+'I') 202 // little-endian "IBSP" 203 204 #define Q3_BSP_VERSION 46 205 206 207 // there shouldn't be any problem with increasing these values at the 208 // expense of more memory allocation in the utilities 209 #define Q3_MAX_MAP_MODELS 0x400 210 #define Q3_MAX_MAP_BRUSHES 0x8000 211 #define Q3_MAX_MAP_ENTITIES 0x800 212 #define Q3_MAX_MAP_ENTSTRING 0x10000 213 #define Q3_MAX_MAP_SHADERS 0x400 214 215 #define Q3_MAX_MAP_AREAS 0x100 // MAX_MAP_AREA_BYTES in q_shared must match! 216 #define Q3_MAX_MAP_FOGS 0x100 217 #define Q3_MAX_MAP_PLANES 0x10000 218 #define Q3_MAX_MAP_NODES 0x10000 219 #define Q3_MAX_MAP_BRUSHSIDES 0x10000 220 #define Q3_MAX_MAP_LEAFS 0x10000 221 #define Q3_MAX_MAP_LEAFFACES 0x10000 222 #define Q3_MAX_MAP_LEAFBRUSHES 0x10000 223 #define Q3_MAX_MAP_PORTALS 0x10000 224 #define Q3_MAX_MAP_LIGHTING 0x400000 225 #define Q3_MAX_MAP_LIGHTGRID 0x400000 226 #define Q3_MAX_MAP_VISIBILITY 0x200000 227 228 #define Q3_MAX_MAP_DRAW_SURFS 0x20000 229 #define Q3_MAX_MAP_DRAW_VERTS 0x80000 230 #define Q3_MAX_MAP_DRAW_INDEXES 0x80000 231 232 233 // key / value pair sizes in the entities lump 234 #define Q3_MAX_KEY 32 235 #define Q3_MAX_VALUE 1024 236 237 // the editor uses these predefined yaw angles to orient entities up or down 238 #define ANGLE_UP -1 239 #define ANGLE_DOWN -2 240 241 #define LIGHTMAP_WIDTH 128 242 #define LIGHTMAP_HEIGHT 128 243 244 245 //============================================================================= 246 247 248 typedef struct { 249 int fileofs, filelen; 250 } q3_lump_t; 251 252 #define Q3_LUMP_ENTITIES 0 253 #define Q3_LUMP_SHADERS 1 254 #define Q3_LUMP_PLANES 2 255 #define Q3_LUMP_NODES 3 256 #define Q3_LUMP_LEAFS 4 257 #define Q3_LUMP_LEAFSURFACES 5 258 #define Q3_LUMP_LEAFBRUSHES 6 259 #define Q3_LUMP_MODELS 7 260 #define Q3_LUMP_BRUSHES 8 261 #define Q3_LUMP_BRUSHSIDES 9 262 #define Q3_LUMP_DRAWVERTS 10 263 #define Q3_LUMP_DRAWINDEXES 11 264 #define Q3_LUMP_FOGS 12 265 #define Q3_LUMP_SURFACES 13 266 #define Q3_LUMP_LIGHTMAPS 14 267 #define Q3_LUMP_LIGHTGRID 15 268 #define Q3_LUMP_VISIBILITY 16 269 #define Q3_HEADER_LUMPS 17 270 271 typedef struct { 272 int ident; 273 int version; 274 275 q3_lump_t lumps[Q3_HEADER_LUMPS]; 276 } q3_dheader_t; 277 278 typedef struct { 279 float mins[3], maxs[3]; 280 int firstSurface, numSurfaces; 281 int firstBrush, numBrushes; 282 } q3_dmodel_t; 283 284 typedef struct { 285 char shader[MAX_QPATH]; 286 int surfaceFlags; 287 int contentFlags; 288 } q3_dshader_t; 289 290 // planes (x&~1) and (x&~1)+1 are allways opposites 291 292 typedef struct { 293 float normal[3]; 294 float dist; 295 } q3_dplane_t; 296 297 typedef struct { 298 int planeNum; 299 int children[2]; // negative numbers are -(leafs+1), not nodes 300 int mins[3]; // for frustom culling 301 int maxs[3]; 302 } q3_dnode_t; 303 304 typedef struct { 305 int cluster; // -1 = opaque cluster (do I still store these?) 306 int area; 307 308 int mins[3]; // for frustum culling 309 int maxs[3]; 310 311 int firstLeafSurface; 312 int numLeafSurfaces; 313 314 int firstLeafBrush; 315 int numLeafBrushes; 316 } q3_dleaf_t; 317 318 typedef struct { 319 int planeNum; // positive plane side faces out of the leaf 320 int shaderNum; 321 } q3_dbrushside_t; 322 323 typedef struct { 324 int firstSide; 325 int numSides; 326 int shaderNum; // the shader that determines the contents flags 327 } q3_dbrush_t; 328 329 typedef struct { 330 char shader[MAX_QPATH]; 331 int brushNum; 332 int visibleSide; // the brush side that ray tests need to clip against (-1 == none) 333 } q3_dfog_t; 334 335 typedef struct { 336 vec3_t xyz; 337 float st[2]; 338 float lightmap[2]; 339 vec3_t normal; 340 byte color[4]; 341 } q3_drawVert_t; 342 343 typedef enum { 344 MST_BAD, 345 MST_PLANAR, 346 MST_PATCH, 347 MST_TRIANGLE_SOUP, 348 MST_FLARE 349 } q3_mapSurfaceType_t; 350 351 typedef struct { 352 int shaderNum; 353 int fogNum; 354 int surfaceType; 355 356 int firstVert; 357 int numVerts; 358 359 int firstIndex; 360 int numIndexes; 361 362 int lightmapNum; 363 int lightmapX, lightmapY; 364 int lightmapWidth, lightmapHeight; 365 366 vec3_t lightmapOrigin; 367 vec3_t lightmapVecs[3]; // for patches, [0] and [1] are lodbounds 368 369 int patchWidth; 370 int patchHeight; 371 } q3_dsurface_t; 372 373 374 #endif