]> icculus.org git repositories - divverent/darkplaces.git/blob - model_shared.h
fix for glowing invisible models showing up (artifact items staying visible after...
[divverent/darkplaces.git] / model_shared.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
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.
8
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.
12
13 See the GNU General Public License for more details.
14
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.
18
19 */
20
21 #ifndef __MODEL__
22 #define __MODEL__
23
24 #ifndef SYNCTYPE_T
25 #define SYNCTYPE_T
26 typedef enum {ST_SYNC=0, ST_RAND } synctype_t;
27 #endif
28
29 /*
30
31 d*_t structures are on-disk representations
32 m*_t structures are in-memory
33
34 */
35
36 typedef enum {mod_invalid, mod_brush, mod_sprite, mod_alias} modtype_t;
37
38 typedef struct animscene_s
39 {
40         char name[32]; // for viewthing support
41         int firstframe;
42         int framecount;
43         int loop; // true or false
44         float framerate;
45 }
46 animscene_t;
47
48 typedef struct skinframe_s
49 {
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
56 }
57 skinframe_t;
58
59 #define MAX_SKINS 256
60
61
62 #include "model_brush.h"
63 #include "model_sprite.h"
64 #include "model_alias.h"
65
66 typedef struct model_s
67 {
68         char                    name[MAX_QPATH];
69         // model needs to be loaded if this is true
70         qboolean                needload;
71         // set if the model is used in current map, models which are not, are purged
72         qboolean                used;
73         // CRC of the file this model was loaded from, to reload if changed
74         qboolean                crc;
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
78         qboolean                ishlbsp;
79
80         // mod_brush, mod_alias, mod_sprite
81         modtype_t               type;
82         // LordHavoc: Q2/ZYM model support
83         int                             aliastype;
84         // LordHavoc: if true (normally only for sprites) the model/sprite/bmodel is always rendered fullbright
85         int                             fullbright;
86         // number of QC accessable frame(group)s in the model
87         int                             numframes;
88         // whether to randomize animated framegroups
89         synctype_t              synctype;
90
91         // used for sprites and models
92         int                             numtris;
93         // used for models
94         int                             numskins;
95         // used by models
96         int                             numverts;
97
98         // flags from the model file
99         int                             flags;
100         // engine calculated flags, ones that can not be set in the file
101         int                             flags2;
102
103         // all models use textures...
104         rtexturepool_t  *texturepool;
105
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;
115
116         // brush model specific
117         int                             firstmodelsurface, nummodelsurfaces;
118
119         // lightmap format, set to r_lightmaprgba when model is loaded
120         int                             lightmaprgba;
121
122         int                             numsubmodels;
123         dmodel_t                *submodels;
124
125         int                             numplanes;
126         mplane_t                *planes;
127
128         // number of visible leafs, not counting 0 (solid)
129         int                             numleafs;
130         mleaf_t                 *leafs;
131
132         int                             numvertexes;
133         mvertex_t               *vertexes;
134
135         int                             numedges;
136         medge_t                 *edges;
137
138         int                             numnodes;
139         mnode_t                 *nodes;
140
141         int                             numtexinfo;
142         mtexinfo_t              *texinfo;
143
144         int                             numsurfaces;
145         msurface_t              *surfaces;
146         int                             *surfacevisframes;
147         int                             *surfacepvsframes;
148         msurface_t              *surfacepvsnext;
149
150         int                             numsurfedges;
151         int                             *surfedges;
152
153         int                             numclipnodes;
154         dclipnode_t             *clipnodes;
155
156         int                             nummarksurfaces;
157         int                             *marksurfaces;
158
159         hull_t                  hulls[MAX_MAP_HULLS];
160
161         int                             numtextures;
162         texture_t               *textures;
163
164         qbyte                   *visdata;
165         qbyte                   *lightdata;
166         char                    *entities;
167
168         int                             numportals;
169         mportal_t               *portals;
170
171         int                             numportalpoints;
172         mvertex_t               *portalpoints;
173
174         int                             numlights;
175         mlight_t                *lights;
176
177         // skin animation info
178         animscene_t             *skinscenes; // [numskins]
179         // skin frame info
180         skinframe_t             *skinframes;
181
182         animscene_t             *animscenes; // [numframes]
183
184         // Q1 and Q2 models are the same after loading
185         int                             *mdlmd2data_indices;
186         float                   *mdlmd2data_texcoords;
187         md2frame_t              *mdlmd2data_frames;
188         trivertx_t              *mdlmd2data_pose;
189
190         // for Zymotic models
191         void                    *zymdata_header;
192
193         int                             sprnum_type;
194         mspriteframe_t  *sprdata_frames;
195
196         // draw the model
197         void(*Draw)(struct entity_render_s *ent);
198         // draw the model's sky polygons (only used by brush models)
199         void(*DrawSky)(struct entity_render_s *ent);
200         // draw the model's shadows
201         void(*DrawShadow)(struct entity_render_s *ent);
202
203         // memory pool for allocations
204         mempool_t               *mempool;
205 }
206 model_t;
207
208 //============================================================================
209
210 // this can be used for anything without a valid texture
211 extern rtexture_t *r_notexture;
212 // every texture must be in a pool...
213 extern rtexturepool_t *r_notexturepool;
214
215 // model loading
216 extern model_t *loadmodel;
217 extern qbyte *mod_base;
218 // sky/water subdivision
219 //extern cvar_t gl_subdivide_size;
220 // texture fullbrights
221 extern cvar_t r_fullbrights;
222
223 void Mod_Init (void);
224 void Mod_CheckLoaded (model_t *mod);
225 void Mod_ClearAll (void);
226 model_t *Mod_FindName (const char *name);
227 model_t *Mod_ForName (const char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel);
228 void Mod_TouchModel (const char *name);
229 void Mod_UnloadModel (model_t *mod);
230
231 void Mod_ClearUsed(void);
232 void Mod_PurgeUnused(void);
233
234 extern model_t *loadmodel;
235 extern char loadname[32];       // for hunk tags
236
237 #endif  // __MODEL__
238