]> icculus.org git repositories - divverent/darkplaces.git/blob - model_brush.h
Small fixes to tab completion
[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 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 } glpolysizeof_t;
106
107 typedef struct msurface_s
108 {
109         int                     visframe;               // should be drawn when node is crossed
110
111         mplane_t        *plane;
112         int                     flags;
113
114         int                     firstedge;      // look up in model->surfedges[], negative numbers
115         int                     numedges;       // are backwards edges
116
117         short           texturemins[2];
118         short           extents[2];
119
120         short           light_s, light_t;       // gl lightmap coordinates
121
122         glpoly_t        *polys;                         // multiple if warped
123
124         mtexinfo_t      *texinfo;
125
126 // lighting info
127         int                     dlightframe;
128         int                     dlightbits[8];
129
130         int                     lightframe; // avoid redundent addition of dlights
131         int                     worldnodeframe; // only render each surface once
132
133         int                     lightmaptexturenum;
134         byte            styles[MAXLIGHTMAPS];
135         unsigned short cached_light[MAXLIGHTMAPS];      // values currently used in lightmap
136         short           cached_dlight;                          // LordHavoc: if lightmap was lit by dynamic lights, update on frame after end of effect to erase it
137         short           cached_lightscalebit;           // LordHavoc: to cause lightmap to be rerendered when lighthalf changes
138         float           cached_ambient;                         // LordHavoc: rerender lightmaps when r_ambient changes
139         byte            *samples;               // [numstyles*surfsize]
140 } msurface_t;
141
142 // warning: if this is changed, references must be updated in cpu_* assembly files
143 typedef struct mnode_s
144 {
145 // common with leaf
146         int                     contents;               // 0, to differentiate from leafs
147
148         struct mnode_s  *parent;
149         struct mportal_s *portals;
150
151         // for bounding box culling
152         vec3_t          mins;
153         vec3_t          maxs;
154
155 // node specific
156         mplane_t        *plane;
157         struct mnode_s  *children[2];
158
159         unsigned short          firstsurface;
160         unsigned short          numsurfaces;
161 } mnode_t;
162
163
164
165 typedef struct mleaf_s
166 {
167 // common with node
168         int                     contents;               // will be a negative contents number
169
170         struct mnode_s  *parent;
171         struct mportal_s *portals;
172
173         // for bounding box culling
174         vec3_t          mins;
175         vec3_t          maxs;
176
177 // leaf specific
178         int                     visframe;               // visible if current (r_framecount)
179         int                     worldnodeframe; // used by certain worldnode variants to avoid processing the same leaf twice in a frame
180         int                     portalmarkid;   // used by polygon-through-portals visibility checker
181
182         // LordHavoc: leaf based dynamic lighting
183         int                     dlightbits[8];
184         int                     dlightframe;
185
186         byte            *compressed_vis;
187
188         msurface_t      **firstmarksurface;
189         int                     nummarksurfaces;
190         byte            ambient_sound_level[NUM_AMBIENTS];
191 } mleaf_t;
192
193 typedef struct
194 {
195         dclipnode_t     *clipnodes;
196         mplane_t        *planes;
197         int                     firstclipnode;
198         int                     lastclipnode;
199         vec3_t          clip_mins;
200         vec3_t          clip_maxs;
201 } hull_t;
202
203 typedef struct mportal_s
204 {
205         struct mportal_s *next; // the next portal on this leaf
206         mleaf_t *here; // the leaf this portal is on
207         mleaf_t *past; // the leaf through this portal (infront)
208         mvertex_t *points;
209         int numpoints;
210         mplane_t plane;
211         int visframe; // is this portal visible this frame?
212 }
213 mportal_t;
214
215 extern void CL_ParseEntityLump(char *entdata);
216 extern rtexture_t *r_notexture;
217 extern texture_t r_notexture_mip;
218
219 struct model_s;
220 extern void Mod_LoadBrushModel (struct model_s *mod, void *buffer);
221 extern void Mod_BrushInit(void);