home *** CD-ROM | disk | FTP | other *** search
/ Quake++ for Quake / Quake++.iso / quake / edquake / code / bsp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-05  |  5.1 KB  |  123 lines

  1. #define u_short  unsigned short int
  2. #define u_char  unsigned char
  3. #define u_long  unsigned long
  4.  
  5. typedef struct                 // A Directory entry
  6. { long  offset;                // Offset to entry, in bytes, from start of file
  7.   long  size;                  // Size of entry in file, in bytes
  8.   } dentry_t;
  9.  
  10. typedef struct                 // The BSP file header
  11. { long  startloc;
  12.   long  version;               // Model version, must be 0x17 (23).
  13.                  //NOTE:shareware is 0x1c
  14.   dentry_t entities;           // List of Entities.
  15.   dentry_t planes;             // Map Planes.
  16.                    // numplanes = size/sizeof(plane_t)
  17.   dentry_t miptex;             // Wall Textures.
  18.   dentry_t vertices;           // Map Vertices.
  19.                    // numvertices = size/sizeof(vertex_t)
  20.   dentry_t visilist;           // Leaves Visibility lists.
  21.   dentry_t nodes;              // BSP Nodes.
  22.                    // numnodes = size/sizeof(node_t)
  23.   dentry_t surfaces;           // Map Surfaces.
  24.                    // numsurfaces = size/sizeof(surface_t)
  25.   dentry_t lightmaps;          // Wall Light Maps.
  26.   dentry_t boundnodes;         // BSP bound nodes, for Hulls.
  27.                    // numbounds = size/sizeof(hullbound_t)
  28.   dentry_t leaves;             // BSP Leaves.
  29.                    // numlaves = size/sizeof(leaf_t)
  30.   dentry_t lstsurf;            // List of Surfaces.
  31.   dentry_t edges;              // Original surface Edges.
  32.                    // numedges = Size/sizeof(edge_t)
  33.   dentry_t lstedges;           // List of surfaces Edges.
  34.   dentry_t hulls;              // List of Hulls.
  35.                    // numhulls = Size/sizeof(hull_t)
  36. } dheader_t;
  37.  
  38. typedef float scalar_t;        // Scalar value,
  39.  
  40. typedef struct                 // Vector or Position
  41. { scalar_t x;                  // horizontal
  42.   scalar_t y;                  // horizontal
  43.   scalar_t z;                  // vertical
  44. } vec3_t;
  45.  
  46. typedef struct                 // Bounding Box
  47. { vec3_t   min;                // minimum values of X,Y,Z
  48.   vec3_t   max;                // maximum values of X,Y,Z
  49. } boundbox_t;
  50.  
  51. typedef struct
  52. { boundbox_t bound;            // The bounding box of the Hull
  53.   long zero[3];                // Always 0, purpose unknown
  54.   long node;                   // index of first BSP node
  55.   long boundnode;              // index of first Bound BSP node
  56.   long numleafs;               // number of BSP leaves
  57.   long firstsurface;           // id of Surfaces
  58.   long numsurfaces;            // number of Surfaces
  59. } dhull_t;
  60.  
  61. typedef struct
  62. { float X;                    // X,Y,Z coordinates of the vertex
  63.   float Y;                    // usually some integer value
  64.   float Z;                    // but coded in floating point
  65. } vertex_t;
  66.  
  67. typedef struct
  68. { u_short startvertex;         // index of the start vertex
  69.                    //  must be in [0,numvertices[
  70.   u_short endvertex;           // index of the start vertex
  71.                 //  must be in [0,numvertices[
  72. } edge_t;
  73.  
  74. typedef struct
  75. { u_short planenum;            // The plane in which the surface lies
  76.                    //           must be in [0,numplanes[
  77.   u_short side;                // 0 if in front of the plane, 1 if behind the plane
  78.   u_char texnum;               // id of Mip Texture
  79.                                   //           must be in [0,numtex[
  80.   u_char sofs;                 // horizontal offset (in texture space)
  81.   u_char tofs;                 // vertical offset (in texture space)
  82.   u_char flips;                // if bit 0==1 flip vertically (in texture space)
  83.                // if bit 1==1 flip horizontally (in texture space)
  84.                   // if bit 2==1 exchange vertical and horizontal coordinates
  85.   long firstedge;              // first edge in the List of edges
  86.            //           must be in [0,numedges[
  87.   long numedge;                // number of edges in the List of edges
  88.   u_char typelight;            // type of lighting, for the surface
  89.   u_char baselight;            // from 0xFF (dark) to 0 (bright)
  90.   u_short unknown1;            // 0xFFFF, probably useless (padding)
  91.   long lightmap;               // Pointer inside the general light map, or -1
  92. // this define the start of the surface light map
  93. } surface_t;
  94.  
  95. typedef struct                 // Mip texture list header
  96. {
  97.   long numtex;                 // Number of textures in Mip Texture list
  98.   long offset[256];         // Offset to each of the individual texture
  99. } mipheader_t;                 //  from the beginning of mipheader_t
  100.  
  101.  
  102. typedef struct                 // Mip Texture
  103. { char name[16];               // Name of the texture.
  104. u_long width;                // width of picture, must be a multiple of 8
  105. u_long height;               // height of picture, must be a multiple of 8
  106. u_long offset1;              // offset to u_char Pix[width   * height]
  107. u_long offset2;              // offset to u_char Pix[width/2 * height/2]
  108. u_long offset4;              // offset to u_char Pix[width/4 * height/4]
  109. u_long offset8;              // offset to u_char Pix[width/8 * height/8]
  110. long  pakoffset;             //internal use
  111. } miptex_t;
  112.  
  113. extern dheader_t bsp;
  114. extern miptex_t  texture[256];
  115. extern long numtex;
  116.  
  117. #include <stdio.h>
  118.  
  119. void reportbsp();
  120. void loadbsp(int e);
  121. int gettexture();
  122. void showtexture(int e);
  123. dentry_t fgetd(FILE *p);