bsp.h

Go to the documentation of this file.
00001 
00005 /*
00006 Copyright (C) 1997-2001 Id Software, Inc.
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016 
00017 See the GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023 */
00024 
00025 #ifndef UFO2MAP_BSP_H
00026 #define UFO2MAP_BSP_H
00027 
00028 #include <assert.h>
00029 
00030 #include "map.h"
00031 
00032 #include "common/shared.h"
00033 #include "common/scriplib.h"
00034 #include "common/polylib.h"
00035 #include "common/bspfile.h"
00036 
00037 #include "../../common/tracing.h"
00038 
00039 extern dMapTile_t *curTile;
00040 extern mapTiles_t mapTiles;
00041 
00042 typedef struct bspbrush_s {
00043     struct bspbrush_s   *next;
00044     vec3_t  mins, maxs;
00045     int     side, testside;     
00046     struct mapbrush_s   *original;
00047     int     numsides;
00048     side_t  sides[6];           
00049 } bspbrush_t;
00050 
00051 typedef struct node_s {
00053     int             planenum;   
00054     struct node_s   *parent;
00055     vec3_t          mins, maxs; 
00056     bspbrush_t      *volume;    
00059     side_t          *side;      
00060     struct node_s   *children[2];
00061     face_t          *faces;
00062 
00064     bspbrush_t      *brushlist; 
00065     int             contentFlags;   
00066     int             area;       
00067     struct portal_s *portals;   
00068 } node_t;
00069 
00070 typedef struct {
00071     struct node_s       *headnode;
00072     struct node_s       outside_node;
00073     vec3_t      mins, maxs;
00074 } tree_t;
00075 
00076 extern int entity_num;
00077 
00078 extern plane_t mapplanes[MAX_MAP_PLANES];
00079 extern int nummapplanes;
00080 
00081 extern int nummapbrushes;
00082 extern mapbrush_t mapbrushes[MAX_MAP_BRUSHES];
00083 
00084 extern int nummapbrushsides;
00085 extern side_t brushsides[MAX_MAP_SIDES];
00086 extern brush_texture_t side_brushtextures[MAX_MAP_SIDES];
00087 
00088 extern int brush_start, brush_end;
00089 
00090 byte GetLevelFlagsFromBrush(const mapbrush_t *brush);
00091 void LoadMapFile(const char *filename);
00092 void WriteMapFile(const char *filename);
00093 int FindOrCreateFloatPlane(vec3_t normal, vec_t dist);
00094 
00095 /*============================================================================= */
00096 
00097 /* textures.c */
00098 
00099 typedef struct {
00100     char    name[MAX_TEXPATH];
00101     qboolean    footstepMarked; 
00102     qboolean    materialMarked; 
00103 } textureref_t;
00104 
00105 
00106 extern  textureref_t    textureref[MAX_MAP_TEXTURES];
00107 int FindMiptex(const char *name);
00108 int TexinfoForBrushTexture(plane_t *plane, brush_texture_t *bt, const vec3_t origin, qboolean isTerrain);
00109 
00110 /* csg.c */
00111 
00112 int MapBrushesBounds(const int startbrush, const int endbrush, const int level, const vec3_t clipmins, const vec3_t clipmaxs, vec3_t mins, vec3_t maxs);
00113 bspbrush_t *MakeBspBrushList(int startbrush, int endbrush, int level, vec3_t clipmins, vec3_t clipmaxs);
00114 bspbrush_t *ChopBrushes(bspbrush_t *head);
00115 
00116 /* brushbsp.c */
00117 
00118 bspbrush_t *CopyBrush(const bspbrush_t *brush);
00119 void SplitBrush(const bspbrush_t *brush, int planenum, bspbrush_t **front, bspbrush_t **back);
00120 bspbrush_t *AllocBrush(int numsides);
00121 int CountBrushList(bspbrush_t *brushes);
00122 void FreeBrush(bspbrush_t *brushes);
00123 void FreeBrushList(bspbrush_t *brushes);
00124 qboolean WindingIsTiny(winding_t *w);
00125 tree_t *BrushBSP(bspbrush_t *brushlist, vec3_t mins, vec3_t maxs);
00126 void WriteBSPBrushMap(const char *name, const bspbrush_t *list);
00127 
00128 /* portals.c */
00129 
00130 int VisibleContents(int contents);
00131 void MarkVisibleSides(tree_t *tree, int start, int end);
00132 void FreePortal(portal_t *p);
00133 void MakeTreePortals(tree_t *tree);
00134 void RemovePortalFromNode(portal_t *portal, node_t *l);
00135 
00136 /*============================================================================= */
00137 
00138 /* writebsp.c */
00139 
00140 void SetModelNumbers(void);
00141 
00142 void BeginBSPFile(void);
00143 int WriteBSP(node_t *headnode);
00144 void EndBSPFile(const char *filename);
00145 void BeginModel(int entityNum);
00146 void EndModel(void);
00147 void EmitBrushes(void);
00148 void EmitPlanes(void);
00149 
00150 /* faces.c */
00151 
00152 void MakeFaces(node_t *headnode);
00153 void FixTjuncs(node_t *headnode);
00154 int GetEdge(int v1, int v2, const face_t *f);
00155 void FreeFace(face_t *f);
00156 
00157 /* tree.c */
00158 
00159 void FreeTree(tree_t *tree);
00160 
00161 /* trace.c */
00162 
00163 void MakeTracingNodes(int levels);
00164 void CloseTracingNodes(void);
00165 
00166 /* levels.c */
00167 
00168 extern const vec3_t v_epsilon;
00169 extern vec3_t worldMins, worldMaxs;
00170 
00171 void PushInfo(void);
00172 void PopInfo(void);
00173 void ProcessLevel(unsigned int levelnum);
00174 void PruneNodes(node_t *node);
00175 
00176 /* routing.c */
00177 
00178 void DoRouting(void);
00179 
00180 /* bsp.c */
00181 
00182 void ProcessModels(const char *filename);
00183 
00184 #endif /* UFO2MAP_BSP_H */

Generated by  doxygen 1.6.2