QFILES.H 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena 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 III Arena 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 Foobar; 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. #define MD3_IDENT (('3'<<24)+('P'<<16)+('D'<<8)+'I')
  84. #define MAX_QPATH 64 // max length of a quake game pathname
  85. #define MD3_XYZ_SCALE (1.0/64)
  86. typedef struct {
  87. int ident;
  88. int version;
  89. char name[MAX_QPATH]; // model name
  90. int flags;
  91. int numFrames;
  92. int numTags;
  93. int numSurfaces;
  94. int numSkins;
  95. int ofsFrames; // offset for first frame
  96. int ofsTags; // numFrames * numTags
  97. int ofsSurfaces; // first surface, others follow
  98. int ofsEnd; // end of file
  99. } md3Header_t;
  100. typedef struct {
  101. int ident; //
  102. char name[MAX_QPATH]; // polyset name
  103. int flags;
  104. int numFrames; // all surfaces in a model should have the same
  105. int numShaders; // all surfaces in a model should have the same
  106. int numVerts;
  107. int numTriangles;
  108. int ofsTriangles;
  109. int ofsShaders; // offset from start of md3Surface_t
  110. int ofsSt; // texture coords are common for all frames
  111. int ofsXyzNormals; // numVerts * numFrames
  112. int ofsEnd; // next surface follows
  113. } md3Surface_t;
  114. typedef struct {
  115. char name[MAX_QPATH];
  116. int shaderIndex; // for in-game use
  117. } md3Shader_t;
  118. typedef struct {
  119. int indexes[3];
  120. } md3Triangle_t;
  121. typedef struct {
  122. float st[2];
  123. } md3St_t;
  124. typedef struct {
  125. short xyz[3];
  126. short normal;
  127. } md3XyzNormal_t;
  128. typedef struct
  129. {
  130. float st[2];
  131. int nVertIndex;
  132. } glst_t;
  133. typedef struct
  134. {
  135. int nCount;
  136. int ObjectIndex;
  137. glst_t GlSt;
  138. } gl_t;
  139. /*
  140. ========================================================================
  141. .SP2 sprite file format
  142. ========================================================================
  143. */
  144. #define IDSPRITEHEADER (('2'<<24)+('S'<<16)+('D'<<8)+'I')
  145. // little-endian "IDS2"
  146. #define SPRITE_VERSION 2
  147. typedef struct
  148. {
  149. int width, height;
  150. int origin_x, origin_y; // raster coordinates inside pic
  151. char name[MAX_SKINNAME]; // name of pcx file
  152. } dsprframe_t;
  153. typedef struct {
  154. int ident;
  155. int version;
  156. int numframes;
  157. dsprframe_t frames[1]; // variable sized
  158. } dsprite_t;
  159. /*
  160. ==============================================================================
  161. .WAL texture file format
  162. ==============================================================================
  163. */
  164. #define MIPLEVELS 4
  165. typedef struct miptex_s
  166. {
  167. char name[32];
  168. unsigned width, height;
  169. unsigned offsets[MIPLEVELS]; // four mip maps stored
  170. char animname[32]; // next frame in animation chain
  171. int flags;
  172. int contents;
  173. int value;
  174. } miptex_t;
  175. /*
  176. ==============================================================================
  177. .BSP file format
  178. ==============================================================================
  179. */
  180. #define IDBSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I')
  181. // little-endian "IBSP"
  182. #define BSPVERSION 36
  183. // upper design bounds
  184. // leaffaces, leafbrushes, planes, and verts are still bounded by
  185. // 16 bit short limits
  186. #define MAX_MAP_MODELS 1024
  187. #define MAX_MAP_BRUSHES 8192
  188. #define MAX_MAP_ENTITIES 2048
  189. #define MAX_MAP_ENTSTRING 0x20000
  190. #define MAX_MAP_TEXINFO 8192
  191. #define MAX_MAP_PLANES 65536
  192. #define MAX_MAP_NODES 65536
  193. #define MAX_MAP_BRUSHSIDES 65536
  194. #define MAX_MAP_LEAFS 65536
  195. #define MAX_MAP_VERTS 65536
  196. #define MAX_MAP_FACES 65536
  197. #define MAX_MAP_LEAFFACES 65536
  198. #define MAX_MAP_LEAFBRUSHES 65536
  199. #define MAX_MAP_PORTALS 65536
  200. #define MAX_MAP_EDGES 128000
  201. #define MAX_MAP_SURFEDGES 256000
  202. #define MAX_MAP_LIGHTING 0x200000
  203. #define MAX_MAP_VISIBILITY 0x100000
  204. #define MAX_WORLD_COORD ( 128*1024 )
  205. #define MIN_WORLD_COORD ( -128*1024 )
  206. #define WORLD_SIZE ( MAX_WORLD_COORD - MIN_WORLD_COORD )
  207. #define MAX_BRUSH_SIZE ( WORLD_SIZE )
  208. // key / value pair sizes
  209. #define MAX_KEY 32
  210. #define MAX_VALUE 1024
  211. //=============================================================================
  212. typedef struct
  213. {
  214. int fileofs, filelen;
  215. } lump_t;
  216. #define LUMP_ENTITIES 0
  217. #define LUMP_PLANES 1
  218. #define LUMP_VERTEXES 2
  219. #define LUMP_VISIBILITY 3
  220. #define LUMP_NODES 4
  221. #define LUMP_TEXINFO 5
  222. #define LUMP_FACES 6
  223. #define LUMP_LIGHTING 7
  224. #define LUMP_LEAFS 8
  225. #define LUMP_LEAFFACES 9
  226. #define LUMP_LEAFBRUSHES 10
  227. #define LUMP_EDGES 11
  228. #define LUMP_SURFEDGES 12
  229. #define LUMP_MODELS 13
  230. #define LUMP_BRUSHES 14
  231. #define LUMP_BRUSHSIDES 15
  232. #define LUMP_POP 16
  233. #define HEADER_LUMPS 17
  234. typedef struct
  235. {
  236. int ident;
  237. int version;
  238. lump_t lumps[HEADER_LUMPS];
  239. } dheader_t;
  240. typedef struct
  241. {
  242. float mins[3], maxs[3];
  243. float origin[3]; // for sounds or lights
  244. int headnode;
  245. int firstface, numfaces; // submodels just draw faces
  246. // without walking the bsp tree
  247. } dmodel_t;
  248. typedef struct
  249. {
  250. float point[3];
  251. } dvertex_t;
  252. // 0-2 are axial planes
  253. #define PLANE_X 0
  254. #define PLANE_Y 1
  255. #define PLANE_Z 2
  256. // 3-5 are non-axial planes snapped to the nearest
  257. #define PLANE_ANYX 3
  258. #define PLANE_ANYY 4
  259. #define PLANE_ANYZ 5
  260. // planes (x&~1) and (x&~1)+1 are allways opposites
  261. typedef struct
  262. {
  263. float normal[3];
  264. float dist;
  265. int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
  266. } dplane_t;
  267. // contents flags are seperate bits
  268. // a given brush can contribute multiple content bits
  269. // multiple brushes can be in a single leaf
  270. // lower bits are stronger, and will eat weaker brushes completely
  271. #define CONTENTS_SOLID 1 // an eye is never valid in a solid
  272. #define CONTENTS_WINDOW 2 // translucent, but not watery
  273. #define CONTENTS_AUX 4
  274. #define CONTENTS_LAVA 8
  275. #define CONTENTS_SLIME 16
  276. #define CONTENTS_WATER 32
  277. #define CONTENTS_MIST 64
  278. #define LAST_VISIBLE_CONTENTS 64
  279. // remaining contents are non-visible, and don't eat brushes
  280. #define CONTENTS_PLAYERCLIP 0x10000
  281. #define CONTENTS_MONSTERCLIP 0x20000
  282. // currents can be added to any other contents, and may be mixed
  283. #define CONTENTS_CURRENT_0 0x40000
  284. #define CONTENTS_CURRENT_90 0x80000
  285. #define CONTENTS_CURRENT_180 0x100000
  286. #define CONTENTS_CURRENT_270 0x200000
  287. #define CONTENTS_CURRENT_UP 0x400000
  288. #define CONTENTS_CURRENT_DOWN 0x800000
  289. #define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity
  290. #define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game
  291. #define CONTENTS_DEADMONSTER 0x4000000 // corpse
  292. #define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs
  293. #define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans
  294. #define CONTENTS_LADDER 0x20000000 // ladder
  295. #define CONTENTS_NEGATIVE_CURVE 0x40000000 // reverse inside / outside
  296. #define CONTENTS_KEEP (CONTENTS_DETAIL | CONTENTS_NEGATIVE_CURVE)
  297. typedef struct
  298. {
  299. int planenum;
  300. int children[2]; // negative numbers are -(leafs+1), not nodes
  301. short mins[3]; // for frustom culling
  302. short maxs[3];
  303. unsigned short firstface;
  304. unsigned short numfaces; // counting both sides
  305. } dnode_t;
  306. typedef struct texinfo_s
  307. {
  308. float vecs[2][4]; // [s/t][xyz offset]
  309. int flags; // miptex flags + overrides
  310. int value; // light emission, etc
  311. char texture[32]; // texture name (textures/*.wal)
  312. int nexttexinfo; // for animations, -1 = end of chain
  313. } texinfo_t;
  314. #define SURF_LIGHT 0x1 // value will hold the light strength
  315. #define SURF_SLICK 0x2 // effects game physics
  316. #define SURF_SKY 0x4 // don't draw, but add to skybox
  317. #define SURF_WARP 0x8 // turbulent water warp
  318. #define SURF_TRANS33 0x10
  319. #define SURF_TRANS66 0x20
  320. #define SURF_FLOWING 0x40 // scroll towards angle
  321. #define SURF_NODRAW 0x80 // don't bother referencing the texture
  322. #define SURF_PATCH 0x20000000
  323. #define SURF_CURVE_FAKE 0x40000000
  324. #define SURF_CURVE 0x80000000
  325. #define SURF_KEEP (SURF_CURVE | SURF_CURVE_FAKE | SURF_PATCH)
  326. // note that edge 0 is never used, because negative edge nums are used for
  327. // counterclockwise use of the edge in a face
  328. typedef struct
  329. {
  330. unsigned short v[2]; // vertex numbers
  331. } dedge_t;
  332. #define MAXLIGHTMAPS 4
  333. typedef struct
  334. {
  335. unsigned short planenum;
  336. short side;
  337. int firstedge; // we must support > 64k edges
  338. short numedges;
  339. short texinfo;
  340. // lighting info
  341. byte styles[MAXLIGHTMAPS];
  342. int lightofs; // start of [numstyles*surfsize] samples
  343. } dface_t;
  344. typedef struct
  345. {
  346. int contents; // OR of all brushes (not needed?)
  347. int pvsofs; // -1 = no info
  348. int phsofs; // -1 = no info
  349. short mins[3]; // for frustum culling
  350. short maxs[3];
  351. unsigned short firstleafface;
  352. unsigned short numleaffaces;
  353. unsigned short firstleafbrush;
  354. unsigned short numleafbrushes;
  355. } dleaf_t;
  356. typedef struct
  357. {
  358. unsigned short planenum; // facing out of the leaf
  359. short texinfo;
  360. } dbrushside_t;
  361. typedef struct
  362. {
  363. int firstside;
  364. int numsides;
  365. int contents;
  366. } dbrush_t;
  367. #define ANGLE_UP -1
  368. #define ANGLE_DOWN -2