1 // FGAIShip - AIBase derived class creates an AI ship
\r
3 // Written by David Culp, started November 2003.
\r
4 // with major amendments and additions by Vivian Meazza, 2004 - 2007
\r
6 // Copyright (C) 2003 David P. Culp - davidculp2@comcast.net
\r
8 // This program is free software; you can redistribute it and/or
\r
9 // modify it under the terms of the GNU General Public License as
\r
10 // published by the Free Software Foundation; either version 2 of the
\r
11 // License, or (at your option) any later version.
\r
13 // This program is distributed in the hope that it will be useful, but
\r
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
16 // General Public License for more details.
\r
18 // You should have received a copy of the GNU General Public License
\r
19 // along with this program; if not, write to the Free Software
\r
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
22 #ifndef _FG_AISHIP_HXX
\r
23 #define _FG_AISHIP_HXX
\r
25 #include "AIBase.hxx"
\r
26 #include "AIFlightPlan.hxx"
\r
27 #include <simgear/scene/material/mat.hxx>
\r
31 class FGAIShip : public FGAIBase {
\r
35 FGAIShip(object_type ot = otShip);
\r
36 virtual ~FGAIShip();
\r
38 virtual void readFromScenario(SGPropertyNode* scFileNode);
\r
40 virtual bool init(bool search_in_AI_path=false);
\r
41 virtual void bind();
\r
42 virtual void unbind();
\r
43 virtual void update(double dt);
\r
44 void setFlightPlan(FGAIFlightPlan* f);
\r
45 // void setName(const string&);
\r
46 void setRudder(float r);
\r
47 void setRoll(double rl);
\r
48 void ProcessFlightPlan( double dt);
\r
49 void AccelTo(double speed);
\r
50 void PitchTo(double angle);
\r
51 void RollTo(double angle);
\r
52 void YawTo(double angle);
\r
53 void ClimbTo(double altitude);
\r
54 void TurnTo(double heading);
\r
55 void setCurrName(const string&);
\r
56 void setNextName(const string&);
\r
57 void setPrevName(const string&);
\r
58 void setLeadAngleGain(double g);
\r
59 void setLeadAngleLimit(double l);
\r
60 void setLeadAngleProp(double p);
\r
61 void setRudderConstant(double rc);
\r
62 void setSpeedConstant(double sc);
\r
63 void setFixedTurnRadius(double ft);
\r
64 void setTunnel(bool t);
\r
65 void setInitialTunnel(bool t);
\r
69 double sign(double x);
\r
75 bool _tunnel, _initial_tunnel;
\r
78 virtual const char* getTypeString(void) const { return "ship"; }
\r
79 double _rudder_constant, _speed_constant, _hdg_constant, _limit ;
\r
80 double _elevation_m, _elevation_ft;
\r
81 double _missed_range, _tow_angle, _wait_count, _missed_count,_wp_range;
\r
82 double _dt_count, _next_run;
\r
84 FGAIFlightPlan::waypoint* prev; // the one behind you
\r
85 FGAIFlightPlan::waypoint* curr; // the one ahead
\r
86 FGAIFlightPlan::waypoint* next; // the next plus 1
\r
90 // string _name; // The name of this ship.
\r
96 virtual void reinit() { init(); }
\r
98 void setRepeat(bool r);
\r
99 void setRestart(bool r);
\r
100 void setMissed(bool m);
\r
102 void setServiceable(bool s);
\r
103 void Run(double dt);
\r
104 void setStartTime(const string&);
\r
105 void setUntilTime(const string&);
\r
108 void setXTrackError();
\r
112 const SGMaterial* _material;
\r
114 double getRange(double lat, double lon, double lat2, double lon2) const;
\r
115 double getCourse(double lat, double lon, double lat2, double lon2) const;
\r
116 double getDaySeconds();
\r
117 double processTimeString(const string& time);
\r
119 bool initFlightPlan();
\r
120 bool advanceFlightPlan (double elapsed_sec, double day_sec);
\r
122 float _rudder, _tgt_rudder;
\r
124 double _roll_constant, _roll_factor;
\r
125 double _sp_turn_radius_ft, _rd_turn_radius_ft, _fixed_turn_radius;
\r
126 double _old_range, _range_rate;
\r
127 double _missed_time_sec;
\r
130 double _lead_angle;
\r
131 double _lead_angle_gain, _lead_angle_limit, _proportion;
\r
133 double _xtrack_error;
\r
134 double _curr_alt, _prev_alt;
\r
136 string _prev_name, _curr_name, _next_name;
\r
138 string _start_time, _until_time;
\r
147 #endif // _FG_AISHIP_HXX
\r