home *** CD-ROM | disk | FTP | other *** search
/ Black Art of 3D Game Programming / Black_Art_of_3D_Game_Programming.iso / source / msc / library / black15.h < prev    next >
Text File  |  1995-02-21  |  4KB  |  110 lines

  1.  
  2. // header file for black15.c
  3.  
  4. // D E F I N E S //////////////////////////////////////////////////////////////
  5.  
  6. // these constants are used to place the walls in world coordinates
  7.  
  8. #define WORLD_SCALE_X        2      // scaling factors used to scale the
  9. #define WORLD_SCALE_Y        2      // screen coordinates that the BSP
  10. #define WORLD_SCALE_Z       -2      // is drawn with
  11.  
  12. #define WORLD_POS_X          0      // the final position to move the
  13. #define WORLD_POS_Y          0      // walls to when "view" is selected
  14. #define WORLD_POS_Z          300
  15.  
  16. #define SCREEN_TO_WORLD_X    -112   // the translation factors to move the origin
  17. #define SCREEN_TO_WORLD_Z    -100   // to the center of the screen in mode 320x200
  18.  
  19. #define WALL_CEILING         20 // the y coordinate of the artificial ceiling
  20. #define WALL_FLOOR          -20 // the y coordinate of the artificial floor
  21.  
  22.  
  23. #define BSP_WALL_COLOR       47 // color of all the walls in the bsp tree
  24. #define BSP_WALL_SHADE       47
  25.  
  26. // M A C R O S ///////////////////////////////////////////////////////////////
  27.  
  28. // tests if two 3-d points are equal
  29.  
  30. #define POINTS_EQUAL_3D(p1,p2) (p1.x==p2.x && p1.y==p2.y && p1.z==p2.z)
  31.  
  32. // S T R U C T U R E S ////////////////////////////////////////////////////////
  33.  
  34.  
  35. // this structure holds a wall, it's very similar to our standard polygon
  36. // structure, but stripped down for demo purposes
  37.  
  38. typedef struct wall_typ
  39.         {
  40.         int id;                  // used for debugging
  41.  
  42.         int color;               // color of wall
  43.  
  44.         point_3d wall_world[4];  // the points that make up the wall
  45.         point_3d wall_camera[4]; // the final camera coordinates of the wall
  46.  
  47.         vector_3d normal;        // the outward normal to the wall used during
  48.                                  // creation of BSP only, after that it becomes
  49.                                  // invalid
  50.  
  51.         struct wall_typ *link;   // pointer to next wall
  52.         struct wall_typ *front;  // pointer to walls in front
  53.         struct wall_typ *back;   // pointer to walls behind
  54.  
  55.         } wall, *wall_ptr;
  56.  
  57. //  P R O T O T Y P E S ///////////////////////////////////////////////////////
  58.  
  59. void Draw_TB_Tri_3D_Z(int x1,int y1, int z1,
  60.                       int x2,int y2, int z2,
  61.                       int x3,int y3, int z3,
  62.                       int color);
  63.  
  64.  
  65. void Draw_Tri_3D_Z(int x1,int y1,int z1,
  66.                    int x2,int y2,int z2,
  67.                    int x3,int y3,int z3,
  68.                    int color);
  69.  
  70. void Draw_Poly_List_Z(void);
  71.  
  72. int Create_Z_Buffer(unsigned int height);
  73.  
  74. void Delete_Z_Buffer(void);
  75.  
  76. void Fill_Z_Buffer(int value);
  77.  
  78. void Bsp_World_To_Camera(wall_ptr root);
  79.  
  80. void Bsp_Translate(wall_ptr root,int x_trans,int y_trans,int z_trans);
  81.  
  82. void Bsp_Shade(wall_ptr root);
  83.  
  84. void Bsp_Traverse(wall_ptr root);
  85.  
  86. void Bsp_Delete(wall_ptr root);
  87.  
  88. void Bsp_Print(wall_ptr root);
  89.  
  90. void Bsp_View(wall_ptr bsp_root);
  91.  
  92. void Build_Bsp_Tree(wall_ptr root);
  93.  
  94. void Intersect_Lines(float x0,float y0,float x1,float y1,
  95.                      float x2,float y2,float x3,float y3,
  96.                      float *xi,float *yi);
  97.  
  98. // E X T E R N A L S///////////////////////////////////////////////////////////
  99.  
  100. extern int far *z_buffer;   // the current z buffer memory
  101. extern int far *z_bank_1;   // memory bank 1 of z buffer
  102. extern int far *z_bank_2;   // memory bank 2 of z buffer
  103.  
  104. extern unsigned int z_height; // the height if the z buffer
  105. extern unsigned int z_height_2;      // the height if half the z buffer
  106. extern unsigned int z_bank_size;     // size of a z buffer bank in bytes
  107.  
  108. extern FILE *fp_out;  // general output file
  109.  
  110.