]> icculus.org git repositories - divverent/darkplaces.git/blob - model_shared.h
light only the front faces, cuts down on noticable visdata anomolies
[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_brush, mod_sprite, mod_alias} modtype_t;
37
38 #include "model_brush.h"
39 #include "model_sprite.h"
40 #include "model_alias.h"
41
42 typedef struct model_s
43 {
44         char            name[MAX_QPATH];
45         qboolean        needload;               // bmodels and sprites don't cache normally
46
47         modtype_t       type;
48         int                     aliastype; // LordHavoc: Q2 model support
49         int                     fullbright; // LordHavoc: if true (normally only for sprites) the model/sprite/bmodel is always rendered fullbright
50         int                     numframes;
51         synctype_t      synctype;
52         
53         int                     flags;
54
55 // volume occupied by the model graphics
56         vec3_t          mins, maxs;
57         float           radius;
58
59 // solid volume for clipping 
60         qboolean        clipbox;
61         vec3_t          clipmins, clipmaxs;
62
63 // brush model
64         int                     firstmodelsurface, nummodelsurfaces;
65
66         int                     numsubmodels;
67         dmodel_t        *submodels;
68
69         int                     numplanes;
70         mplane_t        *planes;
71
72         int                     numleafs;               // number of visible leafs, not counting 0
73         mleaf_t         *leafs;
74
75         int                     numvertexes;
76         mvertex_t       *vertexes;
77
78         int                     numedges;
79         medge_t         *edges;
80
81         int                     numnodes;
82         mnode_t         *nodes;
83
84         int                     numtexinfo;
85         mtexinfo_t      *texinfo;
86
87         int                     numsurfaces;
88         msurface_t      *surfaces;
89
90         int                     numsurfedges;
91         int                     *surfedges;
92
93         int                     numclipnodes;
94         dclipnode_t     *clipnodes;
95
96         int                     nummarksurfaces;
97         msurface_t      **marksurfaces;
98
99         hull_t          hulls[MAX_MAP_HULLS];
100
101         int                     numtextures;
102         texture_t       **textures;
103
104         byte            *visdata;
105         byte            *lightdata;
106         char            *entities;
107
108         // LordHavoc: useful for sprites and models
109         int                     numtris;
110         int                     numskins;
111         int                     skinanimrange[1024]; // array of start and length pairs, note: offset from ->cache.data
112         int                     skinanim[1024*5]; // texture numbers for each frame (indexed by animrange), note: offset from ->cache.data, second note: normal pants shirt glow body (normal contains no shirt/pants/glow colors and body is normal + pants + shirt, but not glow)
113
114 // additional model data
115         cache_user_t    cache;          // only access through Mod_Extradata
116
117 } model_t;
118
119 //============================================================================
120
121 void    Mod_Init (void);
122 void    Mod_ClearAll (void);
123 model_t *Mod_ForName (char *name, qboolean crash);
124 void    *Mod_Extradata (model_t *mod);  // handles caching
125 void    Mod_TouchModel (char *name);
126
127 mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
128 byte    *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
129
130 extern model_t  *loadmodel;
131 extern char     loadname[32];   // for hunk tags
132
133 extern model_t *Mod_LoadModel (model_t *mod, qboolean crash);
134
135 extern float RadiusFromBounds (vec3_t mins, vec3_t maxs);
136 extern model_t *Mod_FindName (char *name);
137 #endif  // __MODEL__