]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AICarrier.hxx
0beb52010086f9145ee1ee9b08a4d6a85a2c3ed6
[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., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 #ifndef _FG_AICARRIER_HXX
22 #define _FG_AICARRIER_HXX
23
24 #include <string>
25 #include <list>
26 #include <plib/ssg.h>
27 #include <simgear/compiler.h>
28
29 SG_USING_STD(string);
30 SG_USING_STD(list);
31
32 #include "AIShip.hxx"
33
34 #include "AIManager.hxx"
35 #include "AIBase.hxx"
36
37 class FGAIManager;
38 class FGAICarrier;
39
40 class FGAICarrierHardware : public ssgBase {
41 public:
42
43   enum Type { Catapult, Wire, Solid };
44
45   FGAICarrier *carrier;
46   int id;
47   Type type;
48
49   static FGAICarrierHardware* newCatapult(FGAICarrier *c) {
50     FGAICarrierHardware* ch = new FGAICarrierHardware;
51     ch->carrier = c;
52     ch->type = Catapult;
53     ch->id = unique_id++;
54     return ch;
55   }
56   static FGAICarrierHardware* newWire(FGAICarrier *c) {
57     FGAICarrierHardware* ch = new FGAICarrierHardware;
58     ch->carrier = c;
59     ch->type = Wire;
60     ch->id = unique_id++;
61     return ch;
62   }
63   static FGAICarrierHardware* newSolid(FGAICarrier *c) {
64     FGAICarrierHardware* ch = new FGAICarrierHardware;
65     ch->carrier = c;
66     ch->type = Solid;
67     ch->id = unique_id++;
68     return ch;
69   }
70
71 private:
72   static int unique_id;
73 };
74
75 class FGAICarrier  : public FGAIShip {
76         
77 public:
78         
79         FGAICarrier(FGAIManager* mgr);
80         ~FGAICarrier();
81
82         void setSolidObjects(const list<string>& solid_objects);
83         void setWireObjects(const list<string>& wire_objects);
84         void setCatapultObjects(const list<string>& catapult_objects);
85         void setParkingPositions(const list<ParkPosition>& p);
86         void setSign(const string& );
87         void setFlolsOffset(const Point3D& off);
88         void setTACANChannelID(const string &);
89
90         void getVelocityWrtEarth(sgdVec3& v, sgdVec3& omega, sgdVec3& pivot);
91         virtual void bind();
92     virtual void unbind();
93     void UpdateFlols ( const sgdMat3& trans );
94     void UpdateWind ( double dt );
95     void setWind_from_east( double fps );
96     void setWind_from_north( double fps );
97     void setMaxLat( double deg );
98     void setMinLat( double deg );
99     void setMaxLong( double deg );
100     void setMinLong( double deg );
101     void TurnToLaunch();
102     void TurnToBase();
103     void ReturnToBox();
104     float Horizon(float h);
105
106         bool OutsideBox();
107     
108         
109         bool init();
110
111         bool getParkPosition(const string& id, Point3D& geodPos,
112                              double& hdng, sgdVec3 uvw);
113
114 private:
115
116         void update(double dt);
117         void mark_nohot(ssgEntity*);
118         
119         bool mark_wires(ssgEntity*, const list<string>&, bool = false);
120         bool mark_cat(ssgEntity*, const list<string>&, bool = false);
121         bool mark_solid(ssgEntity*, const list<string>&, bool = false);
122         double wind_from_east;  // fps
123     double wind_from_north; // fps
124     double rel_wind_speed_kts;
125     double rel_wind_from_deg;
126     
127
128         list<string> solid_objects;       // List of solid object names
129         list<string> wire_objects;        // List of wire object names
130         list<string> catapult_objects;    // List of catapult object names
131         list<ParkPosition> ppositions;    // List of positions where an aircraft can start.
132         string sign;                      // The sign of this carrier.
133
134         // Velocity wrt earth.
135         sgdVec3 vel_wrt_earth;
136         sgdVec3 rot_wrt_earth;
137         sgdVec3 rot_pivot_wrt_earth;
138
139
140         // these describe the flols 
141         Point3D flols_off;
142     
143         double dist;            // the distance of the eyepoint from the flols
144         double angle;
145         int source;             // the flols light which is visible at the moment
146     bool wave_off_lights;
147     
148     // these are for manoeuvring the carrier
149     Point3D carrierpos;
150     Point3D initialpos;
151     
152     double wind_speed_from_north_kts ;
153     double wind_speed_from_east_kts  ;
154     double wind_speed_kts;  //true wind speed
155     double wind_from_deg;   //true wind direction
156     double rel_wind;
157     double max_lat, min_lat, max_long, min_long;
158     double base_course, base_speed;
159     
160     bool turn_to_launch_hdg;
161     bool returning;      // set if the carrier is returning to an operating box
162     bool InToWind();     // set if the carrier is in to wind   
163
164
165     SGPropertyNode_ptr _longitude_node;
166     SGPropertyNode_ptr _latitude_node;
167     SGPropertyNode_ptr _altitude_node;
168     SGPropertyNode_ptr _surface_wind_from_deg_node;
169     SGPropertyNode_ptr _surface_wind_speed_node;
170        
171     // this is for tacan
172     
173     string TACAN_channel_id;
174     
175     // these are for moving the elevators
176     void UpdateElevator( double dt, double transition_time);
177     double step;
178     double pos_norm, raw_pos_norm;
179     double transition_time, time_constant;
180     bool elevators;
181 };
182
183 #endif  // _FG_AICARRIER_HXX