]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIManager.hxx
5b0e962b17de668352aa5a6c89fc8da586c9bcda
[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
31 SG_USING_STD(list);
32
33
34 class FGAIManager : public SGSubsystem
35 {
36
37 private:
38
39     // A list of pointers to AI objects
40     typedef list <FGAIBase*> ai_list_type;
41     typedef ai_list_type::iterator ai_list_iterator;
42     typedef ai_list_type::const_iterator ai_list_const_iterator;
43
44     // Everything put in this list should be created dynamically
45     // on the heap and ***DELETED WHEN REMOVED!!!!!***
46     ai_list_type ai_list;
47     ai_list_iterator ai_list_itr;
48
49     // array of already-assigned ID's
50     typedef vector <int> id_vector_type;
51     id_vector_type ids;                    
52     id_vector_type::iterator id_itr;
53
54 public:
55
56     enum object_type { otAircraft, otShip, otBallistic, otRocket, otStorm, otThermal };
57
58     FGAIManager();
59     ~FGAIManager();
60
61     void init();
62     void bind();
63     void unbind();
64     void update(double dt);
65
66     int assignID();
67     void freeID(int ID);
68
69     int createAircraft( string model_class, // see FGAIAircraft.hxx for possible classes
70                         string path,        // path to exterior model
71                         double latitude,    // in degrees -90 to 90
72                         double longitude,   // in degrees -180 to 180
73                         double altitude,    // in feet
74                         double heading,     // true heading in degrees
75                         double speed,       // in knots true airspeed (KTAS)    
76                         double pitch = 0,   // in degrees
77                         double roll = 0 );  // in degrees
78
79     int createShip(     string path,        // path to exterior model
80                         double latitude,    // in degrees -90 to 90
81                         double longitude,   // in degrees -180 to 180
82                         double altitude,    // in feet  (ex. for a lake!)
83                         double heading,     // true heading in degrees
84                         double speed,       // in knots true
85                         double rudder );    // in degrees (between 0 and 5 works best)
86
87
88     int createBallistic( string path,       // path to exterior model
89                          double latitude,   // in degrees -90 to 90
90                          double longitude,  // in degrees -180 to 180
91                          double altitude,   // in feet
92                          double azimuth,    // in degrees (same as heading)
93                          double elevation,  // in degrees (same as pitch)
94                          double speed );    // in feet per second
95
96     int createStorm( string path,        // path to exterior model
97                      double latitude,    // in degrees -90 to 90
98                      double longitude,   // in degrees -180 to 180
99                      double altitude,    // in feet
100                      double heading,     // true heading in degrees
101                      double speed );     // in knots true airspeed (KTAS)    
102
103     int createThermal( double latitude,    // in degrees -90 to 90
104                        double longitude,   // in degrees -180 to 180
105                        double strength,    // in feet per second
106                        double diameter );  // in feet
107                  
108     void destroyObject( int ID );
109
110     inline double get_user_latitude() { return user_latitude; }
111     inline double get_user_longitude() { return user_longitude; }
112     inline double get_user_altitude() { return user_altitude; }
113     inline double get_user_heading() { return user_heading; }
114     inline double get_user_pitch() { return user_pitch; }
115     inline double get_user_yaw() { return user_yaw; }
116     inline double get_user_speed() {return user_speed; }
117
118 private:
119
120     bool initDone;
121     int numObjects;
122     SGPropertyNode* root;
123
124     double user_latitude;
125     double user_longitude;
126     double user_altitude;
127     double user_heading;
128     double user_pitch;
129     double user_yaw;
130     double user_speed;
131     int dt_count;
132     void fetchUserState( void );
133
134 };
135
136 #endif  // _FG_AIMANAGER_HXX