AIBehaviors Class Reference

#include <aiBehaviors.h>

Collaboration diagram for AIBehaviors:
Collaboration graph
[legend]

List of all members.

Public Types

enum  _behavior_type {
  _none = 0x00000, _seek = 0x00002, _flee = 0x00004, _flee_activate = 0x00100,
  _arrival = 0x00008, _arrival_activate = 0x01000, _wander = 0x00010, _pursue = 0x00040,
  _evade = 0x00080, _evade_activate = 0x00800, _flock = 0x00200, _flock_activate = 0x00400,
  _obstacle_avoidance = 0x02000, _obstacle_avoidance_activate = 0x04000
}

Public Member Functions

 AIBehaviors ()
 ~AIBehaviors ()
bool is_on (_behavior_type bt)
bool is_on (string ai_type)
bool is_off (_behavior_type bt)
bool is_off (string ai_type)
void turn_on (string ai_type)
void turn_off (string ai_type)
bool is_conflict ()
void accumulate_force (string force_type, LVecBase3f force)
LVecBase3f calculate_prioritized ()
void flock_activate ()
LVecBase3f do_flock ()
int char_to_int (string ai_type)
void seek (LVecBase3f pos, float seek_wt=1.0)
void flee (NodePath target_object, double panic_distance=10.0, double relax_distance=10.0, float flee_wt=1.0)
void flee (LVecBase3f pos, double panic_distance=10.0, double relax_distance=10.0, float flee_wt=1.0)
void pursue (NodePath target_object, float pursue_wt=1.0)
void evade (NodePath target_object, double panic_distance=10.0, double relax_distance=10.0, float evade_wt=1.0)
void arrival (double distance=10.0)
void flock (float flock_wt)
void wander (double wander_radius=5.0, int flag=0, double aoe=0.0, float wander_weight=1.0)
void obstacle_avoidance (float feeler_length=1.0)
void path_follow (float follow_wt)
void add_to_path (LVecBase3f pos)
void start_follow (string type="normal")
void init_path_find (const char *navmesh_filename)
void path_find_to (LVecBase3f pos, string type="normal")
void path_find_to (NodePath target, string type="normal")
void add_static_obstacle (NodePath obstacle)
void add_dynamic_obstacle (NodePath obstacle)
void remove_ai (string ai_type)
void pause_ai (string ai_type)
void resume_ai (string ai_type)
string behavior_status (string ai_type)

Public Attributes

AICharacter_ai_char
Flock_flock_group
int _behaviors_flags
LVecBase3f _steering_force
Seek_seek_obj
LVecBase3f _seek_force
Flee_flee_obj
LVecBase3f _flee_force
ListFlee _flee_list
 This list is used if the ai character needs to flee from multiple onjects.
ListFlee::iterator _flee_itr
Pursue_pursue_obj
LVecBase3f _pursue_force
Evade_evade_obj
LVecBase3f _evade_force
ListEvade _evade_list
 This list is used if the ai character needs to evade from multiple onjects.
ListEvade::iterator _evade_itr
Arrival_arrival_obj
LVecBase3f _arrival_force
float _flock_weight
 Since Flock is a collective behavior the variables are declared within the AIBehaviors class.
LVecBase3f _flock_force
bool _flock_done
Wander_wander_obj
LVecBase3f _wander_force
ObstacleAvoidance_obstacle_avoidance_obj
LVecBase3f _obstacle_avoidance_force
PathFollow_path_follow_obj
PathFind_path_find_obj
bool _conflict
bool _previous_conflict
PUBLISHED __pad0__: void seek(NodePath target_object
PUBLISHED float seek_wt = 1.0)

Detailed Description

Definition at line 64 of file aiBehaviors.h.


Member Enumeration Documentation

Enumerator:
_none 
_seek 
_flee 
_flee_activate 
_arrival 
_arrival_activate 
_wander 
_pursue 
_evade 
_evade_activate 
_flock 
_flock_activate 
_obstacle_avoidance 
_obstacle_avoidance_activate 

Definition at line 67 of file aiBehaviors.h.


Constructor & Destructor Documentation

AIBehaviors::AIBehaviors (  ) 

Definition at line 19 of file aiBehaviors.cxx.

Here is the call graph for this function:

AIBehaviors::~AIBehaviors (  ) 

Definition at line 46 of file aiBehaviors.cxx.


Member Function Documentation

void AIBehaviors::accumulate_force ( string  force_type,
LVecBase3f  force 
)

Function : accumulate_force Description : This function updates the individual steering forces for each of the ai characters. These accumulated forces are eventually what comprise the resultant steering force of the character.

Definition at line 113 of file aiBehaviors.cxx.

Here is the caller graph for this function:

void AIBehaviors::add_dynamic_obstacle ( NodePath  obstacle  ) 

Function : add_dynamic_obstacle Description : This function starts the pathfinding obstacle navigation for the passed in obstacle.

Definition at line 964 of file aiBehaviors.cxx.

Here is the call graph for this function:

void AIBehaviors::add_static_obstacle ( NodePath  obstacle  ) 

Function : add_static_obstacle Description : This function allows the user to dynamically add obstacles to the game environment. The function will update the nodes within the bounding volume of the obstacle as non-traversable. Hence will not be considered by the pathfinding algorithm.

Definition at line 952 of file aiBehaviors.cxx.

Here is the call graph for this function:

void AIBehaviors::add_to_path ( LVecBase3f  pos  ) 

Function : add_to_path Description : This function adds positions to the path to follow.

Definition at line 887 of file aiBehaviors.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

void AIBehaviors::arrival ( double  distance = 10.0  ) 

Function : arrival Description : This function activates arrival. This is the function we want the user to call for arrival to be done.

Definition at line 713 of file aiBehaviors.cxx.

Here is the call graph for this function:

string AIBehaviors::behavior_status ( string  ai_type  ) 

Function : behavior_status Description : This function returns the status of an AI Type whether it is active, paused or disabled. It returns -1 if an invalid string is passed.

Definition at line 976 of file aiBehaviors.cxx.

Here is the call graph for this function:

LVecBase3f AIBehaviors::calculate_prioritized (  ) 

Function : calculate_prioritized Description : This function updates the main steering force for the ai character using the accumulate function and checks for max force and arrival force. It finally returns this steering force which is accessed by the update function in the AICharacter class.

Definition at line 171 of file aiBehaviors.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

int AIBehaviors::char_to_int ( string  ai_type  ) 

Function : char_to_int Description : This function is used to derive int values from the ai types strings. Returns -1 if an invalid string is passed.

Definition at line 1197 of file aiBehaviors.cxx.

Here is the caller graph for this function:

LVecBase3f AIBehaviors::do_flock (  ) 

Function : do_flock Description : This function contains the logic for flocking behavior. This is an emergent behavior and is obtained by combining three other behaviors which are separation, cohesion and alignment based on Craig Reynold's algorithm. Also, this behavior does not work by itself. It works only when combined with other steering behaviors such as wander, pursue, evade, seek and flee.

Initialize variables required to compute the flocking force on the ai char.

Loop through all the other AI units in the flock to check if they are neigbours.

Using visibilty cone to detect neighbors.

Check if the current unit is a neighbor.

Separation force calculation.

Calculating the total heading and center of mass of all the neighbors.

Update the neighbor count.

Alignment force calculation

Cohesion force calculation

Calculate the resultant force on the ai character by taking into account the separation, alignment and cohesion forces along with their corresponding weights.

Definition at line 771 of file aiBehaviors.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

void AIBehaviors::evade ( NodePath  target_object,
double  panic_distance = 10.0,
double  relax_distance = 10.0,
float  evade_wt = 1.0 
)

Function : evade Description : This function activates evade_activate.

Definition at line 698 of file aiBehaviors.cxx.

Here is the call graph for this function:

void AIBehaviors::flee ( LVecBase3f  pos,
double  panic_distance = 10.0,
double  relax_distance = 10.0,
float  flee_wt = 1.0 
)

Definition at line 670 of file aiBehaviors.cxx.

Here is the call graph for this function:

void AIBehaviors::flee ( NodePath  target_object,
double  panic_distance = 10.0,
double  relax_distance = 10.0,
float  flee_wt = 1.0 
)

Function : flee Description : This function activates flee_activate and creates an object of the Flee class. This function is overloaded to accept a NodePath or an LVecBase3f.

Definition at line 663 of file aiBehaviors.cxx.

Here is the call graph for this function:

void AIBehaviors::flock ( float  flock_wt  ) 

Function : flock Description : This function activates flock. This is the function we want the user to call for flock to be done.

Definition at line 737 of file aiBehaviors.cxx.

Here is the call graph for this function:

void AIBehaviors::flock_activate (  ) 

Function : flock_activate Description : This function checks whether any other behavior exists to work with flock. When this is true, it calls the do_flock function.

Definition at line 752 of file aiBehaviors.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

void AIBehaviors::init_path_find ( const char *  navmesh_filename  ) 

Function : init_path_find Description : This function activates path finding in the character. This function accepts the meshdata in .csv format.

Definition at line 911 of file aiBehaviors.cxx.

Here is the call graph for this function:

bool AIBehaviors::is_conflict (  ) 

Function : is_conflict Description : Checks for conflict between steering forces. If there is a conflict it returns 'true' and sets _conflict to 'true'. If there is no conflict it returns 'false' and sets _conflict to 'false'.

Definition at line 59 of file aiBehaviors.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

bool AIBehaviors::is_off ( string  ai_type  ) 

Function : is_off Description : This function returns true if pathfollow or pathfinding is off

Definition at line 1485 of file aiBehaviors.cxx.

bool AIBehaviors::is_off ( _behavior_type  bt  ) 

Function : is_off Description : This function returns true if an aiBehavior is off

Definition at line 1474 of file aiBehaviors.cxx.

Here is the caller graph for this function:

bool AIBehaviors::is_on ( string  ai_type  ) 

Function : is_on Description : This function returns true if pathfollow or pathfinding is on

Definition at line 1445 of file aiBehaviors.cxx.

Here is the call graph for this function:

bool AIBehaviors::is_on ( _behavior_type  bt  ) 

Function : is_on Description : This function returns true if an aiBehavior is on

Definition at line 1434 of file aiBehaviors.cxx.

Here is the caller graph for this function:

void AIBehaviors::obstacle_avoidance ( float  obstacle_avoidance_weight = 1.0  ) 

Function : obstacle avoidance Description : This function activates obstacle avoidance for a given character. This is the function we want the user to call for obstacle avoidance to be performed.

Definition at line 863 of file aiBehaviors.cxx.

Here is the call graph for this function:

void AIBehaviors::path_find_to ( NodePath  target,
string  type = "normal" 
)

Function : path_find_to (for pathfinding towards a moving target (a NodePath)) Description : This function checks for the source and target in the navigation mesh for its availability and then finds the best path via the A* algorithm Then it calls the path follower to make the object follow the path.

Definition at line 938 of file aiBehaviors.cxx.

Here is the call graph for this function:

void AIBehaviors::path_find_to ( LVecBase3f  pos,
string  type = "normal" 
)

Function : path_find_to (for pathfinding towards a static position) Description : This function checks for the source and target in the navigation mesh for its availability and then finds the best path via the A* algorithm Then it calls the path follower to make the object follow the path.

Definition at line 925 of file aiBehaviors.cxx.

Here is the call graph for this function:

void AIBehaviors::path_follow ( float  follow_wt  ) 

Function : path_follow Description : This function activates path following. This is the function we want the user to call for path following.

Definition at line 876 of file aiBehaviors.cxx.

Here is the caller graph for this function:

void AIBehaviors::pause_ai ( string  ai_type  ) 

Function : pause_ai Description : This function pauses individual or all the AIs.

Definition at line 444 of file aiBehaviors.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

void AIBehaviors::pursue ( NodePath  target_object,
float  pursue_wt = 1.0 
)

Function : pursue Description : This function activates pursue. This is the function we want the user to call for pursue to be done.

Definition at line 685 of file aiBehaviors.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

void AIBehaviors::remove_ai ( string  ai_type  ) 

Function : remove_ai Description : This function removes individual or all the AIs.

Definition at line 323 of file aiBehaviors.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

void AIBehaviors::resume_ai ( string  ai_type  ) 

Function : resume_ai Description : This function resumes individual or all the AIs

Definition at line 546 of file aiBehaviors.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

void AIBehaviors::seek ( LVecBase3f  pos,
float  seek_wt = 1.0 
)

Definition at line 650 of file aiBehaviors.cxx.

Here is the call graph for this function:

void AIBehaviors::start_follow ( string  type = "normal"  ) 

Function : start_follow Description : This function starts the path follower.

Definition at line 898 of file aiBehaviors.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

void AIBehaviors::turn_off ( string  ai_type  ) 

Function : turn_off Description : This function turns off any aiBehavior which is passed as a string.

Definition at line 1326 of file aiBehaviors.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

void AIBehaviors::turn_on ( string  ai_type  ) 

Function : turn_on Description : This function turns on any aiBehavior which is passed as a string.

Definition at line 1260 of file aiBehaviors.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

void AIBehaviors::wander ( double  wander_radius = 5.0,
int  flag = 0,
double  aoe = 0.0,
float  wander_weight = 1.0 
)

Function : wander Description : This function activates wander. This is the function we want the user to call for flock to be done.

Definition at line 849 of file aiBehaviors.cxx.

Here is the call graph for this function:


Member Data Documentation

Definition at line 151 of file aiBehaviors.h.

Definition at line 84 of file aiBehaviors.h.

Definition at line 111 of file aiBehaviors.h.

Definition at line 110 of file aiBehaviors.h.

Definition at line 87 of file aiBehaviors.h.

Definition at line 128 of file aiBehaviors.h.

Definition at line 104 of file aiBehaviors.h.

ListEvade::iterator AIBehaviors::_evade_itr

Definition at line 108 of file aiBehaviors.h.

This list is used if the ai character needs to evade from multiple onjects.

Definition at line 107 of file aiBehaviors.h.

Definition at line 103 of file aiBehaviors.h.

Definition at line 94 of file aiBehaviors.h.

ListFlee::iterator AIBehaviors::_flee_itr

Definition at line 98 of file aiBehaviors.h.

This list is used if the ai character needs to flee from multiple onjects.

Definition at line 97 of file aiBehaviors.h.

Definition at line 93 of file aiBehaviors.h.

Definition at line 116 of file aiBehaviors.h.

Definition at line 115 of file aiBehaviors.h.

Definition at line 85 of file aiBehaviors.h.

Since Flock is a collective behavior the variables are declared within the AIBehaviors class.

Definition at line 114 of file aiBehaviors.h.

Definition at line 122 of file aiBehaviors.h.

Definition at line 121 of file aiBehaviors.h.

Definition at line 126 of file aiBehaviors.h.

Definition at line 124 of file aiBehaviors.h.

Definition at line 128 of file aiBehaviors.h.

Definition at line 101 of file aiBehaviors.h.

Definition at line 100 of file aiBehaviors.h.

Definition at line 91 of file aiBehaviors.h.

Definition at line 90 of file aiBehaviors.h.

Definition at line 88 of file aiBehaviors.h.

Definition at line 119 of file aiBehaviors.h.

Definition at line 118 of file aiBehaviors.h.

PUBLISHED float AIBehaviors::seek_wt = 1.0)

Definition at line 151 of file aiBehaviors.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator

Generated on Tue Dec 8 01:13:03 2009 for Pandai by  doxygen 1.6.1