]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/game/ai/AAS.h
hello world
[icculus/iodoom3.git] / neo / game / ai / AAS.h
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 __AAS_H__
30 #define __AAS_H__
31
32 /*
33 ===============================================================================
34
35         Area Awareness System
36
37 ===============================================================================
38 */
39
40 enum {
41         PATHTYPE_WALK,
42         PATHTYPE_WALKOFFLEDGE,
43         PATHTYPE_BARRIERJUMP,
44         PATHTYPE_JUMP
45 };
46
47 typedef struct aasPath_s {
48         int                                                     type;                   // path type
49         idVec3                                          moveGoal;               // point the AI should move towards
50         int                                                     moveAreaNum;    // number of the area the AI should move towards
51         idVec3                                          secondaryGoal;  // secondary move goal for complex navigation
52         const idReachability *          reachability;   // reachability used for navigation
53 } aasPath_t;
54
55
56 typedef struct aasGoal_s {
57         int                                                     areaNum;                // area the goal is in
58         idVec3                                          origin;                 // position of goal
59 } aasGoal_t;
60
61
62 typedef struct aasObstacle_s {
63         idBounds                                        absBounds;              // absolute bounds of obstacle
64         idBounds                                        expAbsBounds;   // expanded absolute bounds of obstacle
65 } aasObstacle_t;
66
67 class idAASCallback {
68 public:
69         virtual                                         ~idAASCallback() {};
70         virtual bool                            TestArea( const class idAAS *aas, int areaNum ) = 0;
71 };
72
73 typedef int aasHandle_t;
74
75 class idAAS {
76 public:
77         static idAAS *                          Alloc( void );
78         virtual                                         ~idAAS( void ) = 0;
79                                                                 // Initialize for the given map.
80         virtual bool                            Init( const idStr &mapName, unsigned int mapFileCRC ) = 0;
81                                                                 // Print AAS stats.
82         virtual void                            Stats( void ) const = 0;
83                                                                 // Test from the given origin.
84         virtual void                            Test( const idVec3 &origin ) = 0;
85                                                                 // Get the AAS settings.
86         virtual const idAASSettings *GetSettings( void ) const = 0;
87                                                                 // Returns the number of the area the origin is in.
88         virtual int                                     PointAreaNum( const idVec3 &origin ) const = 0;
89                                                                 // Returns the number of the nearest reachable area for the given point.
90         virtual int                                     PointReachableAreaNum( const idVec3 &origin, const idBounds &bounds, const int areaFlags ) const = 0;
91                                                                 // Returns the number of the first reachable area in or touching the bounds.
92         virtual int                                     BoundsReachableAreaNum( const idBounds &bounds, const int areaFlags ) const = 0;
93                                                                 // Push the point into the area.
94         virtual void                            PushPointIntoAreaNum( int areaNum, idVec3 &origin ) const = 0;
95                                                                 // Returns a reachable point inside the given area.
96         virtual idVec3                          AreaCenter( int areaNum ) const = 0;
97                                                                 // Returns the area flags.
98         virtual int                                     AreaFlags( int areaNum ) const = 0;
99                                                                 // Returns the travel flags for traveling through the area.
100         virtual int                                     AreaTravelFlags( int areaNum ) const = 0;
101                                                                 // Trace through the areas and report the first collision.
102         virtual bool                            Trace( aasTrace_t &trace, const idVec3 &start, const idVec3 &end ) const = 0;
103                                                                 // Get a plane for a trace.
104         virtual const idPlane &         GetPlane( int planeNum ) const = 0;
105                                                                 // Get wall edges.
106         virtual int                                     GetWallEdges( int areaNum, const idBounds &bounds, int travelFlags, int *edges, int maxEdges ) const = 0;
107                                                                 // Sort the wall edges to create continuous sequences of walls.
108         virtual void                            SortWallEdges( int *edges, int numEdges ) const = 0;
109                                                                 // Get the vertex numbers for an edge.
110         virtual void                            GetEdgeVertexNumbers( int edgeNum, int verts[2] ) const = 0;
111                                                                 // Get an edge.
112         virtual void                            GetEdge( int edgeNum, idVec3 &start, idVec3 &end ) const = 0;
113                                                                 // Find all areas within or touching the bounds with the given contents and disable/enable them for routing.
114         virtual bool                            SetAreaState( const idBounds &bounds, const int areaContents, bool disabled ) = 0;
115                                                                 // Add an obstacle to the routing system.
116         virtual aasHandle_t                     AddObstacle( const idBounds &bounds ) = 0;
117                                                                 // Remove an obstacle from the routing system.
118         virtual void                            RemoveObstacle( const aasHandle_t handle ) = 0;
119                                                                 // Remove all obstacles from the routing system.
120         virtual void                            RemoveAllObstacles( void ) = 0;
121                                                                 // Returns the travel time towards the goal area in 100th of a second.
122         virtual int                                     TravelTimeToGoalArea( int areaNum, const idVec3 &origin, int goalAreaNum, int travelFlags ) const = 0;
123                                                                 // Get the travel time and first reachability to be used towards the goal, returns true if there is a path.
124         virtual bool                            RouteToGoalArea( int areaNum, const idVec3 origin, int goalAreaNum, int travelFlags, int &travelTime, idReachability **reach ) const = 0;
125                                                                 // Creates a walk path towards the goal.
126         virtual bool                            WalkPathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags ) const = 0;
127                                                                 // Returns true if one can walk along a straight line from the origin to the goal origin.
128         virtual bool                            WalkPathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const = 0;
129                                                                 // Creates a fly path towards the goal.
130         virtual bool                            FlyPathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags ) const = 0;
131                                                                 // Returns true if one can fly along a straight line from the origin to the goal origin.
132         virtual bool                            FlyPathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const = 0;
133                                                                 // Show the walk path from the origin towards the area.
134         virtual void                            ShowWalkPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const = 0;
135                                                                 // Show the fly path from the origin towards the area.
136         virtual void                            ShowFlyPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const = 0;
137                                                                 // Find the nearest goal which satisfies the callback.
138         virtual bool                            FindNearestGoal( aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, aasObstacle_t *obstacles, int numObstacles, idAASCallback &callback ) const = 0;
139 };
140
141 #endif /* !__AAS_H__ */