1 /* 2 * sv_model.h -- header for model loading and caching 3 * $Id: sv_model.h 5014 2012-11-20 16:02:09Z sezero $ 4 * 5 * This version of model.[ch] are based on the quake dedicated server 6 * application lhnqserver by Forest 'LordHavoc' Hale, with simplified 7 * data structures and loading only brush models without the textures. 8 * 9 * Copyright (C) 1996-1997 Id Software, Inc. 10 * Copyright (C) 1997-1998 Raven Software Corp. 11 * 12 * This program is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU General Public License as published by 14 * the Free Software Foundation; either version 2 of the License, or (at 15 * your option) any later version. 16 * 17 * This program is distributed in the hope that it will be useful, but 18 * WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 * See the GNU General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License along 24 * with this program; if not, write to the Free Software Foundation, Inc., 25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 26 */ 27 28 #ifndef __HX2_MODEL_H 29 #define __HX2_MODEL_H 30 31 #include "genmodel.h" 32 #include "spritegn.h" 33 34 /* 35 36 d*_t structures are on-disk representations 37 m*_t structures are in-memory 38 39 */ 40 41 /* 42 ============================================================================== 43 44 BRUSH MODELS 45 46 ============================================================================== 47 */ 48 49 50 // 51 // in memory representation 52 // 53 // !!! if this is changed, it must be changed in asm_draw.h too !!! 54 typedef struct 55 { 56 vec3_t position; 57 } mvertex_t; 58 59 #define SIDE_FRONT 0 60 #define SIDE_BACK 1 61 #define SIDE_ON 2 62 63 64 // plane_t structure 65 typedef struct mplane_s 66 { 67 vec3_t normal; 68 float dist; 69 byte type; // for texture axis selection and fast side tests 70 byte signbits; // signx + signy<<1 + signz<<1 71 byte pad[2]; 72 } mplane_t; 73 74 #define SURF_PLANEBACK 2 75 #define SURF_DRAWSKY 4 76 #define SURF_DRAWSPRITE 8 77 #define SURF_DRAWTURB 0x10 78 #define SURF_DRAWTILED 0x20 79 #define SURF_DRAWBACKGROUND 0x40 80 #define SURF_TRANSLUCENT 0x80 /* r_edge.asm checks this */ 81 #define SURF_DRAWBLACK 0x200 82 83 typedef struct 84 { 85 unsigned short v[2]; 86 } medge_t; 87 88 typedef struct 89 { 90 float vecs[2][4]; 91 int flags; 92 } mtexinfo_t; 93 94 typedef struct msurface_s 95 { 96 mplane_t *plane; 97 int flags; 98 99 short texturemins[2]; 100 short extents[2]; 101 102 mtexinfo_t *texinfo; 103 104 // lighting info 105 byte styles[MAXLIGHTMAPS]; 106 byte *samples; // [numstyles*surfsize] 107 } msurface_t; 108 109 typedef struct mnode_s 110 { 111 // common with leaf 112 int contents; // 0, to differentiate from leafs 113 114 struct mnode_s *parent; 115 116 // node specific 117 mplane_t *plane; 118 struct mnode_s *children[2]; 119 120 unsigned short firstsurface; 121 unsigned short numsurfaces; 122 } mnode_t; 123 124 125 typedef struct mleaf_s 126 { 127 // common with node 128 int contents; // wil be a negative contents number 129 130 struct mnode_s *parent; 131 132 // leaf specific 133 byte *compressed_vis; 134 } mleaf_t; 135 136 // !!! if this is changed, it must be changed in asm_i386.h too !!! 137 typedef struct 138 { 139 dclipnode_t *clipnodes; 140 mplane_t *planes; 141 int firstclipnode; 142 int lastclipnode; 143 vec3_t clip_mins; 144 vec3_t clip_maxs; 145 } hull_t; 146 147 #define HULL_IMPLICIT 0 // Choose the hull based on bounding box- like in Quake 148 #define HULL_POINT 1 // 0 0 0, 0 0 0 149 #define HULL_PLAYER 2 // '-16 -16 0', '16 16 56' 150 #define HULL_SCORPION 3 // '-24 -24 -20', '24 24 20' 151 #define HULL_CROUCH 4 // '-16 -16 0', '16 16 28' 152 #define HULL_HYDRA 5 // '-28 -28 -24', '28 28 24' 153 #define HULL_GOLEM 6 // ???,??? 154 155 156 //=================================================================== 157 158 // 159 // entity effects 160 // 161 #ifndef H2W /* see below for hexenworld */ 162 #define EF_BRIGHTFIELD 0x00000001 163 #endif 164 #define EF_MUZZLEFLASH 0x00000002 165 #define EF_BRIGHTLIGHT 0x00000004 166 #define EF_DIMLIGHT 0x00000008 167 #define EF_DARKLIGHT 0x00000010 168 #define EF_DARKFIELD 0x00000020 169 #define EF_LIGHT 0x00000040 170 #define EF_NODRAW 0x00000080 171 172 #ifdef H2W 173 /* The only difference between Raven's hw-0.15 binary release and the 174 * later HexenC source release is the EF_BRIGHTFIELD and EF_ONFIRE values: 175 * the original binary releases had them as 1 and 1024 respectively, but 176 * the later hcode src releases have them flipped: EF_BRIGHTFIELD = 1024 177 * and EF_ONFIRE = 1, which is a BIG BOO BOO. (On the other hand, Siege 178 * binary and source releases have EF_BRIGHTFIELD and EF_ONFIRE values as 179 * 1 and 1024, which makes the mess even messier.. Sigh..) 180 * The hexenworld engine src release also have EF_BRIGHTFIELD as 1024 and 181 * EF_ONFIRE as 1, therefore uHexen2 sticks to those values. 182 */ 183 #define EF_ONFIRE 0x00000001 184 #define EF_BRIGHTFIELD 0x00000400 185 #define EF_POWERFLAMEBURN 0x00000800 186 #define EF_UPDATESOUND 0x00002000 187 188 #define EF_POISON_GAS 0x00200000 189 #define EF_ACIDBLOB 0x00400000 190 //#define EF_PURIFY2_EFFECT 0x00200000 191 //#define EF_AXE_EFFECT 0x00400000 192 //#define EF_SWORD_EFFECT 0x00800000 193 //#define EF_TORNADO_EFFECT 0x01000000 194 #define EF_ICESTORM_EFFECT 0x02000000 195 //#define EF_ICEBALL_EFFECT 0x04000000 196 //#define EF_METEOR_EFFECT 0x08000000 197 #define EF_HAMMER_EFFECTS 0x10000000 198 #define EF_BEETLE_EFFECTS 0x20000000 199 #endif /* H2W */ 200 201 //=================================================================== 202 203 // 204 // Whole model 205 // 206 207 typedef enum {mod_brush, mod_sprite, mod_alias} modtype_t; 208 209 typedef struct qmodel_s 210 { 211 char name[MAX_QPATH]; 212 unsigned int path_id; // path id of the game directory 213 // that this model came from 214 int needload; // bmodels and sprites don't cache normally 215 216 modtype_t type; 217 int flags; 218 int numframes; 219 220 // 221 // volume occupied by the model graphics 222 // 223 vec3_t mins, maxs; 224 float radius; 225 226 // 227 // brush model 228 // 229 int firstmodelsurface, nummodelsurfaces; 230 231 int numsubmodels; 232 dmodel_t *submodels; 233 234 int numplanes; 235 mplane_t *planes; 236 237 int numleafs; // number of visible leafs, not counting 0 238 mleaf_t *leafs; 239 240 int numvertexes; 241 mvertex_t *vertexes; 242 243 int numnodes; 244 mnode_t *nodes; 245 246 int numtexinfo; 247 mtexinfo_t *texinfo; 248 249 int numsurfaces; 250 msurface_t *surfaces; 251 252 int numclipnodes; 253 dclipnode_t *clipnodes; 254 255 hull_t hulls[MAX_MAP_HULLS]; 256 257 byte *visdata; 258 byte *lightdata; 259 char *entities; 260 } qmodel_t; 261 262 // values for qmodel_t->needload 263 #define NL_PRESENT 0 264 #define NL_NEEDS_LOADED 1 265 #define NL_UNREFERENCED 2 266 267 //============================================================================ 268 269 void Mod_Init (void); 270 void Mod_ClearAll (void); 271 qmodel_t *Mod_ForName (const char *name, qboolean crash); 272 qmodel_t *Mod_FindName (const char *name); 273 274 mleaf_t *Mod_PointInLeaf (float *p, qmodel_t *model); 275 byte *Mod_LeafPVS (mleaf_t *leaf, qmodel_t *model); 276 277 #endif /* __HX2_MODEL_H */ 278 279