doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AASFile.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __AASFILE_H__
30 #define __AASFILE_H__
31 
32 /*
33 ===============================================================================
34 
35  AAS File
36 
37 ===============================================================================
38 */
39 
40 #define AAS_FILEID "DewmAAS"
41 #define AAS_FILEVERSION "1.07"
42 
43 // travel flags
44 #define TFL_INVALID BIT(0) // not valid
45 #define TFL_WALK BIT(1) // walking
46 #define TFL_CROUCH BIT(2) // crouching
47 #define TFL_WALKOFFLEDGE BIT(3) // walking of a ledge
48 #define TFL_BARRIERJUMP BIT(4) // jumping onto a barrier
49 #define TFL_JUMP BIT(5) // jumping
50 #define TFL_LADDER BIT(6) // climbing a ladder
51 #define TFL_SWIM BIT(7) // swimming
52 #define TFL_WATERJUMP BIT(8) // jump out of the water
53 #define TFL_TELEPORT BIT(9) // teleportation
54 #define TFL_ELEVATOR BIT(10) // travel by elevator
55 #define TFL_FLY BIT(11) // fly
56 #define TFL_SPECIAL BIT(12) // special
57 #define TFL_WATER BIT(21) // travel through water
58 #define TFL_AIR BIT(22) // travel through air
59 
60 // face flags
61 #define FACE_SOLID BIT(0) // solid at the other side
62 #define FACE_LADDER BIT(1) // ladder surface
63 #define FACE_FLOOR BIT(2) // standing on floor when on this face
64 #define FACE_LIQUID BIT(3) // face seperating two areas with liquid
65 #define FACE_LIQUIDSURFACE BIT(4) // face seperating liquid and air
66 
67 // area flags
68 #define AREA_FLOOR BIT(0) // AI can stand on the floor in this area
69 #define AREA_GAP BIT(1) // area has a gap
70 #define AREA_LEDGE BIT(2) // if entered the AI bbox partly floats above a ledge
71 #define AREA_LADDER BIT(3) // area contains one or more ladder faces
72 #define AREA_LIQUID BIT(4) // area contains a liquid
73 #define AREA_CROUCH BIT(5) // AI cannot walk but can only crouch in this area
74 #define AREA_REACHABLE_WALK BIT(6) // area is reachable by walking or swimming
75 #define AREA_REACHABLE_FLY BIT(7) // area is reachable by flying
76 
77 // area contents flags
78 #define AREACONTENTS_SOLID BIT(0) // solid, not a valid area
79 #define AREACONTENTS_WATER BIT(1) // area contains water
80 #define AREACONTENTS_CLUSTERPORTAL BIT(2) // area is a cluster portal
81 #define AREACONTENTS_OBSTACLE BIT(3) // area contains (part of) a dynamic obstacle
82 #define AREACONTENTS_TELEPORTER BIT(4) // area contains (part of) a teleporter trigger
83 
84 // bits for different bboxes
85 #define AREACONTENTS_BBOX_BIT 24
86 
87 #define MAX_REACH_PER_AREA 256
88 #define MAX_AAS_TREE_DEPTH 128
89 
90 #define MAX_AAS_BOUNDING_BOXES 4
91 
92 // reachability to another area
94 public:
95  int travelType; // type of travel required to get to the area
96  short toAreaNum; // number of the reachable area
97  short fromAreaNum; // number of area the reachability starts
98  idVec3 start; // start point of inter area movement
99  idVec3 end; // end point of inter area movement
100  int edgeNum; // edge crossed by this reachability
101  unsigned short travelTime; // travel time of the inter area movement
102  byte number; // reachability number within the fromAreaNum (must be < 256)
103  byte disableCount; // number of times this reachability has been disabled
104  idReachability * next; // next reachability in list
105  idReachability * rev_next; // next reachability in reversed list
106  unsigned short * areaTravelTimes; // travel times within the fromAreaNum from reachabilities that lead towards this area
107 public:
108  void CopyBase( idReachability &reach );
109 };
110 
112 };
113 
115 };
116 
118 };
119 
121 };
122 
124 };
125 
127 };
128 
130 public:
132 };
133 
134 // index
135 typedef int aasIndex_t;
136 
137 // vertex
139 
140 // edge
141 typedef struct aasEdge_s {
142  int vertexNum[2]; // numbers of the vertexes of this edge
143 } aasEdge_t;
144 
145 // area boundary face
146 typedef struct aasFace_s {
147  unsigned short planeNum; // number of the plane this face is on
148  unsigned short flags; // face flags
149  int numEdges; // number of edges in the boundary of the face
150  int firstEdge; // first edge in the edge index
151  short areas[2]; // area at the front and back of this face
152 } aasFace_t;
153 
154 // area with a boundary of faces
155 typedef struct aasArea_s {
156  int numFaces; // number of faces used for the boundary of the area
157  int firstFace; // first face in the face index used for the boundary of the area
158  idBounds bounds; // bounds of the area
159  idVec3 center; // center of the area an AI can move towards
160  unsigned short flags; // several area flags
161  unsigned short contents; // contents of the area
162  short cluster; // cluster the area belongs to, if negative it's a portal
163  short clusterAreaNum; // number of the area in the cluster
164  int travelFlags; // travel flags for traveling through this area
165  idReachability * reach; // reachabilities that start from this area
166  idReachability * rev_reach; // reachabilities that lead to this area
167 } aasArea_t;
168 
169 // nodes of the bsp tree
170 typedef struct aasNode_s {
171  unsigned short planeNum; // number of the plane that splits the subspace at this node
172  int children[2]; // child nodes, zero is solid, negative is -(area number)
173 } aasNode_t;
174 
175 // cluster portal
176 typedef struct aasPortal_s {
177  short areaNum; // number of the area that is the actual portal
178  short clusters[2]; // number of cluster at the front and back of the portal
179  short clusterAreaNum[2]; // number of this portal area in the front and back cluster
180  unsigned short maxAreaTravelTime; // maximum travel time through the portal area
181 } aasPortal_t;
182 
183 // cluster
184 typedef struct aasCluster_s {
185  int numAreas; // number of areas in the cluster
186  int numReachableAreas; // number of areas with reachabilities
187  int numPortals; // number of cluster portals
188  int firstPortal; // first cluster portal in the index
189 } aasCluster_t;
190 
191 // trace through the world
192 typedef struct aasTrace_s {
193  // parameters
194  int flags; // areas with these flags block the trace
195  int travelFlags; // areas with these travel flags block the trace
196  int maxAreas; // size of the 'areas' array
197  int getOutOfSolid; // trace out of solid if the trace starts in solid
198  // output
199  float fraction; // fraction of trace completed
200  idVec3 endpos; // end position of trace
201  int planeNum; // plane hit
202  int lastAreaNum; // number of last area the trace went through
203  int blockingAreaNum; // area that could not be entered
204  int numAreas; // number of areas the trace went through
205  int * areas; // array to store areas the trace went through
206  idVec3 * points; // points where the trace entered each new area
207  aasTrace_s( void ) { areas = NULL; points = NULL; getOutOfSolid = false; flags = travelFlags = maxAreas = 0; }
208 } aasTrace_t;
209 
210 // settings
212 public:
213  // collision settings
223  // physics settings
232  float minFloorCos;
233  // fixed travel times
238 
239 public:
240  idAASSettings( void );
241 
242  bool FromFile( const idStr &fileName );
243  bool FromParser( idLexer &src );
244  bool FromDict( const char *name, const idDict *dict );
245  bool WriteToFile( idFile *fp ) const;
246  bool ValidForBounds( const idBounds &bounds ) const;
247  bool ValidEntity( const char *classname ) const;
248 
249 private:
250  bool ParseBool( idLexer &src, bool &b );
251  bool ParseInt( idLexer &src, int &i );
252  bool ParseFloat( idLexer &src, float &f );
253  bool ParseVector( idLexer &src, idVec3 &vec );
254  bool ParseBBoxes( idLexer &src );
255 };
256 
257 
258 /*
259 
260 - when a node child is a solid leaf the node child number is zero
261 - two adjacent areas (sharing a plane at opposite sides) share a face
262  this face is a portal between the areas
263 - when an area uses a face from the faceindex with a positive index
264  then the face plane normal points into the area
265 - the face edges are stored counter clockwise using the edgeindex
266 - two adjacent convex areas (sharing a face) only share One face
267  this is a simple result of the areas being convex
268 - the areas can't have a mixture of ground and gap faces
269  other mixtures of faces in one area are allowed
270 - areas with the AREACONTENTS_CLUSTERPORTAL in the settings have
271  the cluster number set to the negative portal number
272 - edge zero is a dummy
273 - face zero is a dummy
274 - area zero is a dummy
275 - node zero is a dummy
276 - portal zero is a dummy
277 - cluster zero is a dummy
278 
279 */
280 
281 
282 class idAASFile {
283 public:
284  virtual ~idAASFile( void ) {}
285 
286  const char * GetName( void ) const { return name.c_str(); }
287  unsigned int GetCRC( void ) const { return crc; }
288 
289  int GetNumPlanes( void ) const { return planeList.Num(); }
290  const idPlane & GetPlane( int index ) const { return planeList[index]; }
291  int GetNumVertices( void ) const { return vertices.Num(); }
292  const aasVertex_t & GetVertex( int index ) const { return vertices[index]; }
293  int GetNumEdges( void ) const { return edges.Num(); }
294  const aasEdge_t & GetEdge( int index ) const { return edges[index]; }
295  int GetNumEdgeIndexes( void ) const { return edgeIndex.Num(); }
296  const aasIndex_t & GetEdgeIndex( int index ) const { return edgeIndex[index]; }
297  int GetNumFaces( void ) const { return faces.Num(); }
298  const aasFace_t & GetFace( int index ) const { return faces[index]; }
299  int GetNumFaceIndexes( void ) const { return faceIndex.Num(); }
300  const aasIndex_t & GetFaceIndex( int index ) const { return faceIndex[index]; }
301  int GetNumAreas( void ) const { return areas.Num(); }
302  const aasArea_t & GetArea( int index ) { return areas[index]; }
303  int GetNumNodes( void ) const { return nodes.Num(); }
304  const aasNode_t & GetNode( int index ) const { return nodes[index]; }
305  int GetNumPortals( void ) const { return portals.Num(); }
306  const aasPortal_t & GetPortal( int index ) { return portals[index]; }
307  int GetNumPortalIndexes( void ) const { return portalIndex.Num(); }
308  const aasIndex_t & GetPortalIndex( int index ) const { return portalIndex[index]; }
309  int GetNumClusters( void ) const { return clusters.Num(); }
310  const aasCluster_t & GetCluster( int index ) const { return clusters[index]; }
311 
312  const idAASSettings & GetSettings( void ) const { return settings; }
313 
314  void SetPortalMaxTravelTime( int index, int time ) { portals[index].maxAreaTravelTime = time; }
315  void SetAreaTravelFlag( int index, int flag ) { areas[index].travelFlags |= flag; }
316  void RemoveAreaTravelFlag( int index, int flag ) { areas[index].travelFlags &= ~flag; }
317 
318  virtual idVec3 EdgeCenter( int edgeNum ) const = 0;
319  virtual idVec3 FaceCenter( int faceNum ) const = 0;
320  virtual idVec3 AreaCenter( int areaNum ) const = 0;
321 
322  virtual idBounds EdgeBounds( int edgeNum ) const = 0;
323  virtual idBounds FaceBounds( int faceNum ) const = 0;
324  virtual idBounds AreaBounds( int areaNum ) const = 0;
325 
326  virtual int PointAreaNum( const idVec3 &origin ) const = 0;
327  virtual int PointReachableAreaNum( const idVec3 &origin, const idBounds &searchBounds, const int areaFlags, const int excludeTravelFlags ) const = 0;
328  virtual int BoundsReachableAreaNum( const idBounds &bounds, const int areaFlags, const int excludeTravelFlags ) const = 0;
329  virtual void PushPointIntoAreaNum( int areaNum, idVec3 &point ) const = 0;
330  virtual bool Trace( aasTrace_t &trace, const idVec3 &start, const idVec3 &end ) const = 0;
331  virtual void PrintInfo( void ) const = 0;
332 
333 protected:
335  unsigned int crc;
336 
349 };
350 
351 #endif /* !__AASFILE_H__ */
GLsizei const GLfloat * points
Definition: glext.h:3884
unsigned short contents
Definition: AASFile.h:161
virtual bool Trace(aasTrace_t &trace, const idVec3 &start, const idVec3 &end) const =0
unsigned short maxAreaTravelTime
Definition: AASFile.h:180
unsigned short planeNum
Definition: AASFile.h:147
int GetNumFaceIndexes(void) const
Definition: AASFile.h:299
int GetNumVertices(void) const
Definition: AASFile.h:291
const idAASSettings & GetSettings(void) const
Definition: AASFile.h:312
int children[2]
Definition: AASFile.h:172
bool ParseInt(idLexer &src, int &i)
Definition: AASFile.cpp:190
idVec3 center
Definition: AASFile.h:159
short toAreaNum
Definition: AASFile.h:96
void CopyBase(idReachability &reach)
Definition: AASFile.cpp:76
const aasEdge_t & GetEdge(int index) const
Definition: AASFile.h:294
idReachability * rev_next
Definition: AASFile.h:105
idBounds bounds
Definition: AASFile.h:158
bool ValidForBounds(const idBounds &bounds) const
Definition: AASFile.cpp:503
int GetNumEdges(void) const
Definition: AASFile.h:293
const aasFace_t & GetFace(int index) const
Definition: AASFile.h:298
float maxStepHeight
Definition: AASFile.h:228
short fromAreaNum
Definition: AASFile.h:97
struct aasArea_s aasArea_t
const aasPortal_t & GetPortal(int index)
Definition: AASFile.h:306
bool ParseBBoxes(idLexer &src)
Definition: AASFile.cpp:228
int GetNumNodes(void) const
Definition: AASFile.h:303
bool ValidEntity(const char *classname) const
Definition: AASFile.cpp:522
int GetNumPlanes(void) const
Definition: AASFile.h:289
idList< aasNode_t > nodes
Definition: AASFile.h:344
bool allowSwimReachabilities
Definition: AASFile.h:220
virtual int BoundsReachableAreaNum(const idBounds &bounds, const int areaFlags, const int excludeTravelFlags) const =0
idList< aasCluster_t > clusters
Definition: AASFile.h:347
int numAreas
Definition: AASFile.h:204
int tt_startCrouching
Definition: AASFile.h:235
int vertexNum[2]
Definition: AASFile.h:142
const aasVertex_t & GetVertex(int index) const
Definition: AASFile.h:292
idReachability * reach
Definition: AASFile.h:165
Definition: Vector.h:316
const char * GetName(void) const
Definition: AASFile.h:286
int maxAreas
Definition: AASFile.h:196
const aasCluster_t & GetCluster(int index) const
Definition: AASFile.h:310
short areaNum
Definition: AASFile.h:177
int flags
Definition: AASFile.h:194
int * areas
Definition: AASFile.h:205
idAASSettings settings
Definition: AASFile.h:348
GLuint src
Definition: glext.h:5390
bool ParseBool(idLexer &src, bool &b)
Definition: AASFile.cpp:177
int GetNumEdgeIndexes(void) const
Definition: AASFile.h:295
bool FromDict(const char *name, const idDict *dict)
Definition: AASFile.cpp:379
float minFloorCos
Definition: AASFile.h:232
idBounds boundingBoxes[MAX_AAS_BOUNDING_BOXES]
Definition: AASFile.h:215
short cluster
Definition: AASFile.h:162
int i
Definition: process.py:33
idAASSettings(void)
Definition: AASFile.cpp:145
const aasIndex_t & GetEdgeIndex(int index) const
Definition: AASFile.h:296
float gravityValue
Definition: AASFile.h:227
struct aasPortal_s aasPortal_t
idList< aasIndex_t > faceIndex
Definition: AASFile.h:342
bool ParseFloat(idLexer &src, float &f)
Definition: AASFile.cpp:203
int firstEdge
Definition: AASFile.h:150
idVec3 start
Definition: AASFile.h:98
idVec3 gravityDir
Definition: AASFile.h:225
int travelFlags
Definition: AASFile.h:195
short clusterAreaNum
Definition: AASFile.h:163
unsigned short * areaTravelTimes
Definition: AASFile.h:106
int GetNumPortals(void) const
Definition: AASFile.h:305
unsigned short planeNum
Definition: AASFile.h:171
unsigned short flags
Definition: AASFile.h:160
struct aasFace_s aasFace_t
Definition: File.h:50
int aasIndex_t
Definition: AASFile.h:135
void SetAreaTravelFlag(int index, int flag)
Definition: AASFile.h:315
idList< aasIndex_t > edgeIndex
Definition: AASFile.h:340
idVec3 gravity
Definition: AASFile.h:224
Definition: Lexer.h:137
bool usePatches
Definition: AASFile.h:216
int travelType
Definition: AASFile.h:95
bool ParseVector(idLexer &src, idVec3 &vec)
Definition: AASFile.cpp:216
unsigned short travelTime
Definition: AASFile.h:101
short clusters[2]
Definition: AASFile.h:178
int numPortals
Definition: AASFile.h:187
GLuint index
Definition: glext.h:3476
int tt_startWalkOffLedge
Definition: AASFile.h:237
struct aasEdge_s aasEdge_t
bool writeBrushMap
Definition: AASFile.h:217
const aasNode_t & GetNode(int index) const
Definition: AASFile.h:304
unsigned int crc
Definition: AASFile.h:335
idList< aasFace_t > faces
Definition: AASFile.h:341
idVec3 endpos
Definition: AASFile.h:200
GLuint GLuint end
Definition: glext.h:2845
idStr fileExtension
Definition: AASFile.h:222
idList< aasPortal_t > portals
Definition: AASFile.h:345
idVec3 end
Definition: AASFile.h:99
bool FromFile(const idStr &fileName)
Definition: AASFile.cpp:348
Definition: Dict.h:65
virtual idVec3 AreaCenter(int areaNum) const =0
#define NULL
Definition: Lib.h:88
const aasIndex_t & GetFaceIndex(int index) const
Definition: AASFile.h:300
bool allowFlyReachabilities
Definition: AASFile.h:221
float maxFallHeight
Definition: AASFile.h:231
int GetNumAreas(void) const
Definition: AASFile.h:301
Definition: Plane.h:71
int blockingAreaNum
Definition: AASFile.h:203
idPlaneSet planeList
Definition: AASFile.h:337
idReachability * next
Definition: AASFile.h:104
virtual void PrintInfo(void) const =0
int lastAreaNum
Definition: AASFile.h:202
virtual void PushPointIntoAreaNum(int areaNum, idVec3 &point) const =0
virtual idBounds EdgeBounds(int edgeNum) const =0
unsigned int GetCRC(void) const
Definition: AASFile.h:287
int firstPortal
Definition: AASFile.h:188
float fraction
Definition: AASFile.h:199
void SetPortalMaxTravelTime(int index, int time)
Definition: AASFile.h:314
int GetNumFaces(void) const
Definition: AASFile.h:297
virtual int PointAreaNum(const idVec3 &origin) const =0
aasTrace_s(void)
Definition: AASFile.h:207
const aasIndex_t & GetPortalIndex(int index) const
Definition: AASFile.h:308
bool FromParser(idLexer &src)
Definition: AASFile.cpp:258
virtual idBounds AreaBounds(int areaNum) const =0
unsigned short flags
Definition: AASFile.h:148
float maxWaterJumpHeight
Definition: AASFile.h:230
#define MAX_AAS_BOUNDING_BOXES
Definition: AASFile.h:90
virtual idVec3 EdgeCenter(int edgeNum) const =0
GLubyte GLubyte b
Definition: glext.h:4662
virtual idBounds FaceBounds(int faceNum) const =0
struct aasTrace_s aasTrace_t
idVec3 * points
Definition: AASFile.h:206
idVec3 invGravityDir
Definition: AASFile.h:226
idList< aasEdge_t > edges
Definition: AASFile.h:339
idList< aasVertex_t > vertices
Definition: AASFile.h:338
int planeNum
Definition: AASFile.h:201
idReachability * rev_reach
Definition: AASFile.h:166
int tt_waterJump
Definition: AASFile.h:236
int GetNumPortalIndexes(void) const
Definition: AASFile.h:307
tuple f
Definition: idal.py:89
idVec3 aasVertex_t
Definition: AASFile.h:138
short clusterAreaNum[2]
Definition: AASFile.h:179
int numEdges
Definition: AASFile.h:149
void RemoveAreaTravelFlag(int index, int flag)
Definition: AASFile.h:316
int Num(void) const
Definition: List.h:265
unsigned char byte
Definition: Lib.h:75
byte disableCount
Definition: AASFile.h:103
const GLcharARB * name
Definition: glext.h:3629
int firstFace
Definition: AASFile.h:157
idList< aasArea_t > areas
Definition: AASFile.h:343
Definition: Str.h:116
virtual idVec3 FaceCenter(int faceNum) const =0
int tt_barrierJump
Definition: AASFile.h:234
bool WriteToFile(idFile *fp) const
Definition: AASFile.cpp:468
int numFaces
Definition: AASFile.h:156
int getOutOfSolid
Definition: AASFile.h:197
int numBoundingBoxes
Definition: AASFile.h:214
virtual int PointReachableAreaNum(const idVec3 &origin, const idBounds &searchBounds, const int areaFlags, const int excludeTravelFlags) const =0
idList< aasIndex_t > portalIndex
Definition: AASFile.h:346
short areas[2]
Definition: AASFile.h:151
bool noOptimize
Definition: AASFile.h:219
int numReachableAreas
Definition: AASFile.h:186
struct aasNode_s aasNode_t
const idPlane & GetPlane(int index) const
Definition: AASFile.h:290
idStr name
Definition: AASFile.h:334
int GetNumClusters(void) const
Definition: AASFile.h:309
Definition: List.h:84
virtual ~idAASFile(void)
Definition: AASFile.h:284
int numAreas
Definition: AASFile.h:185
bool playerFlood
Definition: AASFile.h:218
const aasArea_t & GetArea(int index)
Definition: AASFile.h:302
int travelFlags
Definition: AASFile.h:164
GLuint start
Definition: glext.h:2845
struct aasCluster_s aasCluster_t
float maxBarrierHeight
Definition: AASFile.h:229