00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #pragma warning (disable:4996)
00017 #pragma warning (disable:4005)
00018 #pragma warning(disable:4275)
00019
00020 #ifndef _AIBEHAVIORS_H
00021 #define _AIBEHAVIORS_H
00022
00023 #include "aiGlobals.h"
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 class AICharacter;
00038 class Seek;
00039 class Flee;
00040 class Pursue;
00041 class Evade;
00042 class Arrival;
00043 class Flock;
00044 class Wander;
00045 class PathFollow;
00046 class PathFind;
00047 class ObstacleAvoidance;
00048
00049 typedef list<Flee, allocator<Flee> > ListFlee;
00050 typedef list<Evade, allocator<Evade> > ListEvade;
00051
00052 class EXPCL_PANDAAI AIBehaviors {
00053
00054 public:
00055 enum _behavior_type {
00056 _none = 0x00000,
00057 _seek = 0x00002,
00058 _flee = 0x00004,
00059 _flee_activate = 0x00100,
00060 _arrival = 0x00008,
00061 _arrival_activate = 0x01000,
00062 _wander = 0x00010,
00063 _pursue = 0x00040,
00064 _evade = 0x00080,
00065 _evade_activate = 0x00800,
00066 _flock = 0x00200,
00067 _flock_activate = 0x00400,
00068 _obstacle_avoidance = 0x02000,
00069 _obstacle_avoidance_activate = 0x04000
00070 };
00071
00072 AICharacter *_ai_char;
00073 Flock *_flock_group;
00074
00075 int _behaviors_flags;
00076 LVecBase3f _steering_force;
00077
00078 Seek *_seek_obj;
00079 LVecBase3f _seek_force;
00080
00081 Flee *_flee_obj;
00082 LVecBase3f _flee_force;
00083
00084
00085 ListFlee _flee_list;
00086 ListFlee::iterator _flee_itr;
00087
00088 Pursue *_pursue_obj;
00089 LVecBase3f _pursue_force;
00090
00091 Evade *_evade_obj;
00092 LVecBase3f _evade_force;
00093
00094
00095 ListEvade _evade_list;
00096 ListEvade::iterator _evade_itr;
00097
00098 Arrival *_arrival_obj;
00099 LVecBase3f _arrival_force;
00100
00101
00102 float _flock_weight;
00103 LVecBase3f _flock_force;
00104 bool _flock_done;
00105
00106 Wander * _wander_obj;
00107 LVecBase3f _wander_force;
00108
00109 ObstacleAvoidance *_obstacle_avoidance_obj;
00110 LVecBase3f _obstacle_avoidance_force;
00111
00112 PathFollow *_path_follow_obj;
00113
00114 PathFind *_path_find_obj;
00115
00116 bool _conflict, _previous_conflict;
00117
00118 AIBehaviors();
00119 ~AIBehaviors();
00120
00121 bool is_on(_behavior_type bt);
00122 bool is_on(string ai_type);
00123 bool is_off(_behavior_type bt);
00124 bool is_off(string ai_type);
00125 void turn_on(string ai_type);
00126 void turn_off(string ai_type);
00127
00128 bool is_conflict();
00129
00130 void accumulate_force(string force_type, LVecBase3f force);
00131 LVecBase3f calculate_prioritized();
00132
00133 void flock_activate();
00134 LVecBase3f do_flock();
00135
00136 int char_to_int(string ai_type);
00137
00138 PUBLISHED:
00139 void seek(NodePath target_object, float seek_wt = 1.0);
00140 void seek(LVecBase3f pos, float seek_wt = 1.0);
00141
00142 void flee(NodePath target_object, double panic_distance = 10.0, double relax_distance = 10.0, float flee_wt = 1.0);
00143 void flee(LVecBase3f pos, double panic_distance = 10.0, double relax_distance = 10.0, float flee_wt = 1.0);
00144
00145 void pursue(NodePath target_object, float pursue_wt = 1.0);
00146
00147 void evade(NodePath target_object, double panic_distance = 10.0, double relax_distance = 10.0, float evade_wt = 1.0);
00148
00149 void arrival(double distance = 10.0);
00150
00151 void flock(float flock_wt);
00152
00153 void wander(double wander_radius = 5.0, int flag =0, double aoe = 0.0, float wander_weight = 1.0);
00154
00155 void obstacle_avoidance(float feeler_length = 1.0);
00156
00157 void path_follow(float follow_wt);
00158 void add_to_path(LVecBase3f pos);
00159 void start_follow(string type = "normal");
00160
00161
00162 void init_path_find(const char* navmesh_filename);
00163 void path_find_to(LVecBase3f pos, string type = "normal");
00164 void path_find_to(NodePath target, string type = "normal");
00165 void add_static_obstacle(NodePath obstacle);
00166 void add_dynamic_obstacle(NodePath obstacle);
00167
00168
00169 void remove_ai(string ai_type);
00170 void pause_ai(string ai_type);
00171 void resume_ai(string ai_type);
00172
00173 string behavior_status(string ai_type);
00174 };
00175
00176 #endif
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187