icculus quake2 doxygen  1.0 dev
r_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 #ifndef __MODEL__
22 #define __MODEL__
23 
24 /*
25 
26 d*_t structures are on-disk representations
27 m*_t structures are in-memory
28 
29 */
30 
31 
32 /*
33 ==============================================================================
34 
35 BRUSH MODELS
36 
37 ==============================================================================
38 */
39 
40 
41 //
42 // in memory representation
43 //
44 // !!! if this is changed, it must be changed in asm_draw.h too !!!
45 typedef struct
46 {
48 } mvertex_t;
49 
50 #define SIDE_FRONT 0
51 #define SIDE_BACK 1
52 #define SIDE_ON 2
53 
54 
55 // plane_t structure
56 // !!! if this is changed, it must be changed in asm_i386.h too !!!
57 typedef struct mplane_s
58 {
60  float dist;
61  byte type; // for texture axis selection and fast side tests
62  byte signbits; // signx + signy<<1 + signz<<1
63  byte pad[2];
64 } mplane_t;
65 
66 
67 // FIXME: differentiate from texinfo SURF_ flags
68 #define SURF_PLANEBACK 2
69 #define SURF_DRAWSKY 4 // sky brush face
70 #define SURF_DRAWTURB 0x10
71 #define SURF_DRAWBACKGROUND 0x40
72 #define SURF_DRAWSKYBOX 0x80 // sky box
73 
74 #define SURF_FLOW 0x100 //PGM
75 
76 // !!! if this is changed, it must be changed in asm_draw.h too !!!
77 typedef struct
78 {
79  unsigned short v[2];
80  unsigned int cachededgeoffset;
81 } medge_t;
82 
83 typedef struct mtexinfo_s
84 {
85  float vecs[2][4];
86  float mipadjust;
88  int flags;
89  int numframes;
90  struct mtexinfo_s *next; // animation chain
91 } mtexinfo_t;
92 
93 typedef struct msurface_s
94 {
95  int visframe; // should be drawn when node is crossed
96 
99 
101  int flags;
102 
103  int firstedge; // look up in model->surfedges[], negative numbers
104  int numedges; // are backwards edges
105 
106 // surface generation data
108 
109  short texturemins[2];
110  short extents[2];
111 
113 
114 // lighting info
116  byte *samples; // [numstyles*surfsize]
117 
119 } msurface_t;
120 
121 
122 #define CONTENTS_NODE -1
123 typedef struct mnode_s
124 {
125 // common with leaf
126  int contents; // CONTENTS_NODE, to differentiate from leafs
127  int visframe; // node needs to be traversed if current
128 
129  short minmaxs[6]; // for bounding box culling
130 
131  struct mnode_s *parent;
132 
133 // node specific
135  struct mnode_s *children[2];
136 
137  unsigned short firstsurface;
138  unsigned short numsurfaces;
139 } mnode_t;
140 
141 
142 
143 typedef struct mleaf_s
144 {
145 // common with node
146  int contents; // wil be something other than CONTENTS_NODE
147  int visframe; // node needs to be traversed if current
148 
149  short minmaxs[6]; // for bounding box culling
150 
151  struct mnode_s *parent;
152 
153 // leaf specific
154  int cluster;
155  int area;
156 
159  int key; // BSP sequence number for leaf's contents
160 } mleaf_t;
161 
162 
163 //===================================================================
164 
165 //
166 // Whole model
167 //
168 
170 
171 typedef struct model_s
172 {
174 
176 
179 
180  int flags;
181 
182 //
183 // volume occupied by the model graphics
184 //
186 
187 //
188 // solid volume for clipping (sent from server)
189 //
192 
193 //
194 // brush model
195 //
197 
200 
203 
204  int numleafs; // number of visible leafs, not counting 0
206 
209 
210  int numedges;
212 
213  int numnodes;
216 
219 
222 
224  int *surfedges;
225 
228 
230 
231  byte *lightdata;
232 
233  // for alias models and sprites
235  void *extradata;
237 } model_t;
238 
239 //============================================================================
240 
241 void Mod_Init (void);
242 void Mod_ClearAll (void);
243 model_t *Mod_ForName (char *name, qboolean crash);
244 void *Mod_Extradata (model_t *mod); // handles caching
245 void Mod_TouchModel (char *name);
246 
247 mleaf_t *Mod_PointInLeaf (float *p, model_t *model);
248 byte *Mod_ClusterPVS (int cluster, model_t *model);
249 
250 void Mod_Modellist_f (void);
251 void Mod_FreeAll (void);
252 void Mod_Free (model_t *mod);
253 
254 extern int registration_sequence;
255 
256 #endif // __MODEL__
Mod_ForName
model_t * Mod_ForName(char *name, qboolean crash)
Definition: r_model.c:90
mplane_t
struct mplane_s mplane_t
model_s::numvertexes
int numvertexes
Definition: r_model.h:207
model_s::clipmins
vec3_t clipmins
Definition: r_model.h:191
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
model_s::vis
dvis_t * vis
Definition: r_model.h:229
surfcache_s
Definition: r_local.h:360
mvertex_t
Definition: r_model.h:45
model_s::nummodelsurfaces
int nummodelsurfaces
Definition: r_model.h:196
Mod_Free
void Mod_Free(model_t *mod)
Definition: r_model.c:1239
Mod_FreeAll
void Mod_FreeAll(void)
Definition: r_model.c:1250
mnode_t
struct mnode_s mnode_t
v
GLdouble v
Definition: qgl_win.c:143
model_s::clipmaxs
vec3_t clipmaxs
Definition: r_model.h:191
Mod_TouchModel
void Mod_TouchModel(char *name)
model_s::flags
int flags
Definition: r_model.h:180
model_s::edges
medge_t * edges
Definition: r_model.h:211
mtexinfo_s
Definition: r_model.h:83
mnode_s::visframe
int visframe
Definition: r_model.h:127
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
mplane_s::pad
byte pad[2]
Definition: r_model.h:63
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
model_s
Definition: r_model.h:171
mleaf_s::firstmarksurface
msurface_t ** firstmarksurface
Definition: r_model.h:157
dvis_t
Definition: qfiles.h:463
model_s::marksurfaces
msurface_t ** marksurfaces
Definition: r_model.h:227
msurface_s::samples
byte * samples
Definition: r_model.h:116
mnode_s::children
struct mnode_s * children[2]
Definition: r_model.h:135
mleaf_s::contents
int contents
Definition: r_model.h:146
mplane_s::normal
vec3_t normal
Definition: r_model.h:59
msurface_s::extents
short extents[2]
Definition: r_model.h:110
mod_brush
@ mod_brush
Definition: r_model.h:169
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
mplane_s::signbits
byte signbits
Definition: r_model.h:62
msurface_s::plane
mplane_t * plane
Definition: r_model.h:100
model_s::clipbox
qboolean clipbox
Definition: r_model.h:190
model_s::numsubmodels
int numsubmodels
Definition: r_model.h:198
mvertex_t::position
vec3_t position
Definition: r_model.h:47
model_s::numedges
int numedges
Definition: r_model.h:210
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
dmodel_t
Definition: qfiles.h:290
mnode_s::plane
mplane_t * plane
Definition: r_model.h:134
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
mplane_s::dist
float dist
Definition: r_model.h:60
mleaf_s::key
int key
Definition: r_model.h:159
mleaf_t
struct mleaf_s mleaf_t
model_s::type
modtype_t type
Definition: r_model.h:177
model_s::submodels
dmodel_t * submodels
Definition: r_model.h:199
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
medge_t::cachededgeoffset
unsigned int cachededgeoffset
Definition: r_model.h:80
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
Mod_ClusterPVS
byte * Mod_ClusterPVS(int cluster, model_t *model)
Definition: r_model.c:268
model_s::lightdata
byte * lightdata
Definition: r_model.h:231
model_s::surfedges
int * surfedges
Definition: r_model.h:224
MIPLEVELS
#define MIPLEVELS
Definition: qfiles.h:197
mleaf_s::nummarksurfaces
int nummarksurfaces
Definition: r_model.h:158
Mod_Extradata
void * Mod_Extradata(model_t *mod)
MAX_MD2SKINS
#define MAX_MD2SKINS
Definition: qfiles.h:92
name
cvar_t * name
Definition: cl_main.c:94
MAXLIGHTMAPS
#define MAXLIGHTMAPS
Definition: qfiles.h:409
mtexinfo_s::mipadjust
float mipadjust
Definition: r_model.h:86
registration_sequence
int registration_sequence
Definition: r_model.c:44
msurface_s::flags
int flags
Definition: r_model.h:101
mod_sprite
@ mod_sprite
Definition: r_model.h:169
model_s::maxs
vec3_t maxs
Definition: r_model.h:185
mtexinfo_s::next
struct mtexinfo_s * next
Definition: r_model.h:90
msurface_s::cachespots
struct surfcache_s * cachespots[MIPLEVELS]
Definition: r_model.h:107
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_Modellist_f
void Mod_Modellist_f(void)
Definition: r_model.c:55
msurface_t
struct msurface_s msurface_t
model_s::name
char name[MAX_QPATH]
Definition: r_model.h:173
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
mplane_s::type
byte type
Definition: r_model.h:61
mleaf_s::minmaxs
short minmaxs[6]
Definition: r_model.h:149
mleaf_s::parent
struct mnode_s * parent
Definition: r_model.h:151
mtexinfo_t
struct mtexinfo_s mtexinfo_t
model_s::firstmodelsurface
int firstmodelsurface
Definition: r_model.h:196
model_s::surfaces
msurface_t * surfaces
Definition: r_model.h:221
Mod_Init
void Mod_Init(void)
Definition: r_model.c:78
mod_alias
@ mod_alias
Definition: r_model.h:169
model_s::numleafs
int numleafs
Definition: r_model.h:204
msurface_s
Definition: r_model.h:93
mplane_s
Definition: r_model.h:57
model_s::planes
mplane_t * planes
Definition: r_model.h:202
mtexinfo_s::flags
int flags
Definition: r_model.h:88
model_s::numnodes
int numnodes
Definition: r_model.h:213
Mod_PointInLeaf
mleaf_t * Mod_PointInLeaf(float *p, model_t *model)
mnode_s::minmaxs
short minmaxs[6]
Definition: r_model.h:129
msurface_s::texturemins
short texturemins[2]
Definition: r_model.h:109
image_s
Definition: r_local.h:65
msurface_s::dlightbits
int dlightbits
Definition: r_model.h:98
mnode_s::numsurfaces
unsigned short numsurfaces
Definition: r_model.h:138
model_s::vertexes
mvertex_t * vertexes
Definition: r_model.h:208
msurface_s::nextalphasurface
struct msurface_s * nextalphasurface
Definition: r_model.h:118
model_s::nummarksurfaces
int nummarksurfaces
Definition: r_model.h:226
Mod_ClearAll
void Mod_ClearAll(void)
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:127
mod_bad
@ mod_bad
Definition: r_model.h:169
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