2 Copyright (C) 1996-1997 Id Software, Inc.
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.
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.
13 See the GNU General Public License for more details.
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.
25 ==============================================================================
29 ==============================================================================
34 // in memory representation
48 typedef struct mplane_s
52 // for texture axis selection and fast side tests
54 // LordHavoc: faster than id's signbits system
55 int (*BoxOnPlaneSideFunc) (vec3_t emins, vec3_t emaxs, struct mplane_s *p);
59 #define SHADERSTAGE_SKY 0
60 #define SHADERSTAGE_NORMAL 1
61 #define SHADERSTAGE_COUNT 2
63 #define SHADERFLAGS_NEEDLIGHTMAP 1
65 struct entity_render_s;
67 // change this stuff when real shaders are added
68 typedef struct Cshader_s
70 void (*shaderfunc[SHADERSTAGE_COUNT])(const struct entity_render_s *ent, const struct texture_s *texture);
75 extern Cshader_t Cshader_wall_lightmap;
76 extern Cshader_t Cshader_wall_fullbright;
77 extern Cshader_t Cshader_water;
78 extern Cshader_t Cshader_sky;
80 typedef struct texture_s
85 unsigned int width, height;
89 // base texture without fullbrights, never NULL
91 // fullbrights texture, NULL if no fullbrights used
92 rtexture_t *glowtexture;
93 // alpha texture (used for fogging), NULL if opaque
94 rtexture_t *fogtexture;
95 // detail texture (usually not used if transparent)
96 rtexture_t *detailtexture;
98 // shader to use for this texture
101 // list of surfaces to render using this texture
102 struct msurface_s *surfacechain;
104 // total frames in sequence and alternate sequence
106 // direct pointers to each of the frames in the sequences
107 // (indexed as [alternate][frame])
108 struct texture_s *anim_frames[2][10];
109 // set if animated or there is an alternate frame set
110 // (this is an optimization in the renderer)
116 #define SURF_PLANEBACK 2
117 #define SURF_DRAWSKY 4
118 #define SURF_DRAWTURB 0x10
119 #define SURF_LIGHTMAP 0x20
120 #define SURF_DRAWNOALPHA 0x100
121 #define SURF_DRAWFULLBRIGHT 0x200
122 #define SURF_LIGHTBOTHSIDES 0x400
123 #define SURF_CLIPSOLID 0x800 // this polygon can obscure other polygons
139 // LordHavoc: replaces glpoly, triangle mesh
140 typedef struct surfmesh_s
142 // can be multiple meshs per surface
143 struct surfmesh_s *chain;
147 int *lightmapoffsets;
155 typedef struct msurface_s
157 // surface number, to avoid having to do a divide to find the number of a surface from it's address
159 // should be drawn if visframe == r_framecount (set by WorldNode functions)
161 // should be drawn if onscreen and not a backface (used for setting visframe)
163 // chain of surfaces marked visible by pvs
164 //struct msurface_s *pvschain;
166 // the node plane this is on, backwards if SURF_PLANEBACK flag set
171 struct msurface_s *texturechain;
173 // look up in model->surfedges[], negative numbers are backwards edges
177 short texturemins[2];
181 texture_t *currenttexture; // updated (animated) during early surface processing each frame
183 // index into d_lightstylevalue array, 255 means not used (black)
184 qbyte styles[MAXLIGHTMAPS];
185 // RGB lighting data [numstyles][height][width][3]
187 // stain to apply on lightmap (soot/dirt/blood/whatever)
190 // these fields are generated during model loading
191 // the lightmap texture fragment to use on the surface
192 rtexture_t *lightmaptexture;
193 // the stride when building lightmaps to comply with fragment update
194 int lightmaptexturestride;
195 // mesh for rendering
198 // these are just 3D points defining the outline of the polygon,
199 // no texcoord info (that can be generated from these)
202 // bounding box for onscreen checks, and center for sorting
203 vec3_t poly_mins, poly_maxs, poly_center;
205 // these are regenerated every frame
209 // avoid redundent addition of dlights
211 // only render each surface once
212 //int worldnodeframe;
214 // these cause lightmap updates if regenerated
215 // values currently used in lightmap
216 unsigned short cached_light[MAXLIGHTMAPS];
217 // if lightmap was lit by dynamic lights, force update on next frame
219 // to cause lightmap to be rerendered when v_overbrightbits changes
220 short cached_lightscalebit;
221 // rerender lightmaps when r_ambient changes
222 float cached_ambient;
226 typedef struct mnode_s
232 struct mnode_s *parent;
233 struct mportal_s *portals;
235 // for bounding box culling
241 struct mnode_s *children[2];
243 unsigned short firstsurface;
244 unsigned short numsurfaces;
248 typedef struct mleaf_s
251 // always negative in leafs
254 struct mnode_s *parent;
255 struct mportal_s *portals;
257 // for bounding box culling
262 // potentially visible if current (r_pvsframecount)
264 // used by certain worldnode variants to avoid processing the same leaf twice in a frame
266 // used by polygon-through-portals visibility checker
269 qbyte *compressed_vis;
271 int *firstmarksurface;
273 qbyte ambient_sound_level[NUM_AMBIENTS];
279 dclipnode_t *clipnodes;
289 typedef struct mportal_s
291 struct mportal_s *next; // the next portal on this leaf
292 mleaf_t *here; // the leaf this portal is on
293 mleaf_t *past; // the leaf through this portal (infront)
297 int visframe; // is this portal visible this frame?
301 typedef struct mlight_s
305 // distance attenuation scale (smaller is a larger light)
307 // color and brightness combined
309 // brightness bias, used for limiting radius without a hard edge
311 // spotlight direction
313 // cosine of spotlight cone angle (or 0 if not a spotlight)
315 // distance bias (larger value is softer and darker)
317 // light style controlling this light
319 // used only for loading calculations, number of leafs this shines on
324 extern rtexture_t *r_notexture;
325 extern texture_t r_notexture_mip;
328 void Mod_LoadBrushModel (struct model_s *mod, void *buffer);
329 void Mod_BrushInit(void);
331 void Mod_FindNonSolidLocation(vec3_t pos, struct model_s *mod);
332 mleaf_t *Mod_PointInLeaf (const float *p, struct model_s *model);
333 int Mod_PointContents (const float *p, struct model_s *model);
334 qbyte *Mod_LeafPVS (mleaf_t *leaf, struct model_s *model);