00001 00006 /* 00007 Copyright (C) 1997-2001 Id Software, Inc. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00017 00018 See the GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00023 00024 */ 00025 00026 #ifndef R_MODEL_BRUSH_H 00027 #define R_MODEL_BRUSH_H 00028 00029 /* 00030 ============================================================================== 00031 BRUSH MODELS 00032 ============================================================================== 00033 */ 00034 00035 00037 typedef struct mBspVertex_s { 00038 vec3_t position; 00039 vec3_t normal; 00040 } mBspVertex_t; 00041 00042 typedef struct mBspHeader_s { 00043 vec3_t mins, maxs; 00044 vec3_t origin; 00045 float radius; 00046 int headnode; 00047 int visleafs; 00048 int firstface, numfaces; 00049 } mBspHeader_t; 00050 00051 #define MSURF_PLANEBACK 1 00052 #define MSURF_LIGHTMAP 2 00053 00054 typedef struct mBspEdge_s { 00055 unsigned short v[2]; 00056 } mBspEdge_t; 00057 00066 typedef struct mBspTexInfo_s { 00067 vec3_t uv; 00068 float u_offset; 00069 vec3_t vv; 00070 float v_offset; 00071 uint32_t flags; 00072 image_t *image; 00073 } mBspTexInfo_t; 00074 00075 typedef struct mBspFlare_s { 00076 vec3_t origin; 00077 float radius; 00078 const image_t *image; 00079 vec3_t color; 00080 float time; 00081 float alpha; 00082 } mBspFlare_t; 00083 00084 typedef struct mBspSurface_s { 00085 cBspPlane_t *plane; 00086 int flags; 00087 int tile; 00089 int frame; 00092 int firstedge; 00093 int numedges; 00094 00095 short stmins[2]; 00096 short stmaxs[2]; 00097 vec2_t stcenter; 00098 vec2_t stextents; 00099 00100 vec3_t mins; 00101 vec3_t maxs; 00102 00103 vec3_t center; 00104 vec4_t color; 00105 vec3_t normal; 00106 00107 int light_s, light_t; 00108 int lightmap_scale; 00109 00110 unsigned int index; 00111 00112 int tracenum; 00113 00114 mBspTexInfo_t *texinfo; 00115 00116 mBspFlare_t *flare; 00117 00118 int lightmap_texnum; 00119 int deluxemap_texnum; 00120 00121 byte *samples; 00122 byte *lightmap; 00124 int lightframe; 00125 int lights; 00127 qboolean isOriginBrushModel; 00131 } mBspSurface_t; 00132 00137 typedef struct mBspSurfaces_s { 00138 mBspSurface_t **surfaces; 00139 int count; 00140 } mBspSurfaces_t; 00141 00142 #define opaque_surfaces sorted_surfaces[0] 00143 #define opaque_warp_surfaces sorted_surfaces[1] 00144 #define alpha_test_surfaces sorted_surfaces[2] 00145 #define blend_surfaces sorted_surfaces[3] 00146 #define blend_warp_surfaces sorted_surfaces[4] 00147 #define material_surfaces sorted_surfaces[5] 00148 #define flare_surfaces sorted_surfaces[6] 00149 00150 #define NUM_SURFACES_ARRAYS 7 00151 00152 #define R_SurfaceToSurfaces(surfs, surf)\ 00153 (surfs)->surfaces[(surfs)->count++] = surf 00154 00155 #define CONTENTS_NODE -1 00156 #define CONTENTS_PATHFINDING_NODE -2 00157 00160 typedef struct mBspNode_s { 00161 /* common with leaf */ 00162 int contents; 00163 float minmaxs[6]; 00165 struct mBspNode_s *parent; 00166 00167 struct model_s *model; 00168 00169 /* node specific */ 00170 cBspPlane_t *plane; 00171 struct mBspNode_s *children[2]; 00172 00173 unsigned short firstsurface; 00174 unsigned short numsurfaces; 00175 } mBspNode_t; 00176 00177 typedef struct mBspLeaf_s { 00178 /* common with mBspNode_t */ 00179 int contents; 00180 float minmaxs[6]; 00182 mBspNode_t *parent; 00183 00184 struct model_s *model; 00185 } mBspLeaf_t; 00186 00188 typedef struct mBspModel_s { 00189 /* range of surface numbers in this (sub)model */ 00190 int firstmodelsurface, nummodelsurfaces; 00191 int maptile; 00193 int numsubmodels; 00194 mBspHeader_t *submodels; 00195 00196 int numplanes; 00197 cBspPlane_t *planes; 00198 00199 int numleafs; 00200 mBspLeaf_t *leafs; 00201 00202 int numvertexes; 00203 mBspVertex_t *vertexes; 00204 00205 int numedges; 00206 mBspEdge_t *edges; 00207 00208 int numnodes; 00209 int firstnode; 00210 mBspNode_t *nodes; 00211 00212 int numtexinfo; 00213 mBspTexInfo_t *texinfo; 00214 00215 int numsurfaces; 00216 mBspSurface_t *surfaces; 00217 00218 int numsurfedges; 00219 int *surfedges; 00220 00221 /* vertex arrays */ 00222 float *verts; 00223 float *texcoords; 00224 float *lmtexcoords; 00225 float *tangents; 00226 float *normals; 00227 00228 /* vertex buffer objects */ 00229 unsigned int vertex_buffer; 00230 unsigned int texcoord_buffer; 00231 unsigned int lmtexcoord_buffer; 00232 unsigned int tangent_buffer; 00233 unsigned int normal_buffer; 00234 00235 byte lightquant; 00236 byte *lightdata; 00237 00238 /* sorted surfaces arrays */ 00239 mBspSurfaces_t *sorted_surfaces[NUM_SURFACES_ARRAYS]; 00240 } mBspModel_t; 00241 00242 #endif /* R_MODEL_BRUSH_H */