bspfile.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. Copyright (C) 1996-1997 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. // upper design bounds
  16. #define MAX_MAP_HULLS 4
  17. #define MAX_MAP_MODELS 256
  18. #define MAX_MAP_BRUSHES 4096
  19. #define MAX_MAP_ENTITIES 1024
  20. #define MAX_MAP_ENTSTRING 65536
  21. #define MAX_MAP_PLANES 8192
  22. #define MAX_MAP_NODES 32767 // because negative shorts are contents
  23. #define MAX_MAP_CLIPNODES 32767 //
  24. #define MAX_MAP_LEAFS 32767 //
  25. #define MAX_MAP_VERTS 65535
  26. #define MAX_MAP_FACES 65535
  27. #define MAX_MAP_MARKSURFACES 65535
  28. #define MAX_MAP_TEXINFO 4096
  29. #define MAX_MAP_EDGES 256000
  30. #define MAX_MAP_SURFEDGES 512000
  31. #define MAX_MAP_MIPTEX 0x200000
  32. #define MAX_MAP_LIGHTING 0x100000
  33. #define MAX_MAP_VISIBILITY 0x100000
  34. // key / value pair sizes
  35. #define MAX_KEY 32
  36. #define MAX_VALUE 1024
  37. //=============================================================================
  38. #define BSPVERSION 29
  39. typedef struct
  40. {
  41. int fileofs, filelen;
  42. } lump_t;
  43. #define LUMP_ENTITIES 0
  44. #define LUMP_PLANES 1
  45. #define LUMP_TEXTURES 2
  46. #define LUMP_VERTEXES 3
  47. #define LUMP_VISIBILITY 4
  48. #define LUMP_NODES 5
  49. #define LUMP_TEXINFO 6
  50. #define LUMP_FACES 7
  51. #define LUMP_LIGHTING 8
  52. #define LUMP_CLIPNODES 9
  53. #define LUMP_LEAFS 10
  54. #define LUMP_MARKSURFACES 11
  55. #define LUMP_EDGES 12
  56. #define LUMP_SURFEDGES 13
  57. #define LUMP_MODELS 14
  58. #define HEADER_LUMPS 15
  59. typedef struct
  60. {
  61. float mins[3], maxs[3];
  62. float origin[3];
  63. int headnode[MAX_MAP_HULLS];
  64. int visleafs; // not including the solid leaf 0
  65. int firstface, numfaces;
  66. } dmodel_t;
  67. typedef struct
  68. {
  69. int version;
  70. lump_t lumps[HEADER_LUMPS];
  71. } dheader_t;
  72. typedef struct
  73. {
  74. int nummiptex;
  75. int dataofs[4]; // [nummiptex]
  76. } dmiptexlump_t;
  77. #define MIPLEVELS 4
  78. typedef struct miptex_s
  79. {
  80. char name[16];
  81. unsigned width, height;
  82. unsigned offsets[MIPLEVELS]; // four mip maps stored
  83. } miptex_t;
  84. typedef struct
  85. {
  86. float point[3];
  87. } dvertex_t;
  88. // 0-2 are axial planes
  89. #define PLANE_X 0
  90. #define PLANE_Y 1
  91. #define PLANE_Z 2
  92. // 3-5 are non-axial planes snapped to the nearest
  93. #define PLANE_ANYX 3
  94. #define PLANE_ANYY 4
  95. #define PLANE_ANYZ 5
  96. typedef struct
  97. {
  98. float normal[3];
  99. float dist;
  100. int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
  101. } dplane_t;
  102. #define CONTENTS_EMPTY -1
  103. #define CONTENTS_SOLID -2
  104. #define CONTENTS_WATER -3
  105. #define CONTENTS_SLIME -4
  106. #define CONTENTS_LAVA -5
  107. #define CONTENTS_SKY -6
  108. // !!! if this is changed, it must be changed in asm_i386.h too !!!
  109. typedef struct
  110. {
  111. int planenum;
  112. short children[2]; // negative numbers are -(leafs+1), not nodes
  113. short mins[3]; // for sphere culling
  114. short maxs[3];
  115. unsigned short firstface;
  116. unsigned short numfaces; // counting both sides
  117. } dnode_t;
  118. typedef struct
  119. {
  120. int planenum;
  121. short children[2]; // negative numbers are contents
  122. } dclipnode_t;
  123. typedef struct texinfo_s
  124. {
  125. float vecs[2][4]; // [s/t][xyz offset]
  126. int miptex;
  127. int flags;
  128. } texinfo_t;
  129. #define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
  130. // note that edge 0 is never used, because negative edge nums are used for
  131. // counterclockwise use of the edge in a face
  132. typedef struct
  133. {
  134. unsigned short v[2]; // vertex numbers
  135. } dedge_t;
  136. #define MAXLIGHTMAPS 4
  137. typedef struct
  138. {
  139. short planenum;
  140. short side;
  141. int firstedge; // we must support > 64k edges
  142. short numedges;
  143. short texinfo;
  144. // lighting info
  145. byte styles[MAXLIGHTMAPS];
  146. int lightofs; // start of [numstyles*surfsize] samples
  147. } dface_t;
  148. #define AMBIENT_WATER 0
  149. #define AMBIENT_SKY 1
  150. #define AMBIENT_SLIME 2
  151. #define AMBIENT_LAVA 3
  152. #define NUM_AMBIENTS 4 // automatic ambient sounds
  153. // leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas
  154. // all other leafs need visibility info
  155. typedef struct
  156. {
  157. int contents;
  158. int visofs; // -1 = no visibility info
  159. short mins[3]; // for frustum culling
  160. short maxs[3];
  161. unsigned short firstmarksurface;
  162. unsigned short nummarksurfaces;
  163. byte ambient_level[NUM_AMBIENTS];
  164. } dleaf_t;
  165. //============================================================================
  166. #ifndef QUAKE_GAME
  167. // the utilities get to be lazy and just use large static arrays
  168. extern int nummodels;
  169. extern dmodel_t dmodels[MAX_MAP_MODELS];
  170. extern int visdatasize;
  171. extern byte dvisdata[MAX_MAP_VISIBILITY];
  172. extern int lightdatasize;
  173. extern byte dlightdata[MAX_MAP_LIGHTING];
  174. extern int texdatasize;
  175. extern byte dtexdata[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
  176. extern int entdatasize;
  177. extern char dentdata[MAX_MAP_ENTSTRING];
  178. extern int numleafs;
  179. extern dleaf_t dleafs[MAX_MAP_LEAFS];
  180. extern int numplanes;
  181. extern dplane_t dplanes[MAX_MAP_PLANES];
  182. extern int numvertexes;
  183. extern dvertex_t dvertexes[MAX_MAP_VERTS];
  184. extern int numnodes;
  185. extern dnode_t dnodes[MAX_MAP_NODES];
  186. extern int numtexinfo;
  187. extern texinfo_t texinfo[MAX_MAP_TEXINFO];
  188. extern int numfaces;
  189. extern dface_t dfaces[MAX_MAP_FACES];
  190. extern int numclipnodes;
  191. extern dclipnode_t dclipnodes[MAX_MAP_CLIPNODES];
  192. extern int numedges;
  193. extern dedge_t dedges[MAX_MAP_EDGES];
  194. extern int nummarksurfaces;
  195. extern unsigned short dmarksurfaces[MAX_MAP_MARKSURFACES];
  196. extern int numsurfedges;
  197. extern int dsurfedges[MAX_MAP_SURFEDGES];
  198. void LoadBSPFile (char *filename);
  199. void WriteBSPFile (char *filename);
  200. void PrintBSPFileSizes (void);
  201. #endif