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., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #ifndef _FG_AIMANAGER_HXX
24 #define _FG_AIMANAGER_HXX
28 #include <simgear/structure/subsystem_mgr.hxx>
30 #include <Main/fg_props.hxx>
32 #include <AIModel/AIBase.hxx>
33 #include <AIModel/AIScenario.hxx>
34 #include <AIModel/AIFlightPlan.hxx>
36 #include <Traffic/SchedFlight.hxx>
37 #include <Traffic/Schedule.hxx>
48 FGModelID(const string& pth, ssgBranch * mdl) { path =pth; model=mdl;};
49 ssgBranch * const getModelId() const { return model;};
50 const string & getPath() const { return path;};
53 typedef vector<FGModelID> ModelVec;
54 typedef vector<FGModelID>::const_iterator ModelVecIterator;
59 class FGAIManager : public SGSubsystem
64 // A list of pointers to AI objects
65 typedef list <FGAIBase*> ai_list_type;
66 typedef ai_list_type::iterator ai_list_iterator;
67 typedef ai_list_type::const_iterator ai_list_const_iterator;
69 // Everything put in this list should be created dynamically
70 // on the heap and ***DELETED WHEN REMOVED!!!!!***
72 ModelVec loadedModels;
83 void update(double dt);
85 void* createBallistic( FGAIModelEntity *entity );
86 void* createAircraft( FGAIModelEntity *entity, FGAISchedule *ref=0 );
87 void* createThermal( FGAIModelEntity *entity );
88 void* createStorm( FGAIModelEntity *entity );
89 void* createShip( FGAIModelEntity *entity );
90 void* createCarrier( FGAIModelEntity *entity );
91 void* createStatic( FGAIModelEntity *entity );
93 void destroyObject( int ID );
95 inline double get_user_latitude() const { return user_latitude; }
96 inline double get_user_longitude() const { return user_longitude; }
97 inline double get_user_altitude() const { return user_altitude; }
98 inline double get_user_heading() const { return user_heading; }
99 inline double get_user_pitch() const { return user_pitch; }
100 inline double get_user_yaw() const { return user_yaw; }
101 inline double get_user_speed() const {return user_speed; }
102 inline double get_wind_from_east() const {return wind_from_east; }
103 inline double get_wind_from_north() const {return wind_from_north; }
105 inline int getNum( FGAIBase::object_type ot ) const {
106 return (0 < ot && ot < FGAIBase::MAX_OBJECTS) ? numObjects[ot] : numObjects[0];
109 void processScenario( const string &filename );
111 ssgBranch * getModel(const string& path) const;
112 void setModel(const string& path, ssgBranch *model);
114 static bool getStartPosition(const string& id, const string& pid,
115 Point3D& geodPos, double& hdng, sgdVec3 uvw);
121 int numObjects[FGAIBase::MAX_OBJECTS];
122 SGPropertyNode* root;
123 SGPropertyNode* wind_from_down_node;
124 SGPropertyNode* user_latitude_node;
125 SGPropertyNode* user_longitude_node;
126 SGPropertyNode* user_altitude_node;
127 SGPropertyNode* user_heading_node;
128 SGPropertyNode* user_pitch_node;
129 SGPropertyNode* user_yaw_node;
130 SGPropertyNode* user_speed_node;
131 SGPropertyNode* wind_from_east_node ;
132 SGPropertyNode* wind_from_north_node ;
134 string scenario_filename;
136 double user_latitude;
137 double user_longitude;
138 double user_altitude;
143 double wind_from_east;
144 double wind_from_north;
147 void fetchUserState( void );
150 double range_nearest;
152 void processThermal( FGAIThermal* thermal );
156 #endif // _FG_AIMANAGER_HXX