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