|
|
1.1 root 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: #include "modelgen.h"
25: #include "spritegn.h"
26:
27: /*
28:
29: d*_t structures are on-disk representations
30: m*_t structures are in-memory
31:
32: */
33:
34: // entity effects
35:
36: #define EF_BRIGHTFIELD 1
37: #define EF_MUZZLEFLASH 2
38: #define EF_BRIGHTLIGHT 4
39: #define EF_DIMLIGHT 8
40: #define EF_FLAG1 16
41: #define EF_FLAG2 32
42: #define EF_BLUE 64
43: #define EF_RED 128
44:
45: /*
46: ==============================================================================
47:
48: BRUSH MODELS
49:
50: ==============================================================================
51: */
52:
53:
54: //
55: // in memory representation
56: //
57: // !!! if this is changed, it must be changed in asm_draw.h too !!!
58: typedef struct
59: {
60: vec3_t position;
61: } mvertex_t;
62:
63: #define SIDE_FRONT 0
64: #define SIDE_BACK 1
65: #define SIDE_ON 2
66:
67:
68: // plane_t structure
69: // !!! if this is changed, it must be changed in asm_i386.h too !!!
70: typedef struct mplane_s
71: {
72: vec3_t normal;
73: float dist;
74: byte type; // for texture axis selection and fast side tests
75: byte signbits; // signx + signy<<1 + signz<<1
76: byte pad[2];
77: } mplane_t;
78:
79: typedef struct texture_s
80: {
81: char name[16];
82: unsigned width, height;
83: int anim_total; // total tenths in sequence ( 0 = no)
84: int anim_min, anim_max; // time for this frame min <=time< max
85: struct texture_s *anim_next; // in the animation sequence
86: struct texture_s *alternate_anims; // bmodels in frmae 1 use these
87: unsigned offsets[MIPLEVELS]; // four mip maps stored
88: } texture_t;
89:
90:
91: #define SURF_PLANEBACK 2
92: #define SURF_DRAWSKY 4
93: #define SURF_DRAWSPRITE 8
94: #define SURF_DRAWTURB 0x10
95: #define SURF_DRAWTILED 0x20
96: #define SURF_DRAWBACKGROUND 0x40
97:
98: // !!! if this is changed, it must be changed in asm_draw.h too !!!
99: typedef struct
100: {
101: unsigned short v[2];
102: unsigned int cachededgeoffset;
103: } medge_t;
104:
105: typedef struct
106: {
107: float vecs[2][4];
108: float mipadjust;
109: texture_t *texture;
110: int flags;
111: } mtexinfo_t;
112:
113: typedef struct msurface_s
114: {
115: int visframe; // should be drawn when node is crossed
116:
117: int dlightframe;
118: int dlightbits;
119:
120: mplane_t *plane;
121: int flags;
122:
123: int firstedge; // look up in model->surfedges[], negative numbers
124: int numedges; // are backwards edges
125:
126: // surface generation data
127: struct surfcache_s *cachespots[MIPLEVELS];
128:
129: short texturemins[2];
130: short extents[2];
131:
132: mtexinfo_t *texinfo;
133:
134: // lighting info
135: byte styles[MAXLIGHTMAPS];
136: byte *samples; // [numstyles*surfsize]
137: } msurface_t;
138:
139: typedef struct mnode_s
140: {
141: // common with leaf
142: int contents; // 0, to differentiate from leafs
143: int visframe; // node needs to be traversed if current
144:
145: short minmaxs[6]; // for bounding box culling
146:
147: struct mnode_s *parent;
148:
149: // node specific
150: mplane_t *plane;
151: struct mnode_s *children[2];
152:
153: unsigned short firstsurface;
154: unsigned short numsurfaces;
155: } mnode_t;
156:
157:
158:
159: typedef struct mleaf_s
160: {
161: // common with node
162: int contents; // wil be a negative contents number
163: int visframe; // node needs to be traversed if current
164:
165: short minmaxs[6]; // for bounding box culling
166:
167: struct mnode_s *parent;
168:
169: // leaf specific
170: byte *compressed_vis;
171: struct efrag_s *efrags;
172:
173: msurface_t **firstmarksurface;
174: int nummarksurfaces;
175: int key; // BSP sequence number for leaf's contents
176: byte ambient_sound_level[NUM_AMBIENTS];
177: } mleaf_t;
178:
179: // !!! if this is changed, it must be changed in asm_i386.h too !!!
180: typedef struct
181: {
182: dclipnode_t *clipnodes;
183: mplane_t *planes;
184: int firstclipnode;
185: int lastclipnode;
186: vec3_t clip_mins;
187: vec3_t clip_maxs;
188: } hull_t;
189:
190: /*
191: ==============================================================================
192:
193: SPRITE MODELS
194:
195: ==============================================================================
196: */
197:
198:
199: // FIXME: shorten these?
200: typedef struct mspriteframe_s
201: {
202: int width;
203: int height;
204: void *pcachespot; // remove?
205: float up, down, left, right;
206: byte pixels[4];
207: } mspriteframe_t;
208:
209: typedef struct
210: {
211: int numframes;
212: float *intervals;
213: mspriteframe_t *frames[1];
214: } mspritegroup_t;
215:
216: typedef struct
217: {
218: spriteframetype_t type;
219: mspriteframe_t *frameptr;
220: } mspriteframedesc_t;
221:
222: typedef struct
223: {
224: int type;
225: int maxwidth;
226: int maxheight;
227: int numframes;
228: float beamlength; // remove?
229: void *cachespot; // remove?
230: mspriteframedesc_t frames[1];
231: } msprite_t;
232:
233:
234: /*
235: ==============================================================================
236:
237: ALIAS MODELS
238:
239: Alias models are position independent, so the cache manager can move them.
240: ==============================================================================
241: */
242:
243: typedef struct
244: {
245: aliasframetype_t type;
246: trivertx_t bboxmin;
247: trivertx_t bboxmax;
248: int frame;
249: char name[16];
250: } maliasframedesc_t;
251:
252: typedef struct
253: {
254: aliasskintype_t type;
255: void *pcachespot;
256: int skin;
257: } maliasskindesc_t;
258:
259: typedef struct
260: {
261: trivertx_t bboxmin;
262: trivertx_t bboxmax;
263: int frame;
264: } maliasgroupframedesc_t;
265:
266: typedef struct
267: {
268: int numframes;
269: int intervals;
270: maliasgroupframedesc_t frames[1];
271: } maliasgroup_t;
272:
273: typedef struct
274: {
275: int numskins;
276: int intervals;
277: maliasskindesc_t skindescs[1];
278: } maliasskingroup_t;
279:
280: // !!! if this is changed, it must be changed in asm_draw.h too !!!
281: typedef struct mtriangle_s {
282: int facesfront;
283: int vertindex[3];
284: } mtriangle_t;
285:
286: typedef struct {
287: int model;
288: int stverts;
289: int skindesc;
290: int triangles;
291: maliasframedesc_t frames[1];
292: } aliashdr_t;
293:
294: //===================================================================
295:
296: //
297: // Whole model
298: //
299:
300: typedef enum {mod_brush, mod_sprite, mod_alias} modtype_t;
301:
302: #define EF_ROCKET 1 // leave a trail
303: #define EF_GRENADE 2 // leave a trail
304: #define EF_GIB 4 // leave a trail
305: #define EF_ROTATE 8 // rotate (bonus items)
306: #define EF_TRACER 16 // green split trail
307: #define EF_ZOMGIB 32 // small blood trail
308: #define EF_TRACER2 64 // orange split trail + rotate
309: #define EF_TRACER3 128 // purple trail
310:
311: typedef struct model_s
312: {
313: char name[MAX_QPATH];
314: qboolean needload; // bmodels and sprites don't cache normally
315:
316: modtype_t type;
317: int numframes;
318: synctype_t synctype;
319:
320: int flags;
321:
322: //
323: // volume occupied by the model graphics
324: //
325: vec3_t mins, maxs;
326: float radius;
327:
328: //
329: // solid volume for clipping (sent from server)
330: //
331: qboolean clipbox;
332: vec3_t clipmins, clipmaxs;
333:
334: //
335: // brush model
336: //
337: int firstmodelsurface, nummodelsurfaces;
338:
339: int numsubmodels;
340: dmodel_t *submodels;
341:
342: int numplanes;
343: mplane_t *planes;
344:
345: int numleafs; // number of visible leafs, not counting 0
346: mleaf_t *leafs;
347:
348: int numvertexes;
349: mvertex_t *vertexes;
350:
351: int numedges;
352: medge_t *edges;
353:
354: int numnodes;
355: mnode_t *nodes;
356:
357: int numtexinfo;
358: mtexinfo_t *texinfo;
359:
360: int numsurfaces;
361: msurface_t *surfaces;
362:
363: int numsurfedges;
364: int *surfedges;
365:
366: int numclipnodes;
367: dclipnode_t *clipnodes;
368:
369: int nummarksurfaces;
370: msurface_t **marksurfaces;
371:
372: hull_t hulls[MAX_MAP_HULLS];
373:
374: int numtextures;
375: texture_t **textures;
376:
377: byte *visdata;
378: byte *lightdata;
379: char *entities;
380:
381: unsigned checksum; // for world models only
382: unsigned checksum2; // for world models only
383:
384: //
385: // additional model data
386: //
387: cache_user_t cache; // only access through Mod_Extradata
388:
389: } model_t;
390:
391: //============================================================================
392:
393: void Mod_Init (void);
394: void Mod_ClearAll (void);
395: model_t *Mod_ForName (char *name, qboolean crash);
396: void *Mod_Extradata (model_t *mod); // handles caching
397: void Mod_TouchModel (char *name);
398:
399: mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
400: byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
401:
402: #endif // __MODEL__
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.