Quake-III-Arena

Quake III Arena GPL Source Release
Log | Files | Refs

aasfile.h (8911B)


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