]> icculus.org git repositories - divverent/darkplaces.git/blob - model_shared.h
reenabled some invisible entity checking (probably no difference)
[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 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 #define MAX_SKINS 256
49
50
51 #include "model_brush.h"
52 #include "model_sprite.h"
53 #include "model_alias.h"
54
55 #define MODF_TRANSPARENT 1
56
57 typedef struct model_s
58 {
59         char            name[MAX_QPATH];
60         qboolean        needload;               // bmodels don't cache normally
61
62         modtype_t       type;
63         int                     aliastype; // LordHavoc: Q2 model support
64         int                     fullbright; // LordHavoc: if true (normally only for sprites) the model/sprite/bmodel is always rendered fullbright
65         int                     numframes;
66         synctype_t      synctype;
67
68         int                     flags;
69         int                     flags2; // engine calculated flags, ones that can not be set in the file
70
71 // volume occupied by the model graphics
72         vec3_t          mins, maxs;
73         float           radius;
74
75 // solid volume for clipping
76         qboolean        clipbox;
77         vec3_t          clipmins, clipmaxs;
78
79 // brush model
80         int                     firstmodelsurface, nummodelsurfaces;
81
82         int                     numsubmodels;
83         dmodel_t        *submodels;
84
85         int                     numplanes;
86         mplane_t        *planes;
87
88         int                     numleafs;               // number of visible leafs, not counting 0
89         mleaf_t         *leafs;
90
91         int                     numvertexes;
92         mvertex_t       *vertexes;
93
94         int                     numedges;
95         medge_t         *edges;
96
97         int                     numnodes;
98         mnode_t         *nodes;
99
100         int                     numtexinfo;
101         mtexinfo_t      *texinfo;
102
103         int                     numsurfaces;
104         msurface_t      *surfaces;
105
106         int                     numsurfedges;
107         int                     *surfedges;
108
109         int                     numclipnodes;
110         dclipnode_t     *clipnodes;
111
112         int                     nummarksurfaces;
113         msurface_t      **marksurfaces;
114
115         hull_t          hulls[MAX_MAP_HULLS];
116
117         int                     numtextures;
118         texture_t       **textures;
119
120         byte            *visdata;
121         byte            *lightdata;
122         char            *entities;
123
124         int                     numportals;
125         mportal_t       *portals;
126
127         int                     numportalpoints;
128         mvertex_t       *portalpoints;
129
130         // LordHavoc: useful for sprites and models
131         int                     numtris;
132         int                     numskins;
133         int                     skinanimrange[MAX_SKINS*2]; // array of start and length pairs
134         rtexture_t      *skinanim[MAX_SKINS*5]; // texture numbers for each frame (indexed by animrange), note: normal pants shirt glow body (normal contains no shirt/pants/glow colors and body is normal + pants + shirt, but not glow)
135         int                     ofs_scenes; // offset from Mod_ExtraData(model) memory to array of animscene_t structs
136         // these are used simply to simplify model/sprite/whatever processing and are specific to each type
137         int                     ofs_frames; // offset from Mod_ExtraData(model) memory to array of model specific frame structs
138         int                     framesize; // size of model specific frame structs
139
140 // additional model data
141         cache_user_t    cache;          // only access through Mod_Extradata
142         int                     cachesize;              // size of cached data (zero if not cached)
143
144 } model_t;
145
146 //============================================================================
147
148 // used to avoid setting up submodels in non-world bmodels
149 extern qboolean isworldmodel;
150 // model loading
151 extern model_t *loadmodel;
152 extern byte     *mod_base;
153 // sky/water subdivision
154 extern cvar_t gl_subdivide_size;
155 // texture fullbrights
156 extern cvar_t r_fullbrights;
157
158 void Mod_Init (void);
159 void Mod_ClearAll (void);
160 model_t *Mod_ForName (char *name, qboolean crash);
161 void *Mod_Extradata (model_t *mod);     // handles caching
162 void Mod_TouchModel (char *name);
163
164 mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
165 byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
166
167 extern model_t *loadmodel;
168 extern char loadname[32];       // for hunk tags
169
170 extern model_t *Mod_LoadModel (model_t *mod, qboolean crash);
171
172 extern float RadiusFromBounds (vec3_t mins, vec3_t maxs);
173 extern model_t *Mod_FindName (char *name);
174
175 #endif  // __MODEL__