home *** CD-ROM | disk | FTP | other *** search
/ 1,001 Nights of Doom / 1001NightsOfDoom1995wickedSensations.iso / nodebild / idbsp10.zip / IDBSP.H < prev    next >
Text File  |  1994-06-03  |  7KB  |  274 lines

  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include "cmdlib.h"
  4.  
  5. #ifndef __IDBSP__
  6. #define __IDBSP__
  7.  
  8. #define MAX(a,b) ( (a) > (b) ) ? (a) : (b)
  9. #define MIN(a,b) ( (a) < (b) ) ? (a) : (b)
  10.  
  11. typedef struct
  12.         {
  13.         int count;
  14.         int size;
  15.         void *data;
  16.         } STORAGE;
  17.  
  18. #include <math.h>
  19. #include <limits.h>
  20. #include <float.h>
  21. /*#include "cmdlib.h" */
  22. #include "doomdata.h"
  23. #include "wadfile.h"
  24. /* #include "doomdata.h" */
  25.  
  26. /*
  27. #define SHORT(x)        NXSwapLittleShortToHost((short)x)
  28. #define LONG(x)         NXSwapLittleLongToHost((long)x)
  29. */
  30.  
  31. /*
  32. #define SHORT(x) LittleShort((short)x)
  33. #define LONG(x)  LittleLong((long)x)
  34. */
  35. /*
  36. #define SHORT(x) BigShort((short)x)
  37. #define LONG(x) BigLong((long)x)
  38. */
  39. /*
  40. #define SHORT(x) (short)(x)
  41. #define LONG(x) (long)(x)
  42. */
  43.  
  44. #define PI   3.141592657
  45.  
  46. #define         MAXVERTEX               8192
  47. #define         MAXTOUCHSECS    16
  48. #define         MAXSECTORS              2048
  49. #define         MAXSUBSECTORS   2048
  50.  
  51. typedef struct
  52.         {
  53.         float x;
  54.         float y;
  55.         } NXPoint;
  56.  
  57. typedef struct
  58.         {
  59.         float width;
  60.         float height;
  61.         } NXSize;
  62.  
  63. typedef struct
  64.         {
  65.         NXPoint origin;
  66.         NXSize size;
  67.         } NXRect;
  68.  
  69. /*
  70. ===============================================================================
  71.  
  72.                                                         map file types
  73.  
  74. ===============================================================================
  75. */
  76.  
  77. typedef struct
  78. {
  79.         int                     floorheight, ceilingheight;
  80.         char            floorflat[9], ceilingflat[9];
  81.         int                     lightlevel;
  82.         int                     special, tag;
  83. } sectordef_t;
  84.  
  85. typedef struct
  86. {
  87.         int                     firstrow;
  88.         int                     firstcollumn;
  89.         char            toptexture[9];
  90.         char            bottomtexture[9];
  91.         char            midtexture[9];
  92.         sectordef_t     sectordef;                      /* on the viewers side */
  93.         int                     sector;                         /* only used when saving doom map */
  94. } worldside_t;
  95.  
  96. typedef struct
  97. {
  98.         NXPoint         p1, p2;
  99.         int                     special, tag;
  100.         int                     flags;
  101.         worldside_t     side[2];
  102. } worldline_t;
  103.  
  104. #define ML_BLOCKMOVE    1
  105. #define ML_TWOSIDED             4       /* backside will not be present at all if not two sided */
  106.  
  107. typedef struct
  108. {
  109.         NXPoint         origin;
  110.         int                     angle;
  111.         int                     type;
  112.         int                     options;
  113.         int                     area;
  114. } worldthing_t;
  115.  
  116. /*
  117. ===============================================================================
  118.  
  119.                                                         internal types
  120.  
  121. ===============================================================================
  122. */
  123.  
  124. typedef struct
  125. {
  126.         NXPoint pt;
  127.         float   dx,dy;
  128. }divline_t;
  129.  
  130. typedef struct bspstruct_s
  131. {
  132. /*      id                                              lines_i;                // if non NULL, the node is */
  133.         STORAGE *lines_i;
  134.         divline_t                               divline;                /* terminal and has no children */
  135.         float                                   bbox[4];
  136.         struct  bspstruct_s             *side[2];
  137. } bspnode_t;
  138.  
  139.  
  140. typedef struct
  141. {
  142.         NXPoint         p1, p2;
  143.         int                     linedef, side, offset;
  144.         boolean         grouped;                                /* internal error check */
  145. } line_t;
  146.  
  147.  
  148. /*
  149. ===============================================================================
  150.  
  151.                                                                 idbsp
  152.  
  153. ===============================================================================
  154. */
  155.  
  156. extern  WADFILE                 wad_i;
  157. /*extern        boolean         draw; */
  158. void progress(void);
  159. short   LittleShort (short l);
  160. short   BigShort (short l);
  161. long    LittleLong (long l);
  162. long    BigLong (long l);
  163. void AddFromFile(char *resname, int size, char *fname);
  164. void FreeGlobalStorage(void);
  165.  
  166. /*
  167. ===============================================================================
  168.  
  169.                                                                 doomload
  170.  
  171. ===============================================================================
  172. */
  173.  
  174. extern  STORAGE *linestore_i, *thingstore_i;
  175.  
  176. /* void LoadDoomMap (char *mapname); */
  177. void LoadDoomMap(FILE *file);
  178.  
  179.  
  180. /*
  181. ===============================================================================
  182.  
  183.                                                                 drawing
  184.  
  185. ===============================================================================
  186. */
  187.  
  188. extern  STORAGE         *window_i, *view_i;
  189. extern  float   scale;
  190. extern  NXRect          worldbounds;
  191.  
  192. void EraseWindow (void);
  193. void DrawMap (void);
  194. /*void DrawLineStore (id lines_i); */
  195. void DrawLineStore(STORAGE *lines_i);
  196. void DrawDivLine (divline_t *div);
  197. void DrawLineDef (maplinedef_t *ld);
  198.  
  199.  
  200. /*
  201. ===============================================================================
  202.  
  203.                                                                 buildbsp
  204.  
  205. ===============================================================================
  206. */
  207.  
  208. extern  int             cuts;                   /* number of new lines generated by BSP process */
  209. extern  bspnode_t       *startnode;
  210.  
  211. void BuildBSP (void);
  212. void    DivlineFromWorldline (divline_t *d, line_t *w);
  213. int     PointOnSide (NXPoint *p, divline_t *l);
  214. void ExecuteSplit(STORAGE *lines_i, line_t *spliton, STORAGE *frontlist_i,
  215.                                                                         STORAGE *backlist_i);
  216.  
  217.  
  218. /*
  219. ===============================================================================
  220.  
  221.                                                         savebsp
  222.  
  223. ===============================================================================
  224. */
  225.  
  226. extern  STORAGE *secstore_i;
  227. extern  STORAGE *mapvertexstore_i;
  228. extern  STORAGE *subsecstore_i;
  229. extern  STORAGE *maplinestore_i;
  230. extern  STORAGE *nodestore_i;
  231. extern  STORAGE *mapthingstore_i;
  232. extern  STORAGE *ldefstore_i;
  233. extern  STORAGE *sdefstore_i;
  234.  
  235. void SaveDoomMap (void);
  236.  
  237. /*
  238. ===============================================================================
  239.  
  240.                                                         saveblocks
  241.  
  242. ===============================================================================
  243. */
  244.  
  245. void SaveBlocks (void);
  246.  
  247. /* extern short *datalist; */
  248.  
  249. /*
  250. ===============================================================================
  251.  
  252.                                                         savesectors
  253.  
  254. ===============================================================================
  255. */
  256.  
  257. void ProcessSectors (void);
  258. void BuildSectordefs (void);
  259.  
  260. /* extern short **vertexsublist; */
  261.  
  262. /*
  263. ===============================================================================
  264.  
  265.                                                         saveconnect
  266.  
  267. ===============================================================================
  268. */
  269.  
  270. void ProcessConnections (void);
  271. void OutputConnections (void);
  272.  
  273. #endif
  274.