bsp
qtype.h
00001 #ifndef _QTYPE_H_
00002 #define _QTYPE_H_
00003 
00004 #define TMAX 32765
00005 #ifndef strcasecmp
00006 #define strcasecmp strcmpi
00007 #endif
00008 #define TYP_MIPTEX 68
00009 #define  LUMPTYPE_QPIC      'B'
00010 // the old miptex format
00011 #define  LUMPTYPE_MIPTEX    'C'
00012 #define  LUMPTYPE_RAW       'D'
00013 #define  LUMPTYPE_COLORMAP2 'E'
00014 #define  LUMPTYPE_QPICNEW     'F'
00015 // the new miptex format
00016 #define  LUMPTYPE_MIPTEXNEW  'G'
00017 
00018 typedef float vec_t;
00019 typedef float vec2_t[2];
00020 typedef float vec3_t[3];
00021 
00023 // Quake 2 Model Stuff                       //
00025 #define IDALIASHEADER  (('2'<<24)+('P'<<16)+('D'<<8)+'I')
00026 #define ALIAS_VERSION  8
00027 #define MAX_TRIANGLES  4096
00028 #define MAX_VERTS                 2048
00029 #define MAX_FRAMES        512
00030 #define MAX_MD2SKINS      32
00031 #define MAX_SKINNAME      64
00032 
00033 typedef struct dstvert_s
00034 {
00035     short       s;
00036     short       t;
00037 } dstvert_t;
00038 
00039 typedef struct dtriangle_s
00040 {
00041     short       index_xyz[3];
00042     short       index_st[3];
00043 } dtriangle_t;
00044 
00045 typedef struct dtrivertx_s
00046 {
00047     byte        v[3];     // scaled byte to fit in frame mins/maxs
00048     byte        lightnormalindex;
00049 } dtrivertx_t;
00050 
00051 typedef struct daliasframe_s
00052 {
00053     vec3_t scale; // multiply byte verts by this
00054     vec3_t origin; // then add this
00055     char                   name[16];       // frame name from grabbing
00056     dtrivertx_t verts[1];          // variable sized
00057 } daliasframe_t;
00058 
00059 // the glcmd format:
00060 // a positive integer starts a tristrip command, followed by that many
00061 // vertex structures.
00062 // a negative integer starts a trifan command, followed by -x vertexes
00063 // a zero indicates the end of the command list.
00064 // a vertex consists of a floating point s, a floating point t,
00065 // and an integer vertex index.
00066 
00067 typedef struct dmdlheader_s
00068 {
00069     int ident;
00070     int version;
00071     int skinwidth;
00072     int skinheight;
00073     int framesize;              // byte size of each frame
00074     int num_skins;
00075     int num_xyz;
00076     int num_st;                 // greater than num_xyz for seams
00077     int num_tris;
00078     int num_glcmds;     // dwords in strip/fan command list
00079     int num_frames;
00080     int ofs_skins;              // each skin is a MAX_SKINNAME string
00081     int ofs_st;                 // byte offset from start for stverts
00082     int ofs_tris;               // offset for dtriangles
00083     int ofs_frames;     // offset for first frame
00084     int ofs_glcmds;
00085     int ofs_end;                // end of file
00086 } dmdlheader_t;
00087 
00088 typedef struct dmdl_s
00089 {
00090     char        **skinnames;
00091     int        num_skins;
00092     int        num_glcmds;
00093     int        *glcmds;
00094     int        numframes;
00095     daliasframe_t *frames;
00096     int        framesize;
00097     int        skinwidth;
00098     int        skinheight;
00099     float       s_scale;
00100     float       t_scale;
00101     float       skin_screen_offset_x;
00102     float       skin_screen_offset_y;
00103     int                 gltex;
00104     int                 gl_list;
00105 } dmdl_t;
00106 
00108 // Quake 1 Model Stuff                            //
00110 typedef struct mdlheader_s
00111 {
00112     int   id;         // 0x4F504449 = "IDPO"
00113     int   version;    // Version = 3
00114     vec3_t scale;      // Scale factor, for x,y,z
00115     vec3_t origin;     // Model origin: point for x=0,y=0,z=0
00116     float  radius;     // Model radius, maybe useless now.
00117     vec3_t eye;        // Position of the eyes
00118     int   numskins ;  // the number of skin textures
00119     int   skinwidth;  // Width of skin texture
00120     //  must be multiple of 8
00121     int   skinheight; // Height of skin texture
00122     //  must be multiple of 8
00123     int   numverts;   // Number of vertices
00124     int   numtris;    // Number of triangles surfaces
00125     int   numframes;  // Number of frames
00126     int   sync;       // Sync type
00127     int   flags;      // duh
00128     float  size;       // dunno. pixels / triangle ??
00129 } mdlheader_t;
00130 
00131 typedef struct skin_s
00132 {
00133     int   type;            // Group type(1) or regular(0)
00134     int   numgroupskins;   // only used on group skins
00135     float  *interval;       // only used on group skins
00136     unsigned char **skin;   // the skin picture, length = skinwidth*skinheight
00137 } skin_t;                 // numskins pictures
00138 
00139 typedef struct stvert_s
00140 {
00141     int onseam;      // 0 or 1
00142     int s;           // position, horizontally
00143     //  in range [0,skinwidth]
00144     int t;           // position, vertically
00145     //  in range [0,skinheight]
00146 } stvert_t;
00147 
00148 typedef struct itriangle_s
00149 {
00150     int facesfront;  // boolean
00151     int vertices[3]; // Index of 3 triangle vertices
00152     //  in range [0,numverts]
00153 } itriangle_t;
00154 
00155 typedef struct trivertx_s
00156 {
00157     unsigned char x;
00158     unsigned char y;                    // X,Y,Z coordinate, packed on 0-255
00159     unsigned char z;
00160     unsigned char lightnormalindex;     // index of the vertex normal
00161 } trivertx_t;
00162 
00163 typedef struct frameinfo_s
00164 {
00165     trivertx_t min;              //
00166     trivertx_t max;              //
00167     char name[16];               // name of frame
00168 } frameinfo_t;
00169 
00170 typedef struct frame_s
00171 {
00172     int type;                    // single frame(0) or group frame(1)
00173     int numgroupframes;          // used for groups only, duh
00174     trivertx_t groupmin;          // minimum values of X,Y,Z for group
00175     trivertx_t groupmax;          // maximum values of X,Y,Z for group
00176     frameinfo_t *info;            // info on each frame
00177     float *interval;              // interval crap, dunno what it is
00178     trivertx_t **data;            // length of this array is numverts*sizeof(trivertx_t)
00179 } frame_t;
00180 
00181 typedef struct mdl_s
00182 {
00183     char        classname[40];
00184     vec3_t      scale;
00185     vec3_t      origin;
00186     int        numskins;
00187     skin_t      *skins;
00188     int        numverts;
00189     stvert_t    *verts;
00190     int        numtris;
00191     itriangle_t *triangles;
00192     int        numframes;
00193     frame_t     *frames;
00194     int        skinwidth;
00195     int        skinheight;
00196     int        scaledwidth;
00197     int        scaledheight;
00198     int         gltex;
00199     int         gl_list;
00200 } mdl_t;
00201 
00202 typedef struct pakheader_s
00203 {
00204     unsigned char magic[4];  // Name of the new WAD format = "PACK"
00205     int          diroffset; // Position of WAD directory from start of file
00206     int          dirsize;   // Number of entries * 0x40 (64 char)
00207 } pakheader_t;
00208 
00209 typedef struct pakentry_s
00210 {
00211     unsigned char filename[0x38]; // Name of the file, Unix style, with extension,
00212     // 56 chars, padded with '\0'.
00213     int          offset;         // Position of the entry in PACK file
00214     int          size;           // Size of the entry in PACK file
00215 } pakentry_t;
00216 
00217 typedef struct dentry_s
00218 {
00219     int offset;
00220     int size;
00221 } dentry_t;
00222 
00223 typedef struct dheader_s
00224 {
00225     int version;
00226     dentry_t entities;
00227     dentry_t planes;
00228     dentry_t miptex;
00229     dentry_t vertices;
00230     dentry_t visilist;
00231     dentry_t nodes;
00232     dentry_t surfaces;
00233     dentry_t lightmaps;
00234     dentry_t boundnodes;
00235     dentry_t leaves;
00236     dentry_t lstsurf;
00237     dentry_t edges;
00238     dentry_t lstedges;
00239     dentry_t hulls;
00240 } dheader_t;
00241 
00242 typedef struct boundbox_s
00243 {
00244     vec3_t minpt;
00245     vec3_t maxpt;
00246 } boundbox_t;
00247 
00248 typedef struct dhull_s
00249 {
00250     boundbox_t bound;
00251     int zero[3];
00252     int node;
00253     int boundnode;
00254     int numleafs;
00255     int firstsurface;
00256     int numsurfaces;
00257 } dhull_t;
00258 
00259 typedef struct vertex_s
00260 {
00261     float x;
00262     float y;
00263     float z;
00264 } vertex_t;
00265 
00266 typedef struct edge_s
00267 {
00268     unsigned short startvertex;
00269     unsigned short endvertex;
00270 } edge_t;
00271 
00272 typedef struct surface_s
00273 {
00274     unsigned short planenum;
00275     unsigned short side;
00276     unsigned char texnum;
00277     unsigned char sofs;
00278     unsigned char tofs;
00279     unsigned char flips;
00280     int firstedge;
00281     int numedge;
00282     unsigned char typelight;
00283     unsigned char baselight;
00284     unsigned short unknown1;
00285     int lightmap;
00286 } surface_t;
00287 
00288 typedef struct mipheader_s
00289 {
00290     int numtex;
00291     int *offset;
00292 } mipheader_t;
00293 
00294 typedef struct miptex_s
00295 {
00296     char                name[16];
00297     unsigned    int width, height;
00298     unsigned    int offsets[4];         // four mip maps stored
00299 } miptex_t;
00300 
00301 typedef struct miptex2_s
00302 {
00303     char                name[32];
00304     unsigned    int width, height;
00305     unsigned    int offsets[4];                 // four mip maps stored
00306     char                animname[32];                   // next frame in animation chain
00307     int                 flags;
00308     int                 contents;
00309     int                 value;
00310 } miptex2_t;
00311 
00312 typedef struct sin_miptexnew_s
00313 {
00314     char                name[32];
00315     unsigned    width, height;
00316     byte                palette[256*4];
00317     unsigned    offsets[4];                             // four mip maps stored
00318 } sin_miptexnew_t;
00319 
00320 typedef struct valve_miptexnew_s
00321 {
00322     char                name[16];
00323     unsigned    width, height;
00324     unsigned    offsets[4];                             // four mip maps stored
00325     WORD                palSize;
00326     byte                *palette;
00327 } valve_miptexnew_t;
00328 
00329 typedef struct wadinfo_s
00330 {
00331     char                identification[4];              // should be WAD2 or 2DAW
00332     int                 numlumps;
00333     int                 infotableofs;
00334 } wadinfo_t;
00335 
00336 typedef struct lumpinfo_s
00337 {
00338     int                 filepos;
00339     int                 disksize;
00340     int                 size;                                   // uncompressed
00341     char                type;
00342     char                compression;
00343     char                pad1, pad2;
00344     char                name[16];                               // must be null terminated
00345 } lumpinfo_t;
00346 
00347 typedef struct sin_lumpinfo_s
00348 {
00349     int                 filepos;
00350     int                 disksize;
00351     int                 size;                                   // uncompressed
00352     char                type;
00353     char                compression;
00354     char                pad1, pad2;
00355     char                name[32];
00356 } sin_lumpinfo_t;
00357 
00358 typedef struct node_s
00359 {
00360     int planenum;
00361     unsigned short front;
00362     unsigned short back;
00363     boundbox_t box;
00364 } node_t;
00365 
00366 typedef struct dleaf_s
00367 {
00368     int type;
00369     boundbox_t bound;
00370     int vislist;
00371     int firstsurf;
00372     int numsurf;
00373     unsigned int zeroes[3];
00374     unsigned short zero;
00375     unsigned short flag;
00376 } dleaf_t;
00377 
00378 typedef struct plane_s
00379 {
00380     vec3_t normal;
00381     float dist;
00382     int type;
00383     int firstsurf;
00384     int numsurf;
00385 } plane_t;
00386 
00387 typedef struct dhullbound_s
00388 {
00389     unsigned int planenum;
00390     short front;
00391     short back;
00392 } dhullbound_t;
00393 
00394 typedef struct pixel32_s
00395 {
00396     union
00397     {
00398         unsigned char chan[4];
00399         COLORREF rgb;
00400     };
00401     unsigned    p;
00402 } pixel32_t;
00403 
00404 #define TEX_TYPE_Q1 0
00405 #define TEX_TYPE_Q2 1
00406 typedef struct texturedef_s
00407 {
00408     char        texture[32];
00409     float       rotate;
00410     float       shift[2];
00411     float       scale[2];
00412 
00413     int value;
00414     int contents;
00415     int flags;
00416 
00417     // Quake 2 stuff
00418     int texType;
00419     char basepath[32];
00420 } texturedef_t;
00421 
00422 typedef struct qtexture_s
00423 {
00424     char        name[32];
00425     int         width;
00426     int         height;
00427     void        *data;                  // pointer to the image bits (belongs to texInfo_t)
00428     pixel32_t flatcolor;
00429     int bindIndex;
00430 } qtexture_t;
00431 
00432 #define         MAX_FACES               64
00433 typedef float   vec5_t[5];
00434 typedef struct winding_s
00435 {
00436     int         numpoints;
00437     vec5_t      points[8];                      // variable sized
00438 } winding_t;
00439 
00440 typedef struct leakPortal_s
00441 {
00442     vec3_t centerPoint;
00443     winding_t *w;
00444 } leakPortal_t;
00445 
00446 typedef struct leakNode_s
00447 {
00448     int numwindings;
00449     winding_t **w;
00450 } leakNode_t;
00451 
00452 
00453 #define MAX_POINTS_ON_WINDING   64
00454 
00455 typedef struct face_s
00456 {
00457     face_s *p_next, *p_prev;
00458 
00459     // implicit rep
00460     vec3_t                      planepts[3];
00461     texturedef_t        texture;
00462 
00463     // cached rep
00464     plane_t                     plane;
00465     qtexture_t          *qtexture;
00466     float                       light;          // 0 - 1.0
00467     winding_t           *w;
00468 
00469     // Quake 2
00470     bool defaults;  // Use defaults if set to YES
00471     int dcontents;  // Default Values...
00472     int dflags;
00473     int dvalue;
00474 
00475     bool transparent;
00476     bool sky;
00477 
00478 } face_t;
00479 
00480 // lower bits are stronger, and will eat weaker brushes completely
00481 #define CONTENTS_SOLID                  1               // an eye is never valid in a solid
00482 #define CONTENTS_WINDOW                 2               // translucent, but not watery
00483 #define CONTENTS_AUX                    4
00484 #define CONTENTS_LAVA                   8
00485 #define CONTENTS_SLIME                  16
00486 #define CONTENTS_WATER                  32
00487 #define CONTENTS_MIST                   64
00488 #define LAST_VISIBLE_CONTENTS   64
00489 
00490 // remaining contents are non-visible, and don't eat brushes
00491 #define CONTENTS_PLAYERCLIP             0x10000
00492 #define CONTENTS_MONSTERCLIP    0x20000
00493 // currents can be added to any other contents, and may be mixed
00494 #define CONTENTS_CURRENT_0              0x40000
00495 #define CONTENTS_CURRENT_90             0x80000
00496 #define CONTENTS_CURRENT_180    0x100000
00497 #define CONTENTS_CURRENT_270    0x200000
00498 #define CONTENTS_CURRENT_UP             0x400000
00499 #define CONTENTS_CURRENT_DOWN   0x800000
00500 #define CONTENTS_ORIGIN                 0x1000000       // removed before bsping an entity
00501 #define CONTENTS_MONSTER                0x2000000       // should never be on a brush, only in game
00502 #define CONTENTS_DEADMONSTER    0x4000000
00503 #define CONTENTS_DETAIL                 0x8000000       // brushes to be added after vis leafs
00504 #define CONTENTS_TRANSLUCENT    0x10000000      // auto set if any surface has trans
00505 #define CONTENTS_LADDER                 0x20000000
00506 
00507 #define CONTENTS_TRANS_MASK             (0xFFFFFFFF & ~(CONTENTS_SOLID|CONTENTS_LADDER))
00508 
00509 #define SURF_LIGHT              0x1             // value will hold the light strength
00510 #define SURF_SLICK              0x2             // effects game physics
00511 #define SURF_SKY                0x4             // don't draw, but add to skybox
00512 #define SURF_WARP               0x8             // turbulent water warp
00513 #define SURF_TRANS33    0x10
00514 #define SURF_TRANS66    0x20
00515 #define SURF_FLOWING    0x40    // scroll towards angle
00516 #define SURF_NODRAW             0x80    // don't bother referencing the texture
00517 #define SURF_HINT               0x100   // for bsp tree
00518 #define SURF_SKIP               0x200   // for bsp tree
00519 
00520 #define SURF_TRANS_MASK                 (SURF_TRANS33|SURF_TRANS66|SURF_FLOWING|SURF_NODRAW|SURF_HINT|SURF_SKIP)
00521 
00522 #define NO_MOUSE                 0
00523 #define DIRECTION_CALLBACK       1
00524 #define NEW_CALLBACK             2
00525 #define ROTATE_CALLBACK          3
00526 #define SELECT_CALLBACK          4
00527 #define CAMERA_CALLBACK          5
00528 #define ADDCLIPPOINT_CALLBACK    6
00529 #define TEXTUREBRUSH_CALLBACK    7
00530 #define TEXTUREFACE_CALLBACK     8
00531 #define FACEDRAG_CALLBACK        9
00532 #define BRUSHDRAG_CALLBACK       10
00533 #define CURFACEDRAG_CALLBACK     11
00534 #define SHEAR_CALLBACK                   12
00535 #define VERTEX_CALLBACK                  13
00536 #define ENTITY_CONNECT           14
00537 #define CLIPPT_CALLBACK          15
00538 #define CLIPWHOLE_CALLBACK       16
00539 #define MOVECAMERA_CALLBACK      17
00540 #define SELECTTOTAL_CALLBACK     18
00541 #define MULTIFACEDRAG_CALLBACK   19
00542 #define MULTIFACEDRAG_CALLBACKSTRICT 20
00543 #define EDGEDRAG_CALLBACK        21
00544 #define SELECTONE_CALLBACK       22
00545 #define KNOB_CALLBACK            72
00546 #define OBJECT_CALLBACK          73
00547 
00548 #define SEL_DESELECT 0
00549 #define SEL_ADDTOBBOX 1
00550 #define SEL_TRANSFORM 2
00551 #define SEL_FLIPNORMALS 3
00552 #define SEL_MOVETOENTITY 4
00553 #define SEL_REMOVE 5
00554 #define SEL_SELECTCOMPLETE 6
00555 #define SEL_SELECTPARTIAL 7
00556 #define SEL_CARVEBYCLIPPER 8
00557 #define SEL_TRANSLATE 9
00558 #define SEL_FEETTOFLOOR 10
00559 #define SEL_SELECT 11
00560 #define SEL_CAMERARENDERSELF 12
00561 #define SEL_SPLITBYCLIPPER 13
00562 #define SEL_SETFILTERED 14
00563 #define SEL_FINDCLOSEST 15
00564 #define SEL_SETREGIONED 16
00565 #define SEL_SETREGIONEDPARTIAL 17
00566 #define SEL_CALCWINDINGS 18
00567 #define SEL_UNSETREGIONED 19
00568 #define SEL_SELECTTOTAL 97
00569 #define SEL_LOCK 98
00570 #define SEL_UNLOCK 99
00571 
00572 #endif  //_QTYPE_H_
 All Classes Functions