home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / game / ai / AAS.h < prev    next >
C/C++ Source or Header  |  2005-11-14  |  8KB  |  164 lines

  1.  
  2. #ifndef __AAS_H__
  3. #define __AAS_H__
  4.  
  5. /*
  6. ===============================================================================
  7.  
  8.     Area Awareness System
  9.  
  10. ===============================================================================
  11. */
  12.  
  13. enum {
  14.     PATHTYPE_WALK,
  15.     PATHTYPE_WALKOFFLEDGE,
  16.     PATHTYPE_BARRIERJUMP,
  17.     PATHTYPE_JUMP
  18. };
  19.  
  20. typedef struct aasPath_s {
  21.     int                            type;            // path type
  22.     idVec3                        moveGoal;        // point the AI should move towards
  23.     int                            moveAreaNum;    // number of the area the AI should move towards
  24.     idVec3                        secondaryGoal;    // secondary move goal for complex navigation
  25.     const idReachability *        reachability;    // reachability used for navigation
  26. } aasPath_t;
  27.  
  28.  
  29. typedef struct aasGoal_s {
  30.     int                            areaNum;        // area the goal is in
  31.     idVec3                        origin;            // position of goal
  32. } aasGoal_t;
  33.  
  34.  
  35. typedef struct aasObstacle_s {
  36.     idBounds                    absBounds;        // absolute bounds of obstacle
  37.     idBounds                    expAbsBounds;    // expanded absolute bounds of obstacle
  38. } aasObstacle_t;
  39.  
  40. class idAASCallback {
  41. public:
  42.     virtual    ~idAASCallback ( void );
  43.     
  44.     enum testResult_t {
  45.         TEST_OK,
  46.         TEST_BADAREA,
  47.         TEST_BADPOINT
  48.     };
  49.     
  50.     virtual void                Init        ( void );
  51.     virtual void                Finish        ( void );
  52.     
  53.     testResult_t                Test        ( class idAAS *aas, int areaNum, const idVec3& origin, float minDistance, float maxDistance, const idVec3* point, aasGoal_t& goal );
  54.     
  55. protected:
  56.  
  57.     virtual bool                TestArea    ( class idAAS *aas, int areaNum, const aasArea_t& area );
  58.     virtual    bool                TestPoint    ( class idAAS *aas, const idVec3& pos, const float zAllow=0.0f );
  59.     
  60. private:
  61.  
  62.     bool        TestPointDistance        ( const idVec3& origin, const idVec3& point, float minDistance, float maxDistance );
  63. };
  64.  
  65. typedef int aasHandle_t;
  66.  
  67. class idAAS {
  68. public:
  69.     static idAAS *                Alloc( void );
  70.     virtual                        ~idAAS( void ) = 0;
  71.                                 // Initialize for the given map.
  72.     virtual bool                Init( const idStr &mapName, unsigned int mapFileCRC ) = 0;
  73. // RAVEN BEGIN
  74. // jscott: added
  75.                                 // Prints out the memory used by this AAS
  76.     virtual size_t                StatsSummary( void ) const = 0;
  77. // RAVEN END
  78.  
  79. // RAVEN BEGIN
  80. // mwhitlock: Dynamic memory consolidation
  81. #if defined(_RV_MEM_SYS_SUPPORT)
  82.     virtual void                Shutdown( void ) = 0;
  83. #endif
  84. // RAVEN END
  85.                                 // Print AAS stats.
  86.     virtual void                Stats( void ) const = 0;
  87.                                 // Test from the given origin.
  88.     virtual void                Test( const idVec3 &origin ) = 0;
  89.                                 // Get the AAS settings.
  90.     virtual const idAASSettings *GetSettings( void ) const = 0;
  91.                                 // Returns the number of the area the origin is in.
  92.     virtual int                    PointAreaNum( const idVec3 &origin ) const = 0;
  93.                                 // Returns the number of the nearest reachable area for the given point.
  94.     virtual int                    PointReachableAreaNum( const idVec3 &origin, const idBounds &bounds, const int areaFlags ) const = 0;
  95.                                 // Returns the number of the first reachable area in or touching the bounds.
  96.     virtual int                    BoundsReachableAreaNum( const idBounds &bounds, const int areaFlags ) const = 0;
  97.                                 // Push the point into the area.
  98.     virtual void                PushPointIntoAreaNum( int areaNum, idVec3 &origin ) const = 0;
  99.                                 // Returns a reachable point inside the given area.
  100.     virtual idVec3                AreaCenter( int areaNum ) const = 0;
  101. // RAVEN BEGIN
  102. // bdube: added
  103.                                 // Returns a reachable point inside the given area.
  104.     virtual float                AreaRadius( int areaNum ) const = 0;
  105.     virtual idBounds &            AreaBounds( int areaNum ) const = NULL;
  106.     virtual float                AreaCeiling( int areaNum ) const = 0;
  107. // RAVEN END    
  108.                                 // Returns the area flags.
  109.     virtual int                    AreaFlags( int areaNum ) const = 0;
  110.                                 // Returns the travel flags for traveling through the area.
  111.     virtual int                    AreaTravelFlags( int areaNum ) const = 0;
  112.                                 // Trace through the areas and report the first collision.
  113.     virtual bool                Trace( aasTrace_t &trace, const idVec3 &start, const idVec3 &end ) const = 0;
  114.                                 // Get a plane for a trace.
  115.     virtual const idPlane &        GetPlane( int planeNum ) const = 0;
  116.                                 // Get wall edges.
  117.     virtual int                    GetWallEdges( int areaNum, const idBounds &bounds, int travelFlags, int *edges, int maxEdges ) const = 0;
  118.                                 // Sort the wall edges to create continuous sequences of walls.
  119.     virtual void                SortWallEdges( int *edges, int numEdges ) const = 0;
  120.                                 // Get the vertex numbers for an edge.
  121.     virtual void                GetEdgeVertexNumbers( int edgeNum, int verts[2] ) const = 0;
  122.                                 // Get an edge.
  123.     virtual void                GetEdge( int edgeNum, idVec3 &start, idVec3 &end ) const = 0;
  124.                                 // Find all areas within or touching the bounds with the given contents and disable/enable them for routing.
  125.     virtual bool                SetAreaState( const idBounds &bounds, const int areaContents, bool disabled ) = 0;
  126.                                 // Add an obstacle to the routing system.
  127.     virtual aasHandle_t            AddObstacle( const idBounds &bounds ) = 0;
  128.                                 // Remove an obstacle from the routing system.
  129.     virtual void                RemoveObstacle( const aasHandle_t handle ) = 0;
  130.                                 // Remove all obstacles from the routing system.
  131.     virtual void                RemoveAllObstacles( void ) = 0;
  132.                                 // Returns the travel time towards the goal area in 100th of a second.
  133.     virtual int                    TravelTimeToGoalArea( int areaNum, const idVec3 &origin, int goalAreaNum, int travelFlags ) const = 0;
  134.                                 // Get the travel time and first reachability to be used towards the goal, returns true if there is a path.
  135.     virtual bool                RouteToGoalArea( int areaNum, const idVec3 origin, int goalAreaNum, int travelFlags, int &travelTime, idReachability **reach ) const = 0;
  136.                                 // Creates a walk path towards the goal.
  137.     virtual bool                WalkPathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags ) const = 0;
  138.                                 // Returns true if one can walk along a straight line from the origin to the goal origin.
  139.     virtual bool                WalkPathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const = 0;
  140.                                 // Creates a fly path towards the goal.
  141.     virtual bool                FlyPathToGoal( aasPath_t &path, int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags ) const = 0;
  142.                                 // Returns true if one can fly along a straight line from the origin to the goal origin.
  143.     virtual bool                FlyPathValid( int areaNum, const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin, int travelFlags, idVec3 &endPos, int &endAreaNum ) const = 0;
  144.                                 // Show the walk path from the origin towards the area.
  145.     virtual void                ShowWalkPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const = 0;
  146.                                 // Show the fly path from the origin towards the area.
  147.     virtual void                ShowFlyPath( const idVec3 &origin, int goalAreaNum, const idVec3 &goalOrigin ) const = 0;
  148.                                 // Find the nearest goal which satisfies the callback.
  149.     virtual bool                FindNearestGoal( aasGoal_t &goal, int areaNum, const idVec3 origin, const idVec3 &target, int travelFlags, float minDistance, float maxDistance, aasObstacle_t *obstacles, int numObstacles, idAASCallback &callback ) const = 0;
  150.  
  151. // RAVEN BEGIN 
  152. // CDR : Added Area Wall Extraction For AASTactical
  153.     virtual idAASFile*            GetFile( void ) = 0;
  154. // cdr: Alternate Routes Bug
  155.      virtual void                SetReachabilityState( idReachability* reach, bool enable ) = 0;
  156.  
  157. // rjohnson: added more debug drawing
  158.     virtual void                ShowAreas( const idVec3 &origin, bool ShowProblemAreas = false ) const = 0;
  159.     virtual bool                IsValid( void ) const = 0;
  160. // RAVEN END
  161. };
  162.  
  163. #endif /* !__AAS_H__ */
  164.