bspfile.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. #include "qfiles.h"
  19. extern int nummodels;
  20. extern dmodel_t dmodels[MAX_MAP_MODELS];
  21. extern int visdatasize;
  22. extern byte dvisdata[MAX_MAP_VISIBILITY];
  23. extern dvis_t *dvis;
  24. extern int lightdatasize;
  25. extern byte dlightdata[MAX_MAP_LIGHTING];
  26. extern int entdatasize;
  27. extern char dentdata[MAX_MAP_ENTSTRING];
  28. extern int numleafs;
  29. extern dleaf_t dleafs[MAX_MAP_LEAFS];
  30. extern int numplanes;
  31. extern dplane_t dplanes[MAX_MAP_PLANES];
  32. extern int numvertexes;
  33. extern dvertex_t dvertexes[MAX_MAP_VERTS];
  34. extern int numnodes;
  35. extern dnode_t dnodes[MAX_MAP_NODES];
  36. extern int numtexinfo;
  37. extern texinfo_t texinfo[MAX_MAP_TEXINFO];
  38. extern int numfaces;
  39. extern dface_t dfaces[MAX_MAP_FACES];
  40. extern int numedges;
  41. extern dedge_t dedges[MAX_MAP_EDGES];
  42. extern int numleaffaces;
  43. extern unsigned short dleaffaces[MAX_MAP_LEAFFACES];
  44. extern int numleafbrushes;
  45. extern unsigned short dleafbrushes[MAX_MAP_LEAFBRUSHES];
  46. extern int numsurfedges;
  47. extern int dsurfedges[MAX_MAP_SURFEDGES];
  48. extern int numareas;
  49. extern darea_t dareas[MAX_MAP_AREAS];
  50. extern int numareaportals;
  51. extern dareaportal_t dareaportals[MAX_MAP_AREAPORTALS];
  52. extern int numbrushes;
  53. extern dbrush_t dbrushes[MAX_MAP_BRUSHES];
  54. extern int numbrushsides;
  55. extern dbrushside_t dbrushsides[MAX_MAP_BRUSHSIDES];
  56. extern byte dpop[256];
  57. void DecompressVis (byte *in, byte *decompressed);
  58. int CompressVis (byte *vis, byte *dest);
  59. void LoadBSPFile (char *filename);
  60. void LoadBSPFileTexinfo (char *filename); // just for qdata
  61. void WriteBSPFile (char *filename);
  62. void PrintBSPFileSizes (void);
  63. //===============
  64. typedef struct epair_s
  65. {
  66. struct epair_s *next;
  67. char *key;
  68. char *value;
  69. } epair_t;
  70. typedef struct
  71. {
  72. vec3_t origin;
  73. int firstbrush;
  74. int numbrushes;
  75. epair_t *epairs;
  76. // only valid for func_areaportals
  77. int areaportalnum;
  78. int portalareas[2];
  79. } entity_t;
  80. extern int num_entities;
  81. extern entity_t entities[MAX_MAP_ENTITIES];
  82. void ParseEntities (void);
  83. void UnparseEntities (void);
  84. void SetKeyValue (entity_t *ent, char *key, char *value);
  85. char *ValueForKey (entity_t *ent, char *key);
  86. // will return "" if not present
  87. vec_t FloatForKey (entity_t *ent, char *key);
  88. void GetVectorForKey (entity_t *ent, char *key, vec3_t vec);
  89. epair_t *ParseEpair (void);
  90. void PrintEntity (entity_t *ent);