]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - model_brush.h
2d2634eb3eac7640f24469415dd8ef12b9e87241
[xonotic/darkplaces.git] / model_brush.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 /*
22 ==============================================================================
23
24 BRUSH MODELS
25
26 ==============================================================================
27 */
28
29
30 //
31 // in memory representation
32 //
33 typedef struct
34 {
35         vec3_t          position;
36 } mvertex_t;
37
38 #define SIDE_FRONT      0
39 #define SIDE_BACK       1
40 #define SIDE_ON         2
41
42
43 // plane_t structure
44 typedef struct mplane_s
45 {
46         vec3_t  normal;
47         float   dist;
48         int             type;                   // for texture axis selection and fast side tests
49         // LordHavoc: faster than id's signbits system
50         int (*BoxOnPlaneSideFunc) (vec3_t emins, vec3_t emaxs, struct mplane_s *p);
51 } mplane_t;
52
53 typedef struct texture_s
54 {
55         char                            name[16];
56         unsigned                        width, height;
57         rtexture_t                      *texture;
58         rtexture_t                      *glowtexture;           // LordHavoc: fullbrights on walls
59         int                                     anim_total;                     // total frames in sequence (0 = not animated)
60         struct texture_s        *anim_frames[10];       // LordHavoc: direct pointers to each of the frames in the sequence
61         struct texture_s        *alternate_anims;       // bmodels in frame 1 use these
62         int                                     transparent;            // LordHavoc: transparent texture support
63 } texture_t;
64
65
66 #define SURF_PLANEBACK          2
67 #define SURF_DRAWSKY            4
68 #define SURF_DRAWSPRITE         8
69 #define SURF_DRAWTURB           0x10
70 #define SURF_DRAWTILED          0x20
71 #define SURF_DRAWBACKGROUND     0x40
72 //#define SURF_UNDERWATER               0x80
73 #define SURF_DRAWNOALPHA        0x100
74 #define SURF_DRAWFULLBRIGHT     0x200
75 #define SURF_LIGHTBOTHSIDES     0x400
76 #define SURF_CLIPSOLID          0x800 // this polygon can obscure other polygons
77
78 typedef struct
79 {
80         unsigned short  v[2];
81 } medge_t;
82
83 typedef struct
84 {
85         float           vecs[2][4];
86         texture_t       *texture;
87         int                     flags;
88 } mtexinfo_t;
89
90 // LordHavoc: was 7, I added one more for raw lightmap position
91 // (xyz st uv l)
92 #define VERTEXSIZE      8
93
94 typedef struct glpoly_s
95 {
96         struct  glpoly_s        *next;
97         int             numverts;
98         float   verts[4][VERTEXSIZE];   // variable sized
99 } glpoly_t;
100
101 typedef struct glpolysizeof_s
102 {
103         struct  glpoly_s        *next;
104         int             numverts;
105         int             flags;                  // for SURF_UNDERWATER
106 } glpolysizeof_t;
107
108 typedef struct msurface_s
109 {
110         int                     visframe;               // should be drawn when node is crossed
111
112         mplane_t        *plane;
113         int                     flags;
114
115         int                     firstedge;      // look up in model->surfedges[], negative numbers
116         int                     numedges;       // are backwards edges
117
118         short           texturemins[2];
119         short           extents[2];
120
121         short           light_s, light_t;       // gl lightmap coordinates
122
123         glpoly_t        *polys;                         // multiple if warped
124
125         mtexinfo_t      *texinfo;
126
127 // lighting info
128         int                     dlightframe;
129         int                     dlightbits[8];
130
131         int                     lightframe; // avoid redundent addition of dlights
132         int                     worldnodeframe; // only render each surface once
133
134         int                     lightmaptexturenum;
135         byte            styles[MAXLIGHTMAPS];
136         unsigned short  cached_light[MAXLIGHTMAPS];     // values currently used in lightmap
137         short           cached_dlight;                          // LordHavoc: if lightmap was lit by dynamic lights, update on frame after end of effect to erase it
138         short           cached_lighthalf;                       // LordHavoc: to cause lightmap to be rerendered when lighthalf changes
139         float           cached_ambient;                         // LordHavoc: rerender lightmaps when r_ambient changes
140         byte            *samples;               // [numstyles*surfsize]
141 } msurface_t;
142
143 // warning: if this is changed, references must be updated in cpu_* assembly files
144 typedef struct mnode_s
145 {
146 // common with leaf
147         int                     contents;               // 0, to differentiate from leafs
148
149         struct mnode_s  *parent;
150         struct mportal_s *portals;
151
152         // for bounding box culling
153         vec3_t          mins;
154         vec3_t          maxs;
155
156 // node specific
157         mplane_t        *plane;
158         struct mnode_s  *children[2];
159
160         unsigned short          firstsurface;
161         unsigned short          numsurfaces;
162 } mnode_t;
163
164
165
166 typedef struct mleaf_s
167 {
168 // common with node
169         int                     contents;               // will be a negative contents number
170
171         struct mnode_s  *parent;
172         struct mportal_s *portals;
173
174         // for bounding box culling
175         vec3_t          mins;
176         vec3_t          maxs;
177
178 // leaf specific
179         int                     visframe;               // visible if current (r_framecount)
180         int                     worldnodeframe; // used by certain worldnode variants to avoid processing the same leaf twice in a frame
181         int                     portalmarkid;   // used by polygon-through-portals visibility checker
182
183         // LordHavoc: leaf based dynamic lighting
184         int                     dlightbits[8];
185         int                     dlightframe;
186
187         byte            *compressed_vis;
188
189         msurface_t      **firstmarksurface;
190         int                     nummarksurfaces;
191         byte            ambient_sound_level[NUM_AMBIENTS];
192 } mleaf_t;
193
194 typedef struct
195 {
196         dclipnode_t     *clipnodes;
197         mplane_t        *planes;
198         int                     firstclipnode;
199         int                     lastclipnode;
200         vec3_t          clip_mins;
201         vec3_t          clip_maxs;
202 } hull_t;
203
204 typedef struct mportal_s
205 {
206         struct mportal_s *next; // the next portal on this leaf
207         mleaf_t *here; // the leaf this portal is on
208         mleaf_t *past; // the leaf through this portal (infront)
209         mvertex_t *points;
210         int numpoints;
211         mplane_t plane;
212         int visframe; // is this portal visible this frame?
213 }
214 mportal_t;
215
216 extern void CL_ParseEntityLump(char *entdata);
217 extern rtexture_t *r_notexture;
218 extern texture_t r_notexture_mip;
219
220 struct model_s;
221 extern void Mod_LoadBrushModel (struct model_s *mod, void *buffer);
222 extern void Mod_BrushInit(void);