]> icculus.org git repositories - divverent/darkplaces.git/blob - model_shared.h
Added lightstyle interpolation.
[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, mod_brushq2, mod_brushq3} 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 *stain; // inverse modulate with background (used for decals and such)
51         rtexture_t *merged; // original texture without glow
52         rtexture_t *base; // original texture without pants/shirt/glow
53         rtexture_t *pants; // pants only (in greyscale)
54         rtexture_t *shirt; // shirt only (in greyscale)
55         rtexture_t *nmap; // normalmap (bumpmap for dot3)
56         rtexture_t *gloss; // glossmap (for dot3)
57         rtexture_t *detail; // detail texture (silly bumps for non-dot3)
58         rtexture_t *glow; // glow only (fullbrights)
59         rtexture_t *fog; // alpha of the base texture (if not opaque)
60 }
61 skinframe_t;
62
63 #define MAX_SKINS 256
64
65 typedef struct overridetagname_s
66 {
67         char name[MAX_QPATH];
68 }
69 overridetagname_t;
70
71 // a replacement set of tag names, per skin
72 typedef struct overridetagnameset_s
73 {
74         int num_overridetagnames;
75         overridetagname_t *data_overridetagnames;
76 }
77 overridetagnameset_t;
78
79 #define SHADOWMESHVERTEXHASH 1024
80 typedef struct shadowmeshvertexhash_s
81 {
82         struct shadowmeshvertexhash_s *next;
83 }
84 shadowmeshvertexhash_t;
85
86 typedef struct shadowmesh_s
87 {
88         // next mesh in chain
89         struct shadowmesh_s *next;
90         // used for light mesh (NULL on shadow mesh)
91         rtexture_t *map_diffuse;
92         rtexture_t *map_specular;
93         rtexture_t *map_normal;
94         // buffer sizes
95         int numverts, maxverts;
96         int numtriangles, maxtriangles;
97         // used always
98         float *vertex3f;
99         // used for light mesh (NULL on shadow mesh)
100         float *svector3f;
101         float *tvector3f;
102         float *normal3f;
103         float *texcoord2f;
104         // used always
105         int *element3i;
106         // used for shadow mesh (NULL on light mesh)
107         int *neighbor3i;
108         // these are NULL after Mod_ShadowMesh_Finish is performed, only used
109         // while building meshes
110         shadowmeshvertexhash_t **vertexhashtable, *vertexhashentries;
111 }
112 shadowmesh_t;
113
114
115 #include "matrixlib.h"
116
117 #include "model_brush.h"
118 #include "model_sprite.h"
119 #include "model_alias.h"
120
121 typedef struct model_alias_s
122 {
123         // LordHavoc: Q2/ZYM model support
124         int                             aliastype;
125
126         // mdl/md2/md3 models are the same after loading
127         int                             aliasnum_meshes;
128         aliasmesh_t             *aliasdata_meshes;
129
130         int                             aliasnum_tags;
131         int                             aliasnum_tagframes;
132         aliastag_t              *aliasdata_tags;
133
134         // for Zymotic models
135         int                             zymnum_verts;
136         int                             zymnum_tris;
137         int                             zymnum_shaders;
138         int                             zymnum_bones;
139         int                             zymnum_scenes;
140         float                   *zymdata_texcoords;
141         rtexture_t              **zymdata_textures;
142         qbyte                   *zymdata_trizone;
143         zymbone_t               *zymdata_bones;
144         unsigned int    *zymdata_vertbonecounts;
145         zymvertex_t             *zymdata_verts;
146         unsigned int    *zymdata_renderlist;
147         float                   *zymdata_poses;
148 }
149 model_alias_t;
150
151 typedef struct model_sprite_s
152 {
153         int                             sprnum_type;
154         mspriteframe_t  *sprdata_frames;
155 }
156 model_sprite_t;
157
158 struct trace_s;
159
160 typedef struct model_brush_s
161 {
162         // true if this model is a HalfLife .bsp file
163         qboolean ishlbsp;
164         // string of entity definitions (.map format)
165         char *entities;
166         // number of submodels in this map (just used by server to know how many
167         // submodels to load)
168         int numsubmodels;
169
170         // pvs
171         int num_pvsclusters;
172         int num_pvsclusterbytes;
173         unsigned char *data_pvsclusters;
174         // example
175         //pvschain = model->brush.data_pvsclusters + mycluster * model->brush.num_pvsclusterbytes;
176         //if (pvschain[thatcluster >> 3] & (1 << (thatcluster & 7)))
177
178         // a mesh containing all shadow casting geometry for the whole model (including submodels), portions of this are referenced by each surface's num_firstshadowmeshtriangle 
179         shadowmesh_t *shadowmesh;
180
181         // common functions
182         int (*SuperContentsFromNativeContents)(struct model_s *model, int nativecontents);
183         int (*NativeContentsFromSuperContents)(struct model_s *model, int supercontents);
184         qbyte *(*GetPVS)(struct model_s *model, const vec3_t p);
185         int (*FatPVS)(struct model_s *model, const vec3_t org, vec_t radius, qbyte *pvsbuffer, int pvsbufferlength);
186         int (*BoxTouchingPVS)(struct model_s *model, const qbyte *pvs, const vec3_t mins, const vec3_t maxs);
187         void (*LightPoint)(struct model_s *model, const vec3_t p, vec3_t ambientcolor, vec3_t diffusecolor, vec3_t diffusenormal);
188         void (*FindNonSolidLocation)(struct model_s *model, const vec3_t in, vec3_t out, vec_t radius);
189         // these are actually only found on brushq1, but NULL is handled gracefully
190         void (*AmbientSoundLevelsForPoint)(struct model_s *model, const vec3_t p, qbyte *out, int outsize);
191         void (*RoundUpToHullSize)(struct model_s *cmodel, const vec3_t inmins, const vec3_t inmaxs, vec3_t outmins, vec3_t outmaxs);
192
193         char skybox[64];
194 }
195 model_brush_t;
196
197 typedef struct model_brushq1_s
198 {
199         // lightmap format, set to r_lightmaprgba when model is loaded
200         int                             lightmaprgba;
201
202         dmodel_t                *submodels;
203
204         int                             numplanes;
205         mplane_t                *planes;
206
207         // number of actual leafs (including 0 which is solid)
208         int                             num_leafs;
209         // visible leafs, not counting 0 (solid)
210         int                             num_visleafs;
211         mleaf_t                 *data_leafs;
212
213         int                             numvertexes;
214         mvertex_t               *vertexes;
215
216         int                             numedges;
217         medge_t                 *edges;
218
219         int                             numnodes;
220         mnode_t                 *nodes;
221
222         int                             numtexinfo;
223         mtexinfo_t              *texinfo;
224
225         int                             numsurfaces;
226         msurface_t              *surfaces;
227         int                             *surfacevisframes;
228         int                             *surfacepvsframes;
229         msurface_t              *surfacepvsnext;
230         surfmesh_t              *entiremesh;
231
232         int                             numsurfedges;
233         int                             *surfedges;
234
235         int                             numclipnodes;
236         dclipnode_t             *clipnodes;
237
238         int                             nummarksurfaces;
239         int                             *marksurfaces;
240
241         hull_t                  hulls[MAX_MAP_HULLS];
242
243         int                             numtextures;
244         texture_t               *textures;
245
246         int                             num_compressedpvs;
247         qbyte                   *data_compressedpvs;
248
249         int                             num_lightdata;
250         qbyte                   *lightdata;
251
252         int                             numportals;
253         mportal_t               *portals;
254
255         int                             numportalpoints;
256         mvertex_t               *portalpoints;
257
258         int                             numlights;
259         mlight_t                *lights;
260
261         // pvs visibility marking
262         mleaf_t                 *pvsviewleaf;
263         int                             pvsviewleafnovis;
264         int                             pvsframecount;
265         mleaf_t                 *pvsleafchain;
266         int                             *pvssurflist;
267         int                             pvssurflistlength;
268         // these get rebuilt as the player moves around if this is the world,
269         // otherwise they are left alone (no pvs for bmodels)
270         msurface_t              ***pvstexturechains;
271         msurface_t              **pvstexturechainsbuffer;
272         int                             *pvstexturechainslength;
273
274         // lightmap update chains for light styles
275         int                             light_styles;
276         qbyte                   *light_style;
277         int                             *light_stylevalue;
278         msurface_t              ***light_styleupdatechains;
279         msurface_t              **light_styleupdatechainsbuffer;
280
281         mleaf_t *(*PointInLeaf)(struct model_s *model, const float *p);
282         void (*BuildPVSTextureChains)(struct model_s *model);
283 }
284 model_brushq1_t;
285
286 /* MSVC can't compile empty structs, so this is commented out for now
287 typedef struct model_brushq2_s
288 {
289 }
290 model_brushq2_t;
291 */
292
293 // surfaceflags from bsp
294 #define Q3SURFACEFLAG_NODAMAGE 1
295 #define Q3SURFACEFLAG_SLICK 2
296 #define Q3SURFACEFLAG_SKY 4
297 #define Q3SURFACEFLAG_LADDER 8
298 #define Q3SURFACEFLAG_NOIMPACT 16
299 #define Q3SURFACEFLAG_NOMARKS 32
300 #define Q3SURFACEFLAG_FLESH 64
301 #define Q3SURFACEFLAG_NODRAW 128
302 #define Q3SURFACEFLAG_HINT 256
303 #define Q3SURFACEFLAG_SKIP 512
304 #define Q3SURFACEFLAG_NOLIGHTMAP 1024
305 #define Q3SURFACEFLAG_POINTLIGHT 2048
306 #define Q3SURFACEFLAG_METALSTEPS 4096
307 #define Q3SURFACEFLAG_NOSTEPS 8192
308 #define Q3SURFACEFLAG_NONSOLID 16384
309 #define Q3SURFACEFLAG_LIGHTFILTER 32768
310 #define Q3SURFACEFLAG_ALPHASHADOW 65536
311 #define Q3SURFACEFLAG_NODLIGHT 131072
312 #define Q3SURFACEFLAG_DUST 262144
313
314 // surfaceparms from shaders
315 #define Q3SURFACEPARM_ALPHASHADOW 1
316 #define Q3SURFACEPARM_AREAPORTAL 2
317 #define Q3SURFACEPARM_CLUSTERPORTAL 4
318 #define Q3SURFACEPARM_DETAIL 8
319 #define Q3SURFACEPARM_DONOTENTER 16
320 #define Q3SURFACEPARM_FOG 32
321 #define Q3SURFACEPARM_LAVA 64
322 #define Q3SURFACEPARM_LIGHTFILTER 128
323 #define Q3SURFACEPARM_METALSTEPS 256
324 #define Q3SURFACEPARM_NODAMAGE 512
325 #define Q3SURFACEPARM_NODLIGHT 1024
326 #define Q3SURFACEPARM_NODRAW 2048
327 #define Q3SURFACEPARM_NODROP 4096
328 #define Q3SURFACEPARM_NOIMPACT 8192
329 #define Q3SURFACEPARM_NOLIGHTMAP 16384
330 #define Q3SURFACEPARM_NOMARKS 32768
331 #define Q3SURFACEPARM_NOMIPMAPS 65536
332 #define Q3SURFACEPARM_NONSOLID 131072
333 #define Q3SURFACEPARM_ORIGIN 262144
334 #define Q3SURFACEPARM_PLAYERCLIP 524288
335 #define Q3SURFACEPARM_SKY 1048576
336 #define Q3SURFACEPARM_SLICK 2197152
337 #define Q3SURFACEPARM_SLIME 4194304
338 #define Q3SURFACEPARM_STRUCTURAL 8388608
339 #define Q3SURFACEPARM_TRANS 16777216
340 #define Q3SURFACEPARM_WATER 33554432
341
342 typedef struct q3mtexture_s
343 {
344         char name[Q3PATHLENGTH];
345         int surfaceflags;
346         int nativecontents;
347         int supercontents;
348         int surfaceparms;
349
350         int number;
351         skinframe_t skin;
352 }
353 q3mtexture_t;
354
355 typedef struct q3mnode_s
356 {
357         //this part shared between node and leaf
358         struct mplane_s *plane; // != NULL
359         struct q3mnode_s *parent;
360         vec3_t mins;
361         vec3_t maxs;
362         // this part unique to nodes
363         struct q3mnode_s *children[2];
364 }
365 q3mnode_t;
366
367 typedef struct q3mleaf_s
368 {
369         //this part shared between node and leaf
370         struct mplane_s *plane; // == NULL
371         struct q3mnode_s *parent;
372         vec3_t mins;
373         vec3_t maxs;
374         // this part unique to leafs
375         int clusterindex;
376         int areaindex;
377         int numleaffaces;
378         struct q3mface_s **firstleafface;
379         int numleafbrushes;
380         struct q3mbrush_s **firstleafbrush;
381 }
382 q3mleaf_t;
383
384 typedef struct q3mmodel_s
385 {
386         vec3_t mins;
387         vec3_t maxs;
388         int numfaces;
389         struct q3mface_s *firstface;
390         int numbrushes;
391         struct q3mbrush_s *firstbrush;
392 }
393 q3mmodel_t;
394
395 typedef struct q3mbrush_s
396 {
397         struct colbrushf_s *colbrushf;
398         int numbrushsides;
399         struct q3mbrushside_s *firstbrushside;
400         struct q3mtexture_s *texture;
401 }
402 q3mbrush_t;
403
404 typedef struct q3mbrushside_s
405 {
406         struct mplane_s *plane;
407         struct q3mtexture_s *texture;
408 }
409 q3mbrushside_t;
410
411 typedef struct q3meffect_s
412 {
413         char shadername[Q3PATHLENGTH];
414         struct q3mbrush_s *brush;
415         int unknown; // 5 or -1
416 }
417 q3meffect_t;
418
419 typedef struct q3mface_s
420 {
421         struct q3mtexture_s *texture;
422         struct q3meffect_s *effect;
423         rtexture_t *lightmaptexture;
424         int collisions; // performs per triangle collisions on this surface
425         int collisionmarkframe; // don't collide twice in one trace
426         int type;
427         int firstvertex;
428         int firstelement;
429         int patchsize[2];
430         // used for processing
431         int markframe;
432         // (world only) visframe == r_framecount means it is visible this frame
433         int visframe;
434         // bounding box for culling
435         float mins[3];
436         float maxs[3];
437
438         int num_vertices;
439         int num_triangles;
440         float *data_vertex3f;
441         float *data_texcoordtexture2f;
442         float *data_texcoordlightmap2f;
443         float *data_svector3f;
444         float *data_tvector3f;
445         float *data_normal3f;
446         float *data_color4f;
447         int *data_element3i;
448         int *data_neighbor3i;
449
450         int num_collisionvertices;
451         int num_collisiontriangles;
452         float *data_collisionvertex3f;
453         int *data_collisionelement3i;
454
455         // index into model->brush.shadowmesh
456         int num_firstshadowmeshtriangle;
457         
458         // used for shadow volume generation
459         int shadowmark;
460
461         // temporary use by light processing
462         int lighttemp_castshadow;
463 }
464 q3msurface_t;
465
466 typedef struct model_brushq3_s
467 {
468         // if non-zero this is a submodel
469         // (this is the number of the submodel, an index into data_models)
470         int submodel;
471
472         int num_textures;
473         q3mtexture_t *data_textures;
474
475         int num_planes;
476         mplane_t *data_planes;
477
478         int num_nodes;
479         q3mnode_t *data_nodes;
480
481         int num_leafs;
482         q3mleaf_t *data_leafs;
483
484         int num_leafbrushes;
485         q3mbrush_t **data_leafbrushes;
486
487         int num_leaffaces;
488         q3msurface_t **data_leaffaces;
489
490         int num_models;
491         q3mmodel_t *data_models;
492         // each submodel gets its own model struct so this is different for each.
493         q3mmodel_t *data_thismodel;
494
495         int num_brushes;
496         q3mbrush_t *data_brushes;
497
498         int num_brushsides;
499         q3mbrushside_t *data_brushsides;
500
501         int num_vertices;
502         float *data_vertex3f;
503         float *data_texcoordtexture2f;
504         float *data_texcoordlightmap2f;
505         float *data_svector3f;
506         float *data_tvector3f;
507         float *data_normal3f;
508         float *data_color4f;
509
510         int num_triangles;
511         int *data_element3i;
512         int *data_neighbor3i;
513
514         int num_effects;
515         q3meffect_t *data_effects;
516
517         int num_faces;
518         q3msurface_t *data_faces;
519
520         // lightmap textures
521         int num_lightmaps;
522         rtexture_t **data_lightmaps;
523
524         // voxel light data with directional shading
525         int num_lightgrid;
526         q3dlightgrid_t *data_lightgrid;
527         // size of each cell (may vary by map, typically 64 64 128)
528         float num_lightgrid_cellsize[3];
529         // 1.0 / num_lightgrid_cellsize
530         float num_lightgrid_scale[3];
531         // dimensions of the world model in lightgrid cells
532         int num_lightgrid_imins[3];
533         int num_lightgrid_imaxs[3];
534         int num_lightgrid_isize[3];
535         // indexing/clamping
536         int num_lightgrid_dimensions[3];
537         // transform modelspace coordinates to lightgrid index
538         matrix4x4_t num_lightgrid_indexfromworld;
539 }
540 model_brushq3_t;
541
542 typedef struct model_s
543 {
544         // name and path of model, for example "progs/player.mdl"
545         char                    name[MAX_QPATH];
546         // model needs to be loaded if this is true
547         qboolean                needload;
548         // set if the model is used in current map, models which are not, are purged
549         qboolean                used;
550         // true if this is the world model (I.E. defines what sky to use, and may contain submodels)
551         qboolean                isworldmodel;
552         // CRC of the file this model was loaded from, to reload if changed
553         unsigned int    crc;
554         // mod_brush, mod_alias, mod_sprite
555         modtype_t               type;
556         // memory pool for allocations
557         mempool_t               *mempool;
558         // all models use textures...
559         rtexturepool_t  *texturepool;
560         // flags from the model file
561         int                             flags;
562         // engine calculated flags, ones that can not be set in the file
563         int                             flags2;
564         // LordHavoc: if true (normally only for sprites) the model/sprite/bmodel is always rendered fullbright
565         int                             fullbright;
566         // number of QC accessible frame(group)s in the model
567         int                             numframes;
568         // number of QC accessible skin(group)s in the model
569         int                             numskins;
570         // whether to randomize animated framegroups
571         synctype_t              synctype;
572         // bounding box at angles '0 0 0'
573         vec3_t                  normalmins, normalmaxs;
574         // bounding box if yaw angle is not 0, but pitch and roll are
575         vec3_t                  yawmins, yawmaxs;
576         // bounding box if pitch or roll are used
577         vec3_t                  rotatedmins, rotatedmaxs;
578         // sphere radius, usable at any angles
579         float                   radius;
580         // squared sphere radius for easier comparisons
581         float                   radius2;
582         // skin animation info
583         animscene_t             *skinscenes; // [numskins]
584         // skin animation info
585         animscene_t             *animscenes; // [numframes]
586         // range of surface numbers in this (sub)model
587         int                             firstmodelsurface;
588         int                             nummodelsurfaces;
589         // list of surface numbers in this (sub)model
590         int                             *surfacelist;
591         // draw the model's sky polygons (only used by brush models)
592         void(*DrawSky)(struct entity_render_s *ent);
593         // draw the model using lightmap/dlight shading
594         void(*Draw)(struct entity_render_s *ent);
595         // gathers info on which clusters and surfaces are lit by light, as well as calculating a bounding box
596         void(*GetLightInfo)(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outclusterlist, qbyte *outclusterpvs, int *outnumclusterspointer, int *outsurfacelist, qbyte *outsurfacepvs, int *outnumsurfacespointer);
597         // draw a shadow volume for the model based on light source
598         void(*DrawShadowVolume)(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius, int numsurfaces, const int *surfacelist);
599         // draw the lighting on a model (through stencil)
600         void(*DrawLight)(struct entity_render_s *ent, vec3_t relativelightorigin, vec3_t relativeeyeorigin, float lightradius, float *lightcolor, const matrix4x4_t *matrix_modeltolight, const matrix4x4_t *matrix_modeltoattenuationxyz, const matrix4x4_t *matrix_modeltoattenuationz, rtexture_t *lightcubemap, int numsurfaces, const int *surfacelist);
601         // trace a box against this model
602         void (*TraceBox)(struct model_s *model, int frame, struct trace_s *trace, const vec3_t boxstartmins, const vec3_t boxstartmaxs, const vec3_t boxendmins, const vec3_t boxendmaxs, int hitsupercontentsmask);
603         // fields belonging to each type of model
604         model_alias_t   alias;
605         model_sprite_t  sprite;
606         model_brush_t   brush;
607         model_brushq1_t brushq1;
608         /* MSVC can't handle an empty struct, so this is commented out for now
609         model_brushq2_t brushq2;
610         */
611         model_brushq3_t brushq3;
612         // skin files can have different tags for each skin
613         overridetagnameset_t    *data_overridetagnamesforskin;
614         // flags this model for offseting sounds to the model center (used by brush models)
615         int soundfromcenter;
616 }
617 model_t;
618
619 //============================================================================
620
621 // this can be used for anything without a valid texture
622 extern rtexture_t *r_notexture;
623 #define NUM_DETAILTEXTURES 1
624 extern rtexture_t *mod_shared_detailtextures[NUM_DETAILTEXTURES];
625 // every texture must be in a pool...
626 extern rtexturepool_t *mod_shared_texturepool;
627
628 extern rtexture_t *mod_shared_distorttexture[64];
629
630 // model loading
631 extern model_t *loadmodel;
632 extern qbyte *mod_base;
633 // sky/water subdivision
634 //extern cvar_t gl_subdivide_size;
635 // texture fullbrights
636 extern cvar_t r_fullbrights;
637
638 void Mod_Init (void);
639 void Mod_CheckLoaded (model_t *mod);
640 void Mod_ClearAll (void);
641 model_t *Mod_FindName (const char *name);
642 model_t *Mod_ForName (const char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel);
643 void Mod_TouchModel (const char *name);
644 void Mod_UnloadModel (model_t *mod);
645
646 void Mod_ClearUsed(void);
647 void Mod_PurgeUnused(void);
648 void Mod_LoadModels(void);
649
650 extern model_t *loadmodel;
651 extern char loadname[32];       // for hunk tags
652
653 void Mod_BuildTriangleNeighbors(int *neighbors, const int *elements, int numtriangles);
654 void Mod_ValidateElements(const int *elements, int numtriangles, int numverts, const char *filename, int fileline);
655 void Mod_BuildTextureVectorsAndNormals(int numverts, int numtriangles, const float *vertex, const float *texcoord, const int *elements, float *svectors, float *tvectors, float *normals);
656
657 shadowmesh_t *Mod_ShadowMesh_Alloc(mempool_t *mempool, int maxverts, int maxtriangles, rtexture_t *map_diffuse, rtexture_t *map_specular, rtexture_t *map_normal, int light, int neighbors, int expandable);
658 shadowmesh_t *Mod_ShadowMesh_ReAlloc(mempool_t *mempool, shadowmesh_t *oldmesh, int light, int neighbors);
659 int Mod_ShadowMesh_AddVertex(shadowmesh_t *mesh, float *vertex14f);
660 void Mod_ShadowMesh_AddTriangle(mempool_t *mempool, shadowmesh_t *mesh, rtexture_t *map_diffuse, rtexture_t *map_specular, rtexture_t *map_normal, float *vertex14f);
661 void Mod_ShadowMesh_AddMesh(mempool_t *mempool, shadowmesh_t *mesh, rtexture_t *map_diffuse, rtexture_t *map_specular, rtexture_t *map_normal, const float *vertex3f, const float *svector3f, const float *tvector3f, const float *normal3f, const float *texcoord2f, int numtris, const int *element3i);
662 shadowmesh_t *Mod_ShadowMesh_Begin(mempool_t *mempool, int maxverts, int maxtriangles, rtexture_t *map_diffuse, rtexture_t *map_specular, rtexture_t *map_normal, int light, int neighbors, int expandable);
663 shadowmesh_t *Mod_ShadowMesh_Finish(mempool_t *mempool, shadowmesh_t *firstmesh, int light, int neighbors);
664 void Mod_ShadowMesh_CalcBBox(shadowmesh_t *firstmesh, vec3_t mins, vec3_t maxs, vec3_t center, float *radius);
665 void Mod_ShadowMesh_Free(shadowmesh_t *mesh);
666
667 int Mod_LoadSkinFrame(skinframe_t *skinframe, char *basename, int textureflags, int loadpantsandshirt, int usedetailtexture, int loadglowtexture);
668 int Mod_LoadSkinFrame_Internal(skinframe_t *skinframe, char *basename, int textureflags, int loadpantsandshirt, int usedetailtexture, int loadglowtexture, qbyte *skindata, int width, int height);
669
670 // used for talking to the QuakeC mainly
671 int Mod_Q1BSP_NativeContentsFromSuperContents(struct model_s *model, int supercontents);
672 int Mod_Q1BSP_SuperContentsFromNativeContents(struct model_s *model, int nativecontents);
673
674 extern cvar_t r_mipskins;
675
676 typedef struct skinfileitem_s
677 {
678         struct skinfileitem_s *next;
679         char name[MAX_QPATH];
680         char replacement[MAX_QPATH];
681 }
682 skinfileitem_t;
683
684 typedef struct skinfile_s
685 {
686         struct skinfile_s *next;
687         skinfileitem_t *items;
688 }
689 skinfile_t;
690
691 skinfile_t *Mod_LoadSkinFiles(void);
692 void Mod_FreeSkinFiles(skinfile_t *skinfile);
693 int Mod_CountSkinFiles(skinfile_t *skinfile);
694
695 int Mod_RemoveDegenerateTriangles(int numtriangles, const int *inelement3i, int *outelement3i, const float *vertex3f);
696
697 #endif  // __MODEL__
698