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