]> icculus.org git repositories - divverent/darkplaces.git/blob - model_brush.h
copyentity builtin added
[divverent/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 // !!! if this is changed, it must be changed in asm_draw.h too !!!
34 typedef struct
35 {
36         vec3_t          position;
37 } mvertex_t;
38
39 #define SIDE_FRONT      0
40 #define SIDE_BACK       1
41 #define SIDE_ON         2
42
43
44 // plane_t structure
45 // !!! if this is changed, it must be changed in asm_i386.h too !!!
46 typedef struct mplane_s
47 {
48         vec3_t  normal;
49         float   dist;
50         byte    type;                   // for texture axis selection and fast side tests
51 //      byte    signbits;               // signx + signy<<1 + signz<<2
52 //      byte    pad[2];
53         byte    pad[3];
54         int (*BoxOnPlaneSideFunc) (vec3_t emins, vec3_t emaxs, struct mplane_s *p);
55 } mplane_t;
56
57 typedef struct texture_s
58 {
59         char            name[16];
60         unsigned        width, height;
61         int                     gl_texturenum;
62         int                     gl_glowtexturenum; // LordHavoc: fullbrights on walls
63         struct msurface_s       *texturechain;  // for gl_texsort drawing
64         int                     anim_total;                             // total tenths in sequence ( 0 = no)
65         int                     anim_min, anim_max;             // time for this frame min <=time< max
66         struct texture_s *anim_next;            // in the animation sequence
67         struct texture_s *alternate_anims;      // bmodels in frame 1 use these
68         unsigned        offsets[MIPLEVELS];             // four mip maps stored
69         int                     transparent;    // LordHavoc: transparent texture support
70 } texture_t;
71
72
73 #define SURF_PLANEBACK          2
74 #define SURF_DRAWSKY            4
75 #define SURF_DRAWSPRITE         8
76 #define SURF_DRAWTURB           0x10
77 #define SURF_DRAWTILED          0x20
78 #define SURF_DRAWBACKGROUND     0x40
79 //#define SURF_UNDERWATER               0x80
80 // LordHavoc: added these for lava and teleport textures
81 #define SURF_DRAWNOALPHA        0x100
82 #define SURF_DRAWFULLBRIGHT     0x200
83
84 // !!! if this is changed, it must be changed in asm_draw.h too !!!
85 typedef struct
86 {
87         unsigned short  v[2];
88         unsigned int    cachededgeoffset;
89 } medge_t;
90
91 typedef struct
92 {
93         float           vecs[2][4];
94         float           mipadjust;
95         texture_t       *texture;
96         int                     flags;
97 } mtexinfo_t;
98
99 // LordHavoc: was 7, I added two more for raw lightmap coordinates
100 #define VERTEXSIZE      9
101
102 typedef struct glpoly_s
103 {
104         struct  glpoly_s        *next;
105         struct  glpoly_s        *chain;
106         int             numverts;
107         int             flags;                  // for SURF_UNDERWATER
108         float   verts[4][VERTEXSIZE];   // variable sized (xyz s1t1 s2t2)
109 } glpoly_t;
110
111 typedef struct msurface_s
112 {
113         int                     visframe;               // should be drawn when node is crossed
114
115         mplane_t        *plane;
116         int                     flags;
117
118         int                     firstedge;      // look up in model->surfedges[], negative numbers
119         int                     numedges;       // are backwards edges
120         
121         short           texturemins[2];
122         short           extents[2];
123
124         int                     light_s, light_t;       // gl lightmap coordinates
125
126         glpoly_t        *polys;                         // multiple if warped
127         struct  msurface_s      *texturechain;
128
129         mtexinfo_t      *texinfo;
130         
131 // lighting info
132         int                     dlightframe;
133         int                     dlightbits[8];
134
135         int                     lightmaptexturenum;
136         byte            styles[MAXLIGHTMAPS];
137         int                     cached_light[MAXLIGHTMAPS];     // values currently used in lightmap
138         qboolean        cached_dlight;                          // true if dynamic light in cache
139         qboolean        cached_lighthalf;                       // LordHavoc: to cause lightmap to be rerendered when lighthalf changes
140         float           cached_ambient;                         // LordHavoc: rerender lightmaps when r_ambient changes
141         byte            *samples;               // [numstyles*surfsize]
142 } msurface_t;
143
144 typedef struct mnode_s
145 {
146 // common with leaf
147         int                     contents;               // 0, to differentiate from leafs
148         int                     visframe;               // node needs to be traversed if current
149         
150         float           minmaxs[6];             // for bounding box culling
151
152         struct mnode_s  *parent;
153
154 // node specific
155         mplane_t        *plane;
156         struct mnode_s  *children[2];   
157
158         unsigned short          firstsurface;
159         unsigned short          numsurfaces;
160 } mnode_t;
161
162
163
164 typedef struct mleaf_s
165 {
166 // common with node
167         int                     contents;               // wil be a negative contents number
168         int                     visframe;               // node needs to be traversed if current
169
170         float           minmaxs[6];             // for bounding box culling
171
172         struct mnode_s  *parent;
173
174 // leaf specific
175         byte            *compressed_vis;
176         efrag_t         *efrags;
177
178         msurface_t      **firstmarksurface;
179         int                     nummarksurfaces;
180         int                     key;                    // BSP sequence number for leaf's contents
181         byte            ambient_sound_level[NUM_AMBIENTS];
182 } mleaf_t;
183
184 // !!! if this is changed, it must be changed in asm_i386.h too !!!
185 typedef struct
186 {
187         dclipnode_t     *clipnodes;
188         mplane_t        *planes;
189         int                     firstclipnode;
190         int                     lastclipnode;
191         vec3_t          clip_mins;
192         vec3_t          clip_maxs;
193 } hull_t;