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