]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIManager.hxx
9b668f4ccbfb70a69685733e1d171fd3cbff9f37
[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 "AIAircraft.hxx"
31
32 SG_USING_STD(list);
33
34
35 class FGAIManager : public SGSubsystem
36 {
37
38 private:
39
40     // A list of pointers to AI objects
41     typedef list <FGAIBase*> ai_list_type;
42     typedef ai_list_type::iterator ai_list_iterator;
43     typedef ai_list_type::const_iterator ai_list_const_iterator;
44
45     // Everything put in this list should be created dynamically
46     // on the heap and ***DELETED WHEN REMOVED!!!!!***
47     ai_list_type ai_list;
48     ai_list_iterator ai_list_itr;
49
50     // array of already-assigned ID's
51     typedef vector <int> id_vector_type;
52     id_vector_type ids;                    
53     id_vector_type::iterator id_itr;
54
55 public:
56
57     enum object_type { otAircraft, otShip, otBallistic, otRocket };
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 pitch = 0,   // in degrees
78                         double roll = 0 );  // in degrees
79
80     int createShip(     string path,        // path to exterior model
81                         double latitude,    // in degrees -90 to 90
82                         double longitude,   // in degrees -180 to 180
83                         double altitude,    // in feet  (ex. for a lake!)
84                         double heading,     // true heading in degrees
85                         double speed,       // in knots true
86                         double rudder );    // in degrees (between 0 and 5 works best)
87
88
89     int createBallistic( string path,       // path to exterior model
90                          double latitude,   // in degrees -90 to 90
91                          double longitude,  // in degrees -180 to 180
92                          double altitude,   // in feet
93                          double azimuth,    // in degrees (same as heading)
94                          double elevation,  // in degrees (same as pitch)
95                          double speed );    // in feet per second
96
97     void destroyObject( int ID );
98
99     inline double get_user_latitude() { return user_latitude; }
100     inline double get_user_longitude() { return user_longitude; }
101     inline double get_user_altitude() { return user_altitude; }
102     inline double get_user_heading() { return user_heading; }
103     inline double get_user_pitch() { return user_pitch; }
104     inline double get_user_yaw() { return user_yaw; }
105     inline double get_user_speed() {return user_speed; }
106
107 private:
108
109     bool initDone;
110     int numObjects;
111     SGPropertyNode* root;
112
113     double user_latitude;
114     double user_longitude;
115     double user_altitude;
116     double user_heading;
117     double user_pitch;
118     double user_yaw;
119     double user_speed;
120     int dt_count;
121     void fetchUserState( void );
122
123 };
124
125 #endif  // _FG_AIMANAGER_HXX