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