]> icculus.org git repositories - divverent/darkplaces.git/blob - model_shared.h
expanded console buffer from 16k to 128k, and changed scroll amount to be dependent...
[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
147         int                             numsurfedges;
148         int                             *surfedges;
149
150         int                             numclipnodes;
151         dclipnode_t             *clipnodes;
152
153         int                             nummarksurfaces;
154         msurface_t              **marksurfaces;
155
156         hull_t                  hulls[MAX_MAP_HULLS];
157
158         int                             numtextures;
159         texture_t               **textures;
160
161         qbyte                   *visdata;
162         qbyte                   *lightdata;
163         char                    *entities;
164
165         int                             numportals;
166         mportal_t               *portals;
167
168         int                             numportalpoints;
169         mvertex_t               *portalpoints;
170
171         int                             numlights;
172         mlight_t                *lights;
173
174         // skin animation info
175         animscene_t             *skinscenes; // [numskins]
176         // skin frame info
177         skinframe_t             *skinframes;
178
179         animscene_t             *animscenes; // [numframes]
180
181         // Q1 and Q2 models are the same after loading
182         int                             *mdlmd2data_indices;
183         float                   *mdlmd2data_texcoords;
184         md2frame_t              *mdlmd2data_frames;
185         trivertx_t              *mdlmd2data_pose;
186
187         // for Zymotic models
188         void                    *zymdata_header;
189
190         int                             sprnum_type;
191         mspriteframe_t  *sprdata_frames;
192
193         // draw the model
194         void(*Draw)(struct entity_render_s *ent);
195         // draw the model's sky polygons (only used by brush models)
196         void(*DrawSky)(struct entity_render_s *ent);
197         // draw the model's shadows
198         void(*DrawShadow)(struct entity_render_s *ent);
199
200         // memory pool for allocations
201         mempool_t               *mempool;
202 }
203 model_t;
204
205 //============================================================================
206
207 // this can be used for anything without a valid texture
208 extern rtexture_t *r_notexture;
209 // every texture must be in a pool...
210 extern rtexturepool_t *r_notexturepool;
211
212 // model loading
213 extern model_t *loadmodel;
214 extern qbyte *mod_base;
215 // sky/water subdivision
216 //extern cvar_t gl_subdivide_size;
217 // texture fullbrights
218 extern cvar_t r_fullbrights;
219
220 void Mod_Init (void);
221 void Mod_CheckLoaded (model_t *mod);
222 void Mod_ClearAll (void);
223 model_t *Mod_ForName (char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel);
224 void Mod_TouchModel (char *name);
225 void Mod_UnloadModel (model_t *mod);
226
227 void Mod_ClearUsed(void);
228 void Mod_PurgeUnused(void);
229
230 extern model_t *loadmodel;
231 extern char loadname[32];       // for hunk tags
232
233 extern model_t *Mod_FindName (char *name);
234
235 #endif  // __MODEL__
236