qfiles.h 9.2 KB

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