1 // AIManager.hxx - David Culp - based on:
2 // AIMgr.hxx - definition of FGAIMgr
3 // - a global management class for FlightGear generated AI traffic
5 // Written by David Luff, started March 2002.
7 // Copyright (C) 2002 David C Luff - david.luff@nottingham.ac.uk
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #ifndef _FG_AIMANAGER_HXX
24 #define _FG_AIMANAGER_HXX
28 #include <simgear/structure/subsystem_mgr.hxx>
29 #include <simgear/structure/SGSharedPtr.hxx>
30 #include <simgear/props/props_io.hxx>
32 #include <Main/fg_props.hxx>
34 #include <AIModel/AIBase.hxx>
35 #include <AIModel/AIFlightPlan.hxx>
37 #include <Traffic/SchedFlight.hxx>
38 #include <Traffic/Schedule.hxx>
44 class FGAIManager : public SGSubsystem
49 // A list of pointers to AI objects
50 typedef list <SGSharedPtr<FGAIBase> > ai_list_type;
51 typedef ai_list_type::iterator ai_list_iterator;
52 typedef ai_list_type::const_iterator ai_list_const_iterator;
56 inline const ai_list_type& get_ai_list() const {
57 SG_LOG(SG_GENERAL, SG_DEBUG, "AI Manager: AI model return list size " << ai_list.size());
69 void update(double dt);
70 void updateLOD(SGPropertyNode* node);
71 void attach(FGAIBase *model);
73 void destroyObject( int ID );
74 const FGAIBase *calcCollision(double alt, double lat, double lon, double fuse_range);
76 inline double get_user_latitude() const { return user_latitude; }
77 inline double get_user_longitude() const { return user_longitude; }
78 inline double get_user_altitude() const { return user_altitude; }
79 inline double get_user_heading() const { return user_heading; }
80 inline double get_user_pitch() const { return user_pitch; }
81 inline double get_user_yaw() const { return user_yaw; }
82 inline double get_user_speed() const {return user_speed; }
83 inline double get_wind_from_east() const {return wind_from_east; }
84 inline double get_wind_from_north() const {return wind_from_north; }
85 inline double get_user_roll() const { return user_roll; }
86 inline double get_user_agl() const { return user_altitude_agl; }
88 int getNumAiObjects(void) const;
90 void processScenario( const string &filename );
92 static SGPropertyNode_ptr loadScenarioFile(const std::string& filename);
94 static bool getStartPosition(const string& id, const string& pid,
95 SGGeod& geodPos, double& hdng, SGVec3d& uvw);
100 int mNumAiTypeModels[FGAIBase::MAX_OBJECTS];
103 double calcRange(double lat, double lon, double lat2, double lon2)const;
105 SGPropertyNode_ptr root;
106 SGPropertyNode_ptr thermal_lift_node;
107 SGPropertyNode_ptr user_latitude_node;
108 SGPropertyNode_ptr user_longitude_node;
109 SGPropertyNode_ptr user_altitude_node;
110 SGPropertyNode_ptr user_altitude_agl_node;
111 SGPropertyNode_ptr user_heading_node;
112 SGPropertyNode_ptr user_pitch_node;
113 SGPropertyNode_ptr user_yaw_node;
114 SGPropertyNode_ptr user_roll_node;
115 SGPropertyNode_ptr user_speed_node;
116 SGPropertyNode_ptr wind_from_east_node;
117 SGPropertyNode_ptr wind_from_north_node;
119 double user_latitude;
120 double user_longitude;
121 double user_altitude;
122 double user_altitude_agl;
129 double wind_from_east;
130 double wind_from_north;
133 void fetchUserState( void );
136 double range_nearest;
138 void processThermal( FGAIThermal* thermal );
140 SGPropertyChangeCallback<FGAIManager> cb_ai_bare;
141 SGPropertyChangeCallback<FGAIManager> cb_ai_detailed;
144 #endif // _FG_AIMANAGER_HXX