aasfile.h (8238B)
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 //face flags 59 #define FACE_SOLID 1 //just solid at the other side 60 #define FACE_LADDER 2 //ladder 61 #define FACE_GROUND 4 //standing on ground when in this face 62 #define FACE_GAP 8 //gap in the ground 63 #define FACE_LIQUID 16 64 #define FACE_LIQUIDSURFACE 32 65 66 //area contents 67 #define AREACONTENTS_WATER 1 68 #define AREACONTENTS_LAVA 2 69 #define AREACONTENTS_SLIME 4 70 #define AREACONTENTS_CLUSTERPORTAL 8 71 #define AREACONTENTS_TELEPORTAL 16 72 #define AREACONTENTS_ROUTEPORTAL 32 73 #define AREACONTENTS_TELEPORTER 64 74 #define AREACONTENTS_JUMPPAD 128 75 #define AREACONTENTS_DONOTENTER 256 76 #define AREACONTENTS_VIEWPORTAL 512 77 78 //area flags 79 #define AREA_GROUNDED 1 //bot can stand on the ground 80 #define AREA_LADDER 2 //area contains one or more ladder faces 81 #define AREA_LIQUID 4 //area contains a liquid 82 83 //aas file header lumps 84 #define AAS_LUMPS 14 85 #define AASLUMP_BBOXES 0 86 #define AASLUMP_VERTEXES 1 87 #define AASLUMP_PLANES 2 88 #define AASLUMP_EDGES 3 89 #define AASLUMP_EDGEINDEX 4 90 #define AASLUMP_FACES 5 91 #define AASLUMP_FACEINDEX 6 92 #define AASLUMP_AREAS 7 93 #define AASLUMP_AREASETTINGS 8 94 #define AASLUMP_REACHABILITY 9 95 #define AASLUMP_NODES 10 96 #define AASLUMP_PORTALS 11 97 #define AASLUMP_PORTALINDEX 12 98 #define AASLUMP_CLUSTERS 13 99 100 //========== bounding box ========= 101 102 //bounding box 103 typedef struct aas_bbox_s 104 { 105 int presencetype; 106 int flags; 107 vec3_t mins, maxs; 108 } aas_bbox_t; 109 110 //============ settings =========== 111 112 //reachability to another area 113 typedef struct aas_reachability_s 114 { 115 int areanum; //number of the reachable area 116 int facenum; //number of the face towards the other area 117 int edgenum; //number of the edge towards the other area 118 vec3_t start; //start point of inter area movement 119 vec3_t end; //end point of inter area movement 120 int traveltype; //type of travel required to get to the area 121 unsigned short int traveltime;//travel time of the inter area movement 122 } aas_reachability_t; 123 124 //area settings 125 typedef struct aas_areasettings_s 126 { 127 //could also add all kind of statistic fields 128 int contents; //contents of the convex area 129 int areaflags; //several area flags 130 int presencetype; //how a bot can be present in this convex area 131 int cluster; //cluster the area belongs to, if negative it's a portal 132 int clusterareanum; //number of the area in the cluster 133 int numreachableareas; //number of reachable areas from this one 134 int firstreachablearea; //first reachable area in the reachable area index 135 } aas_areasettings_t; 136 137 //cluster portal 138 typedef struct aas_portal_s 139 { 140 int areanum; //area that is the actual portal 141 int frontcluster; //cluster at front of portal 142 int backcluster; //cluster at back of portal 143 int clusterareanum[2]; //number of the area in the front and back cluster 144 } aas_portal_t; 145 146 //cluster portal index 147 typedef int aas_portalindex_t; 148 149 //cluster 150 typedef struct aas_cluster_s 151 { 152 int numareas; //number of areas in the cluster 153 int numreachabilityareas; //number of areas with reachabilities 154 int numportals; //number of cluster portals 155 int firstportal; //first cluster portal in the index 156 } aas_cluster_t; 157 158 //============ 3d definition ============ 159 160 typedef vec3_t aas_vertex_t; 161 162 //just a plane in the third dimension 163 typedef struct aas_plane_s 164 { 165 vec3_t normal; //normal vector of the plane 166 float dist; //distance of the plane (normal vector * distance = point in plane) 167 int type; 168 } aas_plane_t; 169 170 //edge 171 typedef struct aas_edge_s 172 { 173 int v[2]; //numbers of the vertexes of this edge 174 } aas_edge_t; 175 176 //edge index, negative if vertexes are reversed 177 typedef int aas_edgeindex_t; 178 179 //a face bounds a convex area, often it will also seperate two convex areas 180 typedef struct aas_face_s 181 { 182 int planenum; //number of the plane this face is in 183 int faceflags; //face flags (no use to create face settings for just this field) 184 int numedges; //number of edges in the boundary of the face 185 int firstedge; //first edge in the edge index 186 int frontarea; //convex area at the front of this face 187 int backarea; //convex area at the back of this face 188 } aas_face_t; 189 190 //face index, stores a negative index if backside of face 191 typedef int aas_faceindex_t; 192 193 //convex area with a boundary of faces 194 typedef struct aas_area_s 195 { 196 int areanum; //number of this area 197 //3d definition 198 int numfaces; //number of faces used for the boundary of the convex area 199 int firstface; //first face in the face index used for the boundary of the convex area 200 vec3_t mins; //mins of the convex area 201 vec3_t maxs; //maxs of the convex area 202 vec3_t center; //'center' of the convex area 203 } aas_area_t; 204 205 //nodes of the bsp tree 206 typedef struct aas_node_s 207 { 208 int planenum; 209 int children[2]; //child nodes of this node, or convex areas as leaves when negative 210 //when a child is zero it's a solid leaf 211 } aas_node_t; 212 213 //=========== aas file =============== 214 215 //header lump 216 typedef struct 217 { 218 int fileofs; 219 int filelen; 220 } aas_lump_t; 221 222 //aas file header 223 typedef struct aas_header_s 224 { 225 int ident; 226 int version; 227 int bspchecksum; 228 //data entries 229 aas_lump_t lumps[AAS_LUMPS]; 230 } aas_header_t; 231 232 233 //====== additional information ====== 234 /* 235 236 - when a node child is a solid leaf the node child number is zero 237 - two adjacent areas (sharing a plane at opposite sides) share a face 238 this face is a portal between the areas 239 - when an area uses a face from the faceindex with a positive index 240 then the face plane normal points into the area 241 - the face edges are stored counter clockwise using the edgeindex 242 - two adjacent convex areas (sharing a face) only share One face 243 this is a simple result of the areas being convex 244 - the convex areas can't have a mixture of ground and gap faces 245 other mixtures of faces in one area are allowed 246 - areas with the AREACONTENTS_CLUSTERPORTAL in the settings have 247 cluster number zero 248 - edge zero is a dummy 249 - face zero is a dummy 250 - area zero is a dummy 251 - node zero is a dummy 252 */