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/ssgSharedPtr.hxx>
30 #include <simgear/structure/SGSharedPtr.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>
46 ssgSharedPtr<ssgBranch> model;
49 FGModelID(const string& pth, ssgBranch * mdl) { path =pth; model=mdl;};
50 ssgBranch * const getModelId() const { return model;};
51 const string & getPath() const { return path;};
52 int getNumRefs() const { return model.getNumRefs(); };
55 typedef vector<FGModelID> ModelVec;
56 typedef vector<FGModelID>::iterator ModelVecIterator;
61 class FGAIManager : public SGSubsystem
66 // A list of pointers to AI objects
67 typedef list <SGSharedPtr<FGAIBase> > ai_list_type;
68 typedef ai_list_type::iterator ai_list_iterator;
69 typedef ai_list_type::const_iterator ai_list_const_iterator;
72 ModelVec loadedModels;
83 void update(double dt);
85 void attach(SGSharedPtr<FGAIBase> model);
87 void destroyObject( int ID );
89 inline double get_user_latitude() const { return user_latitude; }
90 inline double get_user_longitude() const { return user_longitude; }
91 inline double get_user_altitude() const { return user_altitude; }
92 inline double get_user_heading() const { return user_heading; }
93 inline double get_user_pitch() const { return user_pitch; }
94 inline double get_user_yaw() const { return user_yaw; }
95 inline double get_user_speed() const {return user_speed; }
96 inline double get_wind_from_east() const {return wind_from_east; }
97 inline double get_wind_from_north() const {return wind_from_north; }
99 int getNumAiObjects(void) const;
101 void processScenario( const string &filename );
103 ssgBranch * getModel(const string& path);
104 void setModel(const string& path, ssgBranch *model);
106 static SGPropertyNode_ptr loadScenarioFile(const std::string& filename);
108 static bool getStartPosition(const string& id, const string& pid,
109 SGGeod& geodPos, double& hdng, SGVec3d& uvw);
114 int mNumAiTypeModels[FGAIBase::MAX_OBJECTS];
117 SGPropertyNode_ptr root;
118 SGPropertyNode_ptr wind_from_down_node;
119 SGPropertyNode_ptr user_latitude_node;
120 SGPropertyNode_ptr user_longitude_node;
121 SGPropertyNode_ptr user_altitude_node;
122 SGPropertyNode_ptr user_heading_node;
123 SGPropertyNode_ptr user_pitch_node;
124 SGPropertyNode_ptr user_yaw_node;
125 SGPropertyNode_ptr user_speed_node;
126 SGPropertyNode_ptr wind_from_east_node ;
127 SGPropertyNode_ptr wind_from_north_node ;
129 string scenario_filename;
131 double user_latitude;
132 double user_longitude;
133 double user_altitude;
138 double wind_from_east;
139 double wind_from_north;
141 void fetchUserState( void );
144 double range_nearest;
146 void processThermal( FGAIThermal* thermal );
150 #endif // _FG_AIMANAGER_HXX