1 // FGAICarrier - AIShip-derived class creates an AI aircraft carrier
3 // Written by David Culp, started October 2004.
5 // Copyright (C) 2004 David P. Culp - davidculp2@comcast.net
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.
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.
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.
21 #ifndef _FG_AICARRIER_HXX
22 #define _FG_AICARRIER_HXX
27 #include <simgear/compiler.h>
34 #include "AIManager.hxx"
40 class FGAICarrierHardware : public ssgBase {
43 enum Type { Catapult, Wire, Solid };
49 static FGAICarrierHardware* newCatapult(FGAICarrier *c) {
50 FGAICarrierHardware* ch = new FGAICarrierHardware;
56 static FGAICarrierHardware* newWire(FGAICarrier *c) {
57 FGAICarrierHardware* ch = new FGAICarrierHardware;
63 static FGAICarrierHardware* newSolid(FGAICarrier *c) {
64 FGAICarrierHardware* ch = new FGAICarrierHardware;
76 class FGAICarrier : public FGAIShip {
80 virtual ~FGAICarrier();
82 virtual void readFromScenario(SGPropertyNode* scFileNode);
84 void setSign(const string& );
85 void setTACANChannelID(const string &);
87 void getVelocityWrtEarth(sgdVec3& v, sgdVec3& omega, sgdVec3& pivot);
89 virtual void unbind();
90 void UpdateFlols ( const sgdMat3& trans );
91 void UpdateWind ( double dt );
92 void setWind_from_east( double fps );
93 void setWind_from_north( double fps );
94 void setMaxLat( double deg );
95 void setMinLat( double deg );
96 void setMaxLong( double deg );
97 void setMinLong( double deg );
101 float Horizon(float h);
106 virtual const char* getTypeString(void) const { return "carrier"; }
108 bool getParkPosition(const string& id, Point3D& geodPos,
109 double& hdng, sgdVec3 uvw);
112 /// Is sufficient to be private, stores a possible position to place an
113 /// aircraft on start
114 struct ParkPosition {
115 ParkPosition(const ParkPosition& pp)
116 : name(pp.name), offset(pp.offset), heading_deg(pp.heading_deg)
118 ParkPosition(const string& n, const Point3D& off = Point3D(), double heading = 0)
119 : name(n), offset(off), heading_deg(heading)
127 void update(double dt);
128 void mark_nohot(ssgEntity*);
130 bool mark_wires(ssgEntity*, const list<string>&, bool = false);
131 bool mark_cat(ssgEntity*, const list<string>&, bool = false);
132 bool mark_solid(ssgEntity*, const list<string>&, bool = false);
133 double wind_from_east; // fps
134 double wind_from_north; // fps
135 double rel_wind_speed_kts;
136 double rel_wind_from_deg;
139 list<string> solid_objects; // List of solid object names
140 list<string> wire_objects; // List of wire object names
141 list<string> catapult_objects; // List of catapult object names
142 list<ParkPosition> ppositions; // List of positions where an aircraft can start.
143 string sign; // The sign of this carrier.
145 // Velocity wrt earth.
146 sgdVec3 vel_wrt_earth;
147 sgdVec3 rot_wrt_earth;
148 sgdVec3 rot_pivot_wrt_earth;
151 // these describe the flols
154 double dist; // the distance of the eyepoint from the flols
156 int source; // the flols light which is visible at the moment
157 bool wave_off_lights;
159 // these are for maneuvering the carrier
163 double wind_speed_from_north_kts ;
164 double wind_speed_from_east_kts ;
165 double wind_speed_kts; //true wind speed
166 double wind_from_deg; //true wind direction
168 double max_lat, min_lat, max_long, min_long;
169 double base_course, base_speed;
171 bool turn_to_launch_hdg;
172 bool returning; // set if the carrier is returning to an operating box
173 bool InToWind(); // set if the carrier is in to wind
176 SGPropertyNode_ptr _longitude_node;
177 SGPropertyNode_ptr _latitude_node;
178 SGPropertyNode_ptr _altitude_node;
179 SGPropertyNode_ptr _surface_wind_from_deg_node;
180 SGPropertyNode_ptr _surface_wind_speed_node;
184 string TACAN_channel_id;
186 // these are for moving the elevators
187 void UpdateElevator( double dt, double transition_time);
189 double pos_norm, raw_pos_norm;
190 double transition_time, time_constant;
194 #endif // _FG_AICARRIER_HXX