2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 typedef enum {ST_SYNC=0, ST_RAND } synctype_t;
31 d*_t structures are on-disk representations
32 m*_t structures are in-memory
36 typedef enum {mod_invalid, mod_brush, mod_sprite, mod_alias} modtype_t;
38 typedef struct animscene_s
40 char name[32]; // for viewthing support
43 int loop; // true or false
48 typedef struct skinframe_s
50 rtexture_t *base; // original texture minus pants/shirt/glow
51 rtexture_t *pants; // pants only (in greyscale)
52 rtexture_t *shirt; // shirt only (in greyscale)
53 rtexture_t *glow; // glow only
54 rtexture_t *merged; // original texture minus glow
55 rtexture_t *fog; // white texture with alpha of the base texture, NULL if not transparent
62 #include "model_brush.h"
63 #include "model_sprite.h"
64 #include "model_alias.h"
66 typedef struct model_s
69 // model needs to be loaded if this is true
71 // set if the model is used in current map, models which are not, are purged
73 // CRC of the file this model was loaded from, to reload if changed
75 // true if this is the world model (I.E. defines what sky to use, and may contain submodels)
76 qboolean isworldmodel;
77 // true if this model is a HalfLife .bsp file
80 // mod_brush, mod_alias, mod_sprite
82 // LordHavoc: Q2/ZYM model support
84 // LordHavoc: if true (normally only for sprites) the model/sprite/bmodel is always rendered fullbright
86 // number of QC accessable frame(group)s in the model
88 // whether to randomize animated framegroups
91 // used for sprites and models
98 // flags from the model file
100 // engine calculated flags, ones that can not be set in the file
103 // all models use textures...
104 rtexturepool_t *texturepool;
106 // volume occupied by the model
107 // bounding box at angles '0 0 0'
108 vec3_t normalmins, normalmaxs;
109 // bounding box if yaw angle is not 0, but pitch and roll are
110 vec3_t yawmins, yawmaxs;
111 // bounding box if pitch or roll are used
112 vec3_t rotatedmins, rotatedmaxs;
113 // usable at any angles
114 // float modelradius;
116 // brush model specific
117 int firstmodelsurface, nummodelsurfaces;
118 // LordHavoc: sorted surface pointer array, sorted by shader type and then by texture
119 msurface_t **modelsortedsurfaces; // [nummodelsurfaces]
121 // lightmap format, set to r_lightmaprgba when model is loaded
130 // number of visible leafs, not counting 0 (solid)
147 msurface_t *surfaces;
153 dclipnode_t *clipnodes;
156 msurface_t **marksurfaces;
158 hull_t hulls[MAX_MAP_HULLS];
161 texture_t **textures;
171 mvertex_t *portalpoints;
176 // skin animation info
177 animscene_t *skinscenes; // [numskins]
179 skinframe_t *skinframes;
181 animscene_t *animscenes; // [numframes]
183 // Q1 and Q2 models are the same after loading
184 int *mdlmd2data_indices;
185 float *mdlmd2data_texcoords;
186 md2frame_t *mdlmd2data_frames;
187 trivertx_t *mdlmd2data_pose;
189 // for Zymotic models
190 void *zymdata_header;
193 mspriteframe_t *sprdata_frames;
197 // draw the model's sky polygons (only used by brush models)
198 void(*DrawSky)(void);
199 // draw the model's shadows
200 void(*DrawShadow)(void);
202 // memory pool for allocations
207 //============================================================================
209 // this can be used for anything without a valid texture
210 extern rtexture_t *r_notexture;
211 // every texture must be in a pool...
212 extern rtexturepool_t *r_notexturepool;
215 extern model_t *loadmodel;
216 extern qbyte *mod_base;
217 // sky/water subdivision
218 extern cvar_t gl_subdivide_size;
219 // texture fullbrights
220 extern cvar_t r_fullbrights;
222 void Mod_Init (void);
223 void Mod_CheckLoaded (model_t *mod);
224 void Mod_ClearAll (void);
225 model_t *Mod_ForName (char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel);
226 void Mod_TouchModel (char *name);
227 void Mod_UnloadModel (model_t *mod);
229 mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
230 qbyte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
232 void Mod_ClearUsed(void);
233 void Mod_PurgeUnused(void);
235 extern model_t *loadmodel;
236 extern char loadname[32]; // for hunk tags
238 extern model_t *Mod_FindName (char *name);