qfiles.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. /*
  2. Copyright (C) 1997-2001 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. //
  16. // qfiles.h: quake file formats
  17. // This file must be identical in the quake and utils directories
  18. //
  19. /*
  20. ========================================================================
  21. The .pak files are just a linear collapse of a directory tree
  22. ========================================================================
  23. */
  24. #define IDPAKHEADER (('K'<<24)+('C'<<16)+('A'<<8)+'P')
  25. typedef struct
  26. {
  27. char name[56];
  28. int filepos, filelen;
  29. } dpackfile_t;
  30. typedef struct
  31. {
  32. int ident; // == IDPAKHEADER
  33. int dirofs;
  34. int dirlen;
  35. } dpackheader_t;
  36. #define MAX_FILES_IN_PACK 4096
  37. /*
  38. ========================================================================
  39. PCX files are used for as many images as possible
  40. ========================================================================
  41. */
  42. typedef struct
  43. {
  44. char manufacturer;
  45. char version;
  46. char encoding;
  47. char bits_per_pixel;
  48. unsigned short xmin,ymin,xmax,ymax;
  49. unsigned short hres,vres;
  50. unsigned char palette[48];
  51. char reserved;
  52. char color_planes;
  53. unsigned short bytes_per_line;
  54. unsigned short palette_type;
  55. char filler[58];
  56. unsigned char data; // unbounded
  57. } pcx_t;
  58. /*
  59. ========================================================================
  60. .MD2 triangle model file format
  61. ========================================================================
  62. */
  63. #define IDALIASHEADER (('2'<<24)+('P'<<16)+('D'<<8)+'I')
  64. #define ALIAS_VERSION 8
  65. #define MAX_TRIANGLES 4096
  66. #define MAX_VERTS 2048
  67. #define MAX_FRAMES 512
  68. #define MAX_MD2SKINS 32
  69. #define MAX_SKINNAME 64
  70. typedef struct
  71. {
  72. short s;
  73. short t;
  74. } dstvert_t;
  75. typedef struct
  76. {
  77. short index_xyz[3];
  78. short index_st[3];
  79. } dtriangle_t;
  80. typedef struct
  81. {
  82. byte v[3]; // scaled byte to fit in frame mins/maxs
  83. byte lightnormalindex;
  84. } dtrivertx_t;
  85. #define DTRIVERTX_V0 0
  86. #define DTRIVERTX_V1 1
  87. #define DTRIVERTX_V2 2
  88. #define DTRIVERTX_LNI 3
  89. #define DTRIVERTX_SIZE 4
  90. typedef struct
  91. {
  92. float scale[3]; // multiply byte verts by this
  93. float translate[3]; // then add this
  94. char name[16]; // frame name from grabbing
  95. dtrivertx_t verts[1]; // variable sized
  96. } daliasframe_t;
  97. // the glcmd format:
  98. // a positive integer starts a tristrip command, followed by that many
  99. // vertex structures.
  100. // a negative integer starts a trifan command, followed by -x vertexes
  101. // a zero indicates the end of the command list.
  102. // a vertex consists of a floating point s, a floating point t,
  103. // and an integer vertex index.
  104. typedef struct
  105. {
  106. int ident;
  107. int version;
  108. int skinwidth;
  109. int skinheight;
  110. int framesize; // byte size of each frame
  111. int num_skins;
  112. int num_xyz;
  113. int num_st; // greater than num_xyz for seams
  114. int num_tris;
  115. int num_glcmds; // dwords in strip/fan command list
  116. int num_frames;
  117. int ofs_skins; // each skin is a MAX_SKINNAME string
  118. int ofs_st; // byte offset from start for stverts
  119. int ofs_tris; // offset for dtriangles
  120. int ofs_frames; // offset for first frame
  121. int ofs_glcmds;
  122. int ofs_end; // end of file
  123. } dmdl_t;
  124. /*
  125. ========================================================================
  126. .SP2 sprite file format
  127. ========================================================================
  128. */
  129. #define IDSPRITEHEADER (('2'<<24)+('S'<<16)+('D'<<8)+'I')
  130. // little-endian "IDS2"
  131. #define SPRITE_VERSION 2
  132. typedef struct
  133. {
  134. int width, height;
  135. int origin_x, origin_y; // raster coordinates inside pic
  136. char name[MAX_SKINNAME]; // name of pcx file
  137. } dsprframe_t;
  138. typedef struct {
  139. int ident;
  140. int version;
  141. int numframes;
  142. dsprframe_t frames[1]; // variable sized
  143. } dsprite_t;
  144. /*
  145. ==============================================================================
  146. .WAL texture file format
  147. ==============================================================================
  148. */
  149. #define MIPLEVELS 4
  150. typedef struct miptex_s
  151. {
  152. char name[32];
  153. unsigned width, height;
  154. unsigned offsets[MIPLEVELS]; // four mip maps stored
  155. char animname[32]; // next frame in animation chain
  156. int flags;
  157. int contents;
  158. int value;
  159. } miptex_t;
  160. /*
  161. ==============================================================================
  162. .BSP file format
  163. ==============================================================================
  164. */
  165. #define IDBSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I')
  166. // little-endian "IBSP"
  167. #define BSPVERSION 38
  168. // upper design bounds
  169. // leaffaces, leafbrushes, planes, and verts are still bounded by
  170. // 16 bit short limits
  171. #define MAX_MAP_MODELS 1024
  172. #define MAX_MAP_BRUSHES 8192
  173. #define MAX_MAP_ENTITIES 2048
  174. #define MAX_MAP_ENTSTRING 0x40000
  175. #define MAX_MAP_TEXINFO 8192
  176. #define MAX_MAP_AREAS 256
  177. #define MAX_MAP_AREAPORTALS 1024
  178. #define MAX_MAP_PLANES 65536
  179. #define MAX_MAP_NODES 65536
  180. #define MAX_MAP_BRUSHSIDES 65536
  181. #define MAX_MAP_LEAFS 65536
  182. #define MAX_MAP_VERTS 65536
  183. #define MAX_MAP_FACES 65536
  184. #define MAX_MAP_LEAFFACES 65536
  185. #define MAX_MAP_LEAFBRUSHES 65536
  186. #define MAX_MAP_PORTALS 65536
  187. #define MAX_MAP_EDGES 128000
  188. #define MAX_MAP_SURFEDGES 256000
  189. #define MAX_MAP_LIGHTING 0x200000
  190. #define MAX_MAP_VISIBILITY 0x100000
  191. // key / value pair sizes
  192. #define MAX_KEY 32
  193. #define MAX_VALUE 1024
  194. //=============================================================================
  195. typedef struct
  196. {
  197. int fileofs, filelen;
  198. } lump_t;
  199. #define LUMP_ENTITIES 0
  200. #define LUMP_PLANES 1
  201. #define LUMP_VERTEXES 2
  202. #define LUMP_VISIBILITY 3
  203. #define LUMP_NODES 4
  204. #define LUMP_TEXINFO 5
  205. #define LUMP_FACES 6
  206. #define LUMP_LIGHTING 7
  207. #define LUMP_LEAFS 8
  208. #define LUMP_LEAFFACES 9
  209. #define LUMP_LEAFBRUSHES 10
  210. #define LUMP_EDGES 11
  211. #define LUMP_SURFEDGES 12
  212. #define LUMP_MODELS 13
  213. #define LUMP_BRUSHES 14
  214. #define LUMP_BRUSHSIDES 15
  215. #define LUMP_POP 16
  216. #define LUMP_AREAS 17
  217. #define LUMP_AREAPORTALS 18
  218. #define HEADER_LUMPS 19
  219. typedef struct
  220. {
  221. int ident;
  222. int version;
  223. lump_t lumps[HEADER_LUMPS];
  224. } dheader_t;
  225. typedef struct
  226. {
  227. float mins[3], maxs[3];
  228. float origin[3]; // for sounds or lights
  229. int headnode;
  230. int firstface, numfaces; // submodels just draw faces
  231. // without walking the bsp tree
  232. } dmodel_t;
  233. typedef struct
  234. {
  235. float point[3];
  236. } dvertex_t;
  237. // 0-2 are axial planes
  238. #define PLANE_X 0
  239. #define PLANE_Y 1
  240. #define PLANE_Z 2
  241. // 3-5 are non-axial planes snapped to the nearest
  242. #define PLANE_ANYX 3
  243. #define PLANE_ANYY 4
  244. #define PLANE_ANYZ 5
  245. // planes (x&~1) and (x&~1)+1 are always opposites
  246. typedef struct
  247. {
  248. float normal[3];
  249. float dist;
  250. int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
  251. } dplane_t;
  252. // contents flags are seperate bits
  253. // a given brush can contribute multiple content bits
  254. // multiple brushes can be in a single leaf
  255. // these definitions also need to be in q_shared.h!
  256. // lower bits are stronger, and will eat weaker brushes completely
  257. #define CONTENTS_SOLID 1 // an eye is never valid in a solid
  258. #define CONTENTS_WINDOW 2 // translucent, but not watery
  259. #define CONTENTS_AUX 4
  260. #define CONTENTS_LAVA 8
  261. #define CONTENTS_SLIME 16
  262. #define CONTENTS_WATER 32
  263. #define CONTENTS_MIST 64
  264. #define LAST_VISIBLE_CONTENTS 64
  265. // remaining contents are non-visible, and don't eat brushes
  266. #define CONTENTS_AREAPORTAL 0x8000
  267. #define CONTENTS_PLAYERCLIP 0x10000
  268. #define CONTENTS_MONSTERCLIP 0x20000
  269. // currents can be added to any other contents, and may be mixed
  270. #define CONTENTS_CURRENT_0 0x40000
  271. #define CONTENTS_CURRENT_90 0x80000
  272. #define CONTENTS_CURRENT_180 0x100000
  273. #define CONTENTS_CURRENT_270 0x200000
  274. #define CONTENTS_CURRENT_UP 0x400000
  275. #define CONTENTS_CURRENT_DOWN 0x800000
  276. #define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity
  277. #define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game
  278. #define CONTENTS_DEADMONSTER 0x4000000
  279. #define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs
  280. #define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans
  281. #define CONTENTS_LADDER 0x20000000
  282. #define SURF_LIGHT 0x1 // value will hold the light strength
  283. #define SURF_SLICK 0x2 // effects game physics
  284. #define SURF_SKY 0x4 // don't draw, but add to skybox
  285. #define SURF_WARP 0x8 // turbulent water warp
  286. #define SURF_TRANS33 0x10
  287. #define SURF_TRANS66 0x20
  288. #define SURF_FLOWING 0x40 // scroll towards angle
  289. #define SURF_NODRAW 0x80 // don't bother referencing the texture
  290. typedef struct
  291. {
  292. int planenum;
  293. int children[2]; // negative numbers are -(leafs+1), not nodes
  294. short mins[3]; // for frustom culling
  295. short maxs[3];
  296. unsigned short firstface;
  297. unsigned short numfaces; // counting both sides
  298. } dnode_t;
  299. typedef struct texinfo_s
  300. {
  301. float vecs[2][4]; // [s/t][xyz offset]
  302. int flags; // miptex flags + overrides
  303. int value; // light emission, etc
  304. char texture[32]; // texture name (textures/*.wal)
  305. int nexttexinfo; // for animations, -1 = end of chain
  306. } texinfo_t;
  307. // note that edge 0 is never used, because negative edge nums are used for
  308. // counterclockwise use of the edge in a face
  309. typedef struct
  310. {
  311. unsigned short v[2]; // vertex numbers
  312. } dedge_t;
  313. #define MAXLIGHTMAPS 4
  314. typedef struct
  315. {
  316. unsigned short planenum;
  317. short side;
  318. int firstedge; // we must support > 64k edges
  319. short numedges;
  320. short texinfo;
  321. // lighting info
  322. byte styles[MAXLIGHTMAPS];
  323. int lightofs; // start of [numstyles*surfsize] samples
  324. } dface_t;
  325. typedef struct
  326. {
  327. int contents; // OR of all brushes (not needed?)
  328. short cluster;
  329. short area;
  330. short mins[3]; // for frustum culling
  331. short maxs[3];
  332. unsigned short firstleafface;
  333. unsigned short numleaffaces;
  334. unsigned short firstleafbrush;
  335. unsigned short numleafbrushes;
  336. } dleaf_t;
  337. typedef struct
  338. {
  339. unsigned short planenum; // facing out of the leaf
  340. short texinfo;
  341. } dbrushside_t;
  342. typedef struct
  343. {
  344. int firstside;
  345. int numsides;
  346. int contents;
  347. } dbrush_t;
  348. #define ANGLE_UP -1
  349. #define ANGLE_DOWN -2
  350. // the visibility lump consists of a header with a count, then
  351. // byte offsets for the PVS and PHS of each cluster, then the raw
  352. // compressed bit vectors
  353. #define DVIS_PVS 0
  354. #define DVIS_PHS 1
  355. typedef struct
  356. {
  357. int numclusters;
  358. int bitofs[8][2]; // bitofs[numclusters][2]
  359. } dvis_t;
  360. // each area has a list of portals that lead into other areas
  361. // when portals are closed, other areas may not be visible or
  362. // hearable even if the vis info says that it should be
  363. typedef struct
  364. {
  365. int portalnum;
  366. int otherarea;
  367. } dareaportal_t;
  368. typedef struct
  369. {
  370. int numareaportals;
  371. int firstareaportal;
  372. } darea_t;