]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIManager.hxx
afa23eac6da0c91e1961537d359ea5f087331e51
[flightgear.git] / src / AIModel / AIManager.hxx
1 // AIManager.hxx - experimental! - David Culp - based on:
2 // AIMgr.hxx - definition of FGAIMgr 
3 // - a global management class for FlightGear generated AI traffic
4 //
5 // Written by David Luff, started March 2002.
6 //
7 // Copyright (C) 2002  David C Luff - david.luff@nottingham.ac.uk
8 //
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.
13 //
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.
18 //
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.
22
23 #ifndef _FG_AIMANAGER_HXX
24 #define _FG_AIMANAGER_HXX
25
26 #include <simgear/structure/subsystem_mgr.hxx>
27 #include <Main/fg_props.hxx>
28 #include <list>
29 #include "AIBase.hxx"
30 #include "AIScenario.hxx"
31 #include "AIFlightPlan.hxx"
32
33 SG_USING_STD(list);
34 class FGAIThermal;
35
36
37 class FGAIManager : public SGSubsystem
38 {
39
40 private:
41
42     // A list of pointers to AI objects
43     typedef list <FGAIBase*> ai_list_type;
44     typedef ai_list_type::iterator ai_list_iterator;
45     typedef ai_list_type::const_iterator ai_list_const_iterator;
46
47     // Everything put in this list should be created dynamically
48     // on the heap and ***DELETED WHEN REMOVED!!!!!***
49     ai_list_type ai_list;
50     ai_list_iterator ai_list_itr;
51
52     // array of already-assigned ID's
53     typedef vector <int> id_vector_type;
54     id_vector_type ids;                    
55     id_vector_type::iterator id_itr;
56
57 public:
58
59     FGAIManager();
60     ~FGAIManager();
61
62     void init();
63     void bind();
64     void unbind();
65     void update(double dt);
66
67     int assignID();
68     void freeID(int ID);
69
70     int createAircraft( string model_class, // see FGAIAircraft.hxx for possible classes
71                         string path,        // path to exterior model
72                         double latitude,    // in degrees -90 to 90
73                         double longitude,   // in degrees -180 to 180
74                         double altitude,    // in feet
75                         double heading,     // true heading in degrees
76                         double speed,       // in knots true airspeed (KTAS)    
77                         double roll = 0 );  // in degrees
78
79     int createAircraft( string model_class, // see FGAIAircraft.hxx for possible classes
80                         string path,        // path to exterior model
81                         FGAIFlightPlan *flightplan );
82
83     int createShip(     string path,        // path to exterior model
84                         double latitude,    // in degrees -90 to 90
85                         double longitude,   // in degrees -180 to 180
86                         double altitude,    // in feet  (ex. for a lake!)
87                         double heading,     // true heading in degrees
88                         double speed,       // in knots true
89                         double rudder );    // in degrees (right is positive)(0 to 5 works best)
90
91     int createShip(     string path,        // path to exterior model
92                         FGAIFlightPlan *flightplan );
93
94     int createBallistic( string path,       // path to exterior model
95                          double latitude,   // in degrees -90 to 90
96                          double longitude,  // in degrees -180 to 180
97                          double altitude,   // in feet
98                          double azimuth,    // in degrees (same as heading)
99                          double elevation,  // in degrees (same as pitch)
100                          double speed,      // in feet per second
101                          double eda,        // equivalent drag area, ft2
102                          double life,       // life span in seconds
103                          double buoyancy    // acceleration in ft per second2
104                          );
105      
106     int createStorm( string path,        // path to exterior model
107                      double latitude,    // in degrees -90 to 90
108                      double longitude,   // in degrees -180 to 180
109                      double altitude,    // in feet
110                      double heading,     // true heading in degrees
111                      double speed );     // in knots true airspeed (KTAS)    
112
113     int createThermal( double latitude,    // in degrees -90 to 90
114                        double longitude,   // in degrees -180 to 180
115                        double strength,    // in feet per second
116                        double diameter );  // in feet
117
118         
119     void destroyObject( int ID );
120
121     inline double get_user_latitude() { return user_latitude; }
122     inline double get_user_longitude() { return user_longitude; }
123     inline double get_user_altitude() { return user_altitude; }
124     inline double get_user_heading() { return user_heading; }
125     inline double get_user_pitch() { return user_pitch; }
126     inline double get_user_yaw() { return user_yaw; }
127     inline double get_user_speed() {return user_speed; }
128
129     void processScenario( string filename );
130     int getNum( FGAIBase::object_type ot);
131
132 private:
133
134     bool initDone;
135     bool enabled;
136     int numObjects;
137     SGPropertyNode* root;
138     SGPropertyNode* wind_from_down;
139     string scenario_filename;
140
141     double user_latitude;
142     double user_longitude;
143     double user_altitude;
144     double user_heading;
145     double user_pitch;
146     double user_yaw;
147     double user_speed;
148     double _dt;
149     int dt_count;
150     void fetchUserState( void );
151
152     // used by thermals
153     double range_nearest;
154     double strength;
155     void processThermal( FGAIThermal* thermal ); 
156
157 };
158
159 #endif  // _FG_AIMANAGER_HXX