]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AICarrier.hxx
2bf64003a4e3a753eb3d3d8b888e8fde09c7254d
[flightgear.git] / src / AIModel / AICarrier.hxx
1 // FGAICarrier - AIShip-derived class creates an AI aircraft carrier
2 //
3 // Written by David Culp, started October 2004.
4 //
5 // Copyright (C) 2004  David P. Culp - davidculp2@comcast.net
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
21 #ifndef _FG_AICARRIER_HXX
22 #define _FG_AICARRIER_HXX
23
24 #include <string>
25 #include <list>
26
27 #include <osg/Referenced>
28 #include <osg/Node>
29
30 #include <simgear/compiler.h>
31
32 using std::string;
33 using std::list;
34
35 #include "AIShip.hxx"
36
37 #include "AIManager.hxx"
38 #include "AIBase.hxx"
39
40 class FGAIManager;
41 class FGAICarrier;
42
43 class FGAICarrier  : public FGAIShip {
44 public:
45
46     FGAICarrier();
47     virtual ~FGAICarrier();
48
49     virtual void readFromScenario(SGPropertyNode* scFileNode);
50
51     void setSign(const string& );
52     void setTACANChannelID(const string &);
53
54     virtual void bind();
55     virtual void unbind();
56     void UpdateWind ( double dt );
57     void setWind_from_east( double fps );
58     void setWind_from_north( double fps );
59     void setMaxLat( double deg );
60     void setMinLat( double deg );
61     void setMaxLong( double deg );
62     void setMinLong( double deg );
63     void setMPControl( bool c );
64     void TurnToLaunch();
65     void TurnToRecover();
66     void TurnToBase();
67     void ReturnToBox();
68     bool OutsideBox();
69
70     bool init(bool search_in_AI_path=false);
71
72     virtual const char* getTypeString(void) const { return "carrier"; }
73
74     bool getParkPosition(const string& id, SGGeod& geodPos,
75                          double& hdng, SGVec3d& uvw);
76
77 private:
78   /// Is sufficient to be private, stores a possible position to place an
79   /// aircraft on start
80   struct ParkPosition {
81     ParkPosition(const ParkPosition& pp)
82       : name(pp.name), offset(pp.offset), heading_deg(pp.heading_deg)
83     {}
84     ParkPosition(const string& n, const SGVec3d& off = SGVec3d(), double heading = 0)
85       : name(n), offset(off), heading_deg(heading)
86     {}
87     string name;
88     SGVec3d offset;
89     double heading_deg;
90   };
91
92
93     void update(double dt);
94     double wind_from_east;  // fps
95     double wind_from_north; // fps
96     double rel_wind_speed_kts;
97     double rel_wind_from_deg;
98
99
100
101     list<ParkPosition> ppositions;    // List of positions where an aircraft can start.
102     string sign;                      // The sign of this carrier.
103
104     // these describe the flols
105     SGVec3d flols_off;
106
107     double dist;            // the distance of the eyepoint from the flols
108     double angle;
109     int source;             // the flols light which is visible at the moment
110     bool wave_off_lights;
111     bool in_to_wind;
112
113     // these are for maneuvering the carrier
114     SGGeod mOpBoxPos;
115
116     double wind_speed_from_north_kts ;
117     double wind_speed_from_east_kts  ;
118     double wind_speed_kts;  //true wind speed
119     double wind_from_deg;   //true wind direction
120     double rel_wind;
121     double max_lat, min_lat, max_long, min_long;
122     double base_course, base_speed;
123
124     bool turn_to_launch_hdg;
125     bool turn_to_recovery_hdg;
126     bool turn_to_base_course;
127     bool returning;      // set if the carrier is returning to an operating box
128     bool InToWind();     // set if the carrier is in to wind
129     bool MPControl;
130
131
132     SGPropertyNode_ptr _longitude_node;
133     SGPropertyNode_ptr _latitude_node;
134     SGPropertyNode_ptr _altitude_node;
135     SGPropertyNode_ptr _surface_wind_from_deg_node;
136     SGPropertyNode_ptr _surface_wind_speed_node;
137     SGPropertyNode_ptr _launchbar_state_node;
138     // this is for tacan
139
140     string TACAN_channel_id;
141
142     // these are for moving the elevators
143     void UpdateElevator( double dt, double transition_time);
144     double pos_norm, raw_pos_norm;
145     double transition_time, time_constant;
146     bool elevators;
147
148     // these are for moving the jet blast deflectors
149     void UpdateJBD( double dt, double jbd_transition_time);
150     double jbd_pos_norm, raw_jbd_pos_norm;
151     double jbd_transition_time, jbd_time_constant;
152     bool jbd;
153 };
154
155 #endif  // _FG_AICARRIER_HXX