icculus quake2 doxygen  1.0 dev
gl_model.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 1997-2001 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 /*
22 
23 d*_t structures are on-disk representations
24 m*_t structures are in-memory
25 
26 */
27 
28 /*
29 ==============================================================================
30 
31 BRUSH MODELS
32 
33 ==============================================================================
34 */
35 
36 
37 //
38 // in memory representation
39 //
40 // !!! if this is changed, it must be changed in asm_draw.h too !!!
41 typedef struct
42 {
43  vec3_t position;
44 } mvertex_t;
45 
46 typedef struct
47 {
49  vec3_t origin; // for sounds or lights
50  float radius;
51  int headnode;
52  int visleafs; // not including the solid leaf 0
53  int firstface, numfaces;
54 } mmodel_t;
55 
56 
57 #define SIDE_FRONT 0
58 #define SIDE_BACK 1
59 #define SIDE_ON 2
60 
61 
62 #define SURF_PLANEBACK 2
63 #define SURF_DRAWSKY 4
64 #define SURF_DRAWTURB 0x10
65 #define SURF_DRAWBACKGROUND 0x40
66 #define SURF_UNDERWATER 0x80
67 
68 // !!! if this is changed, it must be changed in asm_draw.h too !!!
69 typedef struct
70 {
71  unsigned short v[2];
72  unsigned int cachededgeoffset;
73 } medge_t;
74 
75 typedef struct mtexinfo_s
76 {
77  float vecs[2][4];
78  int flags;
79  int numframes;
80  struct mtexinfo_s *next; // animation chain
81  image_t *image;
82 } mtexinfo_t;
83 
84 #define VERTEXSIZE 7
85 
86 typedef struct glpoly_s
87 {
88  struct glpoly_s *next;
89  struct glpoly_s *chain;
90  int numverts;
91  int flags; // for SURF_UNDERWATER (not needed anymore?)
92  float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
93 } glpoly_t;
94 
95 typedef struct msurface_s
96 {
97  int visframe; // should be drawn when node is crossed
98 
100  int flags;
101 
102  int firstedge; // look up in model->surfedges[], negative numbers
103  int numedges; // are backwards edges
104 
105  short texturemins[2];
106  short extents[2];
107 
108  int light_s, light_t; // gl lightmap coordinates
109  int dlight_s, dlight_t; // gl lightmap coordinates for dynamic lightmaps
110 
111  glpoly_t *polys; // multiple if warped
114 
116 
117 // lighting info
118  int dlightframe;
119  int dlightbits;
120 
122  byte styles[MAXLIGHTMAPS];
123  float cached_light[MAXLIGHTMAPS]; // values currently used in lightmap
124  byte *samples; // [numstyles*surfsize]
125 } msurface_t;
126 
127 typedef struct mnode_s
128 {
129 // common with leaf
130  int contents; // -1, to differentiate from leafs
131  int visframe; // node needs to be traversed if current
132 
133  float minmaxs[6]; // for bounding box culling
134 
135  struct mnode_s *parent;
136 
137 // node specific
139  struct mnode_s *children[2];
140 
141  unsigned short firstsurface;
142  unsigned short numsurfaces;
143 } mnode_t;
144 
145 
146 
147 typedef struct mleaf_s
148 {
149 // common with node
150  int contents; // wil be a negative contents number
151  int visframe; // node needs to be traversed if current
152 
153  float minmaxs[6]; // for bounding box culling
154 
155  struct mnode_s *parent;
156 
157 // leaf specific
158  int cluster;
159  int area;
160 
162  int nummarksurfaces;
163 } mleaf_t;
164 
165 
166 //===================================================================
167 
168 //
169 // Whole model
170 //
171 
173 
174 typedef struct model_s
175 {
176  char name[MAX_QPATH];
177 
179 
180  modtype_t type;
181  int numframes;
182 
183  int flags;
184 
185 //
186 // volume occupied by the model graphics
187 //
188  vec3_t mins, maxs;
189  float radius;
190 
191 //
192 // solid volume for clipping
193 //
196 
197 //
198 // brush model
199 //
201  int lightmap; // only for submodels
202 
203  int numsubmodels;
205 
206  int numplanes;
208 
209  int numleafs; // number of visible leafs, not counting 0
210  mleaf_t *leafs;
211 
212  int numvertexes;
214 
215  int numedges;
216  medge_t *edges;
217 
218  int numnodes;
219  int firstnode;
220  mnode_t *nodes;
221 
222  int numtexinfo;
224 
225  int numsurfaces;
227 
228  int numsurfedges;
229  int *surfedges;
230 
231  int nummarksurfaces;
233 
234  dvis_t *vis;
235 
236  byte *lightdata;
237 
238  // for alias models and skins
240 
241  int extradatasize;
242  void *extradata;
243 } model_t;
244 
245 //============================================================================
246 
247 void Mod_Init (void);
248 void Mod_ClearAll (void);
249 model_t *Mod_ForName (char *name, qboolean crash);
250 mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
251 byte *Mod_ClusterPVS (int cluster, model_t *model);
252 
253 void Mod_Modellist_f (void);
254 
255 void *Hunk_Begin (int maxsize);
256 void *Hunk_Alloc (int size);
257 int Hunk_End (void);
258 void Hunk_Free (void *base);
259 
260 void Mod_FreeAll (void);
261 void Mod_Free (model_t *mod);
model_s::numvertexes
int numvertexes
Definition: r_model.h:207
model_s::clipmins
vec3_t clipmins
Definition: r_model.h:191
msurface_s::dlight_s
int dlight_s
Definition: gl_model.h:109
Mod_Init
void Mod_Init(void)
Definition: r_model.c:78
msurface_s::styles
byte styles[MAXLIGHTMAPS]
Definition: r_model.h:115
MAX_QPATH
#define MAX_QPATH
Definition: q_shared.h:73
mtexinfo_s::numframes
int numframes
Definition: r_model.h:89
mleaf_s::area
int area
Definition: r_model.h:155
model_s::numplanes
int numplanes
Definition: r_model.h:201
mleaf_t
struct mleaf_s mleaf_t
model_s::vis
dvis_t * vis
Definition: r_model.h:229
mvertex_t
Definition: r_model.h:45
model_s::nummodelsurfaces
int nummodelsurfaces
Definition: r_model.h:196
mmodel_t::numfaces
int numfaces
Definition: gl_model.h:53
msurface_s::light_t
int light_t
Definition: gl_model.h:108
model_s::planes
cplane_t * planes
Definition: gl_model.h:207
v
GLdouble v
Definition: qgl_win.c:143
Mod_Modellist_f
void Mod_Modellist_f(void)
Definition: r_model.c:55
model_s::clipmaxs
vec3_t clipmaxs
Definition: r_model.h:191
mmodel_t::visleafs
int visleafs
Definition: gl_model.h:52
glpoly_s::verts
float verts[4][VERTEXSIZE]
Definition: gl_model.h:92
model_s::flags
int flags
Definition: r_model.h:180
model_s::edges
medge_t * edges
Definition: r_model.h:211
msurface_s::dlight_t
int dlight_t
Definition: gl_model.h:109
mtexinfo_s
Definition: r_model.h:83
Mod_ForName
model_t * Mod_ForName(char *name, qboolean crash)
Definition: r_model.c:90
mnode_s::visframe
int visframe
Definition: r_model.h:127
VERTEXSIZE
#define VERTEXSIZE
Definition: gl_model.h:84
qboolean
qboolean
Definition: q_shared.h:56
msurface_s::numedges
int numedges
Definition: r_model.h:104
msurface_s::visframe
int visframe
Definition: r_model.h:95
msurface_s::dlightframe
int dlightframe
Definition: r_model.h:97
model_s::firstnode
int firstnode
Definition: r_model.h:214
mleaf_s::visframe
int visframe
Definition: r_model.h:147
mnode_s::parent
struct mnode_s * parent
Definition: r_model.h:131
mnode_s
Definition: r_model.h:123
mod_alias
@ mod_alias
Definition: gl_model.h:172
model_s
Definition: r_model.h:171
glpoly_s::next
struct glpoly_s * next
Definition: gl_model.h:88
mleaf_s::firstmarksurface
msurface_t ** firstmarksurface
Definition: r_model.h:157
msurface_t
struct msurface_s msurface_t
dvis_t
Definition: qfiles.h:463
model_s::lightmap
int lightmap
Definition: gl_model.h:201
mod_bad
@ mod_bad
Definition: gl_model.h:172
model_s::marksurfaces
msurface_t ** marksurfaces
Definition: r_model.h:227
msurface_s::samples
byte * samples
Definition: r_model.h:116
mmodel_t
Definition: gl_model.h:46
mnode_s::plane
cplane_t * plane
Definition: gl_model.h:138
Mod_ClearAll
void Mod_ClearAll(void)
mnode_s::children
struct mnode_s * children[2]
Definition: r_model.h:135
mleaf_s::contents
int contents
Definition: r_model.h:146
Hunk_Free
void Hunk_Free(void *base)
Definition: q_shwin.c:99
msurface_s::extents
short extents[2]
Definition: r_model.h:110
modtype_t
modtype_t
Definition: r_model.h:169
mleaf_s
Definition: r_model.h:143
model_s::extradata
void * extradata
Definition: r_model.h:235
msurface_s::plane
cplane_t * plane
Definition: gl_model.h:99
model_s::clipbox
qboolean clipbox
Definition: r_model.h:190
model_s::numsubmodels
int numsubmodels
Definition: r_model.h:198
model_s::numedges
int numedges
Definition: r_model.h:210
glpoly_s::numverts
int numverts
Definition: gl_model.h:90
model_s::registration_sequence
int registration_sequence
Definition: r_model.h:175
model_t
struct model_s model_t
mtexinfo_s::image
image_t * image
Definition: r_model.h:87
model_s::numframes
int numframes
Definition: r_model.h:178
model_s::texinfo
mtexinfo_t * texinfo
Definition: r_model.h:218
medge_t
Definition: r_model.h:77
mod_brush
@ mod_brush
Definition: gl_model.h:172
model_s::type
modtype_t type
Definition: r_model.h:177
Hunk_Alloc
void * Hunk_Alloc(int size)
Definition: q_shwin.c:57
model_s::numsurfedges
int numsurfedges
Definition: r_model.h:223
msurface_s::texinfo
mtexinfo_t * texinfo
Definition: r_model.h:112
model_s::leafs
mleaf_t * leafs
Definition: r_model.h:205
mmodel_t::headnode
int headnode
Definition: gl_model.h:51
model_s::nodes
mnode_t * nodes
Definition: r_model.h:215
model_s::mins
vec3_t mins
Definition: r_model.h:185
mleaf_s::cluster
int cluster
Definition: r_model.h:154
msurface_s::texturechain
struct msurface_s * texturechain
Definition: gl_model.h:112
Mod_Free
void Mod_Free(model_t *mod)
Definition: r_model.c:1239
Mod_ClusterPVS
byte * Mod_ClusterPVS(int cluster, model_t *model)
Definition: r_model.c:268
mmodel_t::radius
float radius
Definition: gl_model.h:50
model_s::lightdata
byte * lightdata
Definition: r_model.h:231
glpoly_s::chain
struct glpoly_s * chain
Definition: gl_model.h:89
model_s::surfedges
int * surfedges
Definition: r_model.h:224
mleaf_s::nummarksurfaces
int nummarksurfaces
Definition: r_model.h:158
mnode_t
struct mnode_s mnode_t
MAX_MD2SKINS
#define MAX_MD2SKINS
Definition: qfiles.h:92
Hunk_End
int Hunk_End(void)
Definition: q_shwin.c:81
name
cvar_t * name
Definition: cl_main.c:94
MAXLIGHTMAPS
#define MAXLIGHTMAPS
Definition: qfiles.h:409
msurface_s::flags
int flags
Definition: r_model.h:101
model_s::maxs
vec3_t maxs
Definition: r_model.h:185
model_s::radius
float radius
Definition: gl_model.h:189
mtexinfo_s::next
struct mtexinfo_s * next
Definition: r_model.h:90
mmodel_t::origin
vec3_t origin
Definition: gl_model.h:49
msurface_s::polys
glpoly_t * polys
Definition: gl_model.h:111
model_s::skins
image_t * skins[MAX_MD2SKINS]
Definition: r_model.h:234
mtexinfo_s::vecs
float vecs[2][4]
Definition: r_model.h:85
Mod_PointInLeaf
mleaf_t * Mod_PointInLeaf(float *p, model_t *model)
model_s::name
char name[MAX_QPATH]
Definition: r_model.h:173
msurface_s::light_s
int light_s
Definition: gl_model.h:108
model_s::numtexinfo
int numtexinfo
Definition: r_model.h:217
mnode_s::contents
int contents
Definition: r_model.h:126
mnode_s::firstsurface
unsigned short firstsurface
Definition: r_model.h:137
mleaf_s::minmaxs
short minmaxs[6]
Definition: r_model.h:149
mleaf_s::parent
struct mnode_s * parent
Definition: r_model.h:151
glpoly_t
struct glpoly_s glpoly_t
model_s::firstmodelsurface
int firstmodelsurface
Definition: r_model.h:196
model_s::surfaces
msurface_t * surfaces
Definition: r_model.h:221
modtype_t
modtype_t
Definition: gl_model.h:172
model_s::numleafs
int numleafs
Definition: r_model.h:204
msurface_s::lightmaptexturenum
int lightmaptexturenum
Definition: gl_model.h:121
mmodel_t::mins
vec3_t mins
Definition: gl_model.h:48
model_s::submodels
mmodel_t * submodels
Definition: gl_model.h:204
msurface_s
Definition: r_model.h:93
mtexinfo_s::flags
int flags
Definition: r_model.h:88
model_s::numnodes
int numnodes
Definition: r_model.h:213
msurface_s::cached_light
float cached_light[MAXLIGHTMAPS]
Definition: gl_model.h:123
mnode_s::minmaxs
short minmaxs[6]
Definition: r_model.h:129
msurface_s::texturemins
short texturemins[2]
Definition: r_model.h:109
Hunk_Begin
void * Hunk_Begin(int maxsize)
Definition: q_shwin.c:41
mtexinfo_t
struct mtexinfo_s mtexinfo_t
Mod_FreeAll
void Mod_FreeAll(void)
Definition: r_model.c:1250
image_s
Definition: r_local.h:65
glpoly_s::flags
int flags
Definition: gl_model.h:91
msurface_s::dlightbits
int dlightbits
Definition: r_model.h:98
cplane_s
Definition: q_shared.h:409
mod_sprite
@ mod_sprite
Definition: gl_model.h:172
mnode_s::numsurfaces
unsigned short numsurfaces
Definition: r_model.h:138
model_s::vertexes
mvertex_t * vertexes
Definition: r_model.h:208
msurface_s::lightmapchain
struct msurface_s * lightmapchain
Definition: gl_model.h:113
model_s::nummarksurfaces
int nummarksurfaces
Definition: r_model.h:226
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:127
msurface_s::firstedge
int firstedge
Definition: r_model.h:103
model_s::extradatasize
int extradatasize
Definition: r_model.h:236
model_s::numsurfaces
int numsurfaces
Definition: r_model.h:220
glpoly_s
Definition: gl_model.h:86