1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4 Copyright (C) 2000-2006 Tim Angus
5 
6 This file is part of Tremulous.
7 
8 Tremulous is free software; you can redistribute it
9 and/or modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the License,
11 or (at your option) any later version.
12 
13 Tremulous is distributed in the hope that it will be
14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Tremulous; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 ===========================================================================
22 */
23 
24 
25 //NOTE:	int =	default signed
26 //				default long
27 
28 #define AASID						(('S'<<24)+('A'<<16)+('A'<<8)+'E')
29 #define AASVERSION_OLD				4
30 #define AASVERSION					5
31 
32 //presence types
33 #define PRESENCE_NONE				1
34 #define PRESENCE_NORMAL				2
35 #define PRESENCE_CROUCH				4
36 
37 //travel types
38 #define MAX_TRAVELTYPES				32
39 #define TRAVEL_INVALID				1		//temporary not possible
40 #define TRAVEL_WALK					2		//walking
41 #define TRAVEL_CROUCH				3		//crouching
42 #define TRAVEL_BARRIERJUMP			4		//jumping onto a barrier
43 #define TRAVEL_JUMP					5		//jumping
44 #define TRAVEL_LADDER				6		//climbing a ladder
45 #define TRAVEL_WALKOFFLEDGE			7		//walking of a ledge
46 #define TRAVEL_SWIM					8		//swimming
47 #define TRAVEL_WATERJUMP			9		//jump out of the water
48 #define TRAVEL_TELEPORT				10		//teleportation
49 #define TRAVEL_ELEVATOR				11		//travel by elevator
50 #define TRAVEL_ROCKETJUMP			12		//rocket jumping required for travel
51 #define TRAVEL_BFGJUMP				13		//bfg jumping required for travel
52 #define TRAVEL_GRAPPLEHOOK			14		//grappling hook required for travel
53 #define TRAVEL_DOUBLEJUMP			15		//double jump
54 #define TRAVEL_RAMPJUMP				16		//ramp jump
55 #define TRAVEL_STRAFEJUMP			17		//strafe jump
56 #define TRAVEL_JUMPPAD				18		//jump pad
57 #define TRAVEL_FUNCBOB				19		//func bob
58 
59 //additional travel flags
60 #define TRAVELTYPE_MASK				0xFFFFFF
61 #define TRAVELFLAG_NOTTEAM1			(1 << 24)
62 #define TRAVELFLAG_NOTTEAM2			(2 << 24)
63 
64 //face flags
65 #define FACE_SOLID					1		//just solid at the other side
66 #define FACE_LADDER					2		//ladder
67 #define FACE_GROUND					4		//standing on ground when in this face
68 #define FACE_GAP					8		//gap in the ground
69 #define FACE_LIQUID					16		//face seperating two areas with liquid
70 #define FACE_LIQUIDSURFACE			32		//face seperating liquid and air
71 #define FACE_BRIDGE					64		//can walk over this face if bridge is closed
72 
73 //area contents
74 #define AREACONTENTS_WATER				1
75 #define AREACONTENTS_LAVA				2
76 #define AREACONTENTS_SLIME				4
77 #define AREACONTENTS_CLUSTERPORTAL		8
78 #define AREACONTENTS_TELEPORTAL			16
79 #define AREACONTENTS_ROUTEPORTAL		32
80 #define AREACONTENTS_TELEPORTER			64
81 #define AREACONTENTS_JUMPPAD			128
82 #define AREACONTENTS_DONOTENTER			256
83 #define	AREACONTENTS_VIEWPORTAL			512
84 #define AREACONTENTS_MOVER				1024
85 #define AREACONTENTS_NOTTEAM1			2048
86 #define AREACONTENTS_NOTTEAM2			4096
87 //number of model of the mover inside this area
88 #define AREACONTENTS_MODELNUMSHIFT		24
89 #define AREACONTENTS_MAXMODELNUM		0xFF
90 #define AREACONTENTS_MODELNUM			(AREACONTENTS_MAXMODELNUM << AREACONTENTS_MODELNUMSHIFT)
91 
92 //area flags
93 #define AREA_GROUNDED				1		//bot can stand on the ground
94 #define AREA_LADDER					2		//area contains one or more ladder faces
95 #define AREA_LIQUID					4		//area contains a liquid
96 #define AREA_DISABLED				8		//area is disabled for routing when set
97 #define AREA_BRIDGE					16		//area ontop of a bridge
98 
99 //aas file header lumps
100 #define AAS_LUMPS					14
101 #define AASLUMP_BBOXES				0
102 #define AASLUMP_VERTEXES			1
103 #define AASLUMP_PLANES				2
104 #define AASLUMP_EDGES				3
105 #define AASLUMP_EDGEINDEX			4
106 #define AASLUMP_FACES				5
107 #define AASLUMP_FACEINDEX			6
108 #define AASLUMP_AREAS				7
109 #define AASLUMP_AREASETTINGS		8
110 #define AASLUMP_REACHABILITY		9
111 #define AASLUMP_NODES				10
112 #define AASLUMP_PORTALS				11
113 #define AASLUMP_PORTALINDEX			12
114 #define AASLUMP_CLUSTERS			13
115 
116 //========== bounding box =========
117 
118 //bounding box
119 typedef struct aas_bbox_s
120 {
121 	int presencetype;
122 	int flags;
123 	vec3_t mins, maxs;
124 } aas_bbox_t;
125 
126 //============ settings ===========
127 
128 //reachability to another area
129 typedef struct aas_reachability_s
130 {
131 	int areanum;						//number of the reachable area
132 	int facenum;						//number of the face towards the other area
133 	int edgenum;						//number of the edge towards the other area
134 	vec3_t start;						//start point of inter area movement
135 	vec3_t end;							//end point of inter area movement
136 	int traveltype;					//type of travel required to get to the area
137 	unsigned short int traveltime;//travel time of the inter area movement
138 } aas_reachability_t;
139 
140 //area settings
141 typedef struct aas_areasettings_s
142 {
143 	//could also add all kind of statistic fields
144 	int contents;						//contents of the area
145 	int areaflags;						//several area flags
146 	int presencetype;					//how a bot can be present in this area
147 	int cluster;						//cluster the area belongs to, if negative it's a portal
148 	int clusterareanum;				//number of the area in the cluster
149 	int numreachableareas;			//number of reachable areas from this one
150 	int firstreachablearea;			//first reachable area in the reachable area index
151 } aas_areasettings_t;
152 
153 //cluster portal
154 typedef struct aas_portal_s
155 {
156 	int areanum;						//area that is the actual portal
157 	int frontcluster;					//cluster at front of portal
158 	int backcluster;					//cluster at back of portal
159 	int clusterareanum[2];			//number of the area in the front and back cluster
160 } aas_portal_t;
161 
162 //cluster portal index
163 typedef int aas_portalindex_t;
164 
165 //cluster
166 typedef struct aas_cluster_s
167 {
168 	int numareas;						//number of areas in the cluster
169 	int numreachabilityareas;			//number of areas with reachabilities
170 	int numportals;						//number of cluster portals
171 	int firstportal;					//first cluster portal in the index
172 } aas_cluster_t;
173 
174 //============ 3d definition ============
175 
176 typedef vec3_t aas_vertex_t;
177 
178 //just a plane in the third dimension
179 typedef struct aas_plane_s
180 {
181 	vec3_t normal;						//normal vector of the plane
182 	float dist;							//distance of the plane (normal vector * distance = point in plane)
183 	int type;
184 } aas_plane_t;
185 
186 //edge
187 typedef struct aas_edge_s
188 {
189 	int v[2];							//numbers of the vertexes of this edge
190 } aas_edge_t;
191 
192 //edge index, negative if vertexes are reversed
193 typedef int aas_edgeindex_t;
194 
195 //a face bounds an area, often it will also seperate two areas
196 typedef struct aas_face_s
197 {
198 	int planenum;						//number of the plane this face is in
199 	int faceflags;						//face flags (no use to create face settings for just this field)
200 	int numedges;						//number of edges in the boundary of the face
201 	int firstedge;						//first edge in the edge index
202 	int frontarea;						//area at the front of this face
203 	int backarea;						//area at the back of this face
204 } aas_face_t;
205 
206 //face index, stores a negative index if backside of face
207 typedef int aas_faceindex_t;
208 
209 //area with a boundary of faces
210 typedef struct aas_area_s
211 {
212 	int areanum;						//number of this area
213 	//3d definition
214 	int numfaces;						//number of faces used for the boundary of the area
215 	int firstface;						//first face in the face index used for the boundary of the area
216 	vec3_t mins;						//mins of the area
217 	vec3_t maxs;						//maxs of the area
218 	vec3_t center;						//'center' of the area
219 } aas_area_t;
220 
221 //nodes of the bsp tree
222 typedef struct aas_node_s
223 {
224 	int planenum;
225 	int children[2];					//child nodes of this node, or areas as leaves when negative
226 										//when a child is zero it's a solid leaf
227 } aas_node_t;
228 
229 //=========== aas file ===============
230 
231 //header lump
232 typedef struct
233 {
234 	int fileofs;
235 	int filelen;
236 } aas_lump_t;
237 
238 //aas file header
239 typedef struct aas_header_s
240 {
241 	int ident;
242 	int version;
243 	int bspchecksum;
244 	//data entries
245 	aas_lump_t lumps[AAS_LUMPS];
246 } aas_header_t;
247 
248 
249 //====== additional information ======
250 /*
251 
252 -	when a node child is a solid leaf the node child number is zero
253 -	two adjacent areas (sharing a plane at opposite sides) share a face
254 	this face is a portal between the areas
255 -	when an area uses a face from the faceindex with a positive index
256 	then the face plane normal points into the area
257 -	the face edges are stored counter clockwise using the edgeindex
258 -	two adjacent convex areas (sharing a face) only share One face
259 	this is a simple result of the areas being convex
260 -	the areas can't have a mixture of ground and gap faces
261 	other mixtures of faces in one area are allowed
262 -	areas with the AREACONTENTS_CLUSTERPORTAL in the settings have
263 	the cluster number set to the negative portal number
264 -	edge zero is a dummy
265 -	face zero is a dummy
266 -	area zero is a dummy
267 -	node zero is a dummy
268 */
269