]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIShip.hxx
Merge branch 'jsd/atmos' into topic/atmos-merge
[flightgear.git] / src / AIModel / AIShip.hxx
1 // FGAIShip - AIBase derived class creates an AI ship
2 //
3 // Written by David Culp, started November 2003.
4 // with major amendments and additions by Vivian Meazza, 2004 - 2007 
5 //
6 // Copyright (C) 2003  David P. Culp - davidculp2@comcast.net
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
22 #ifndef _FG_AISHIP_HXX
23 #define _FG_AISHIP_HXX
24
25 #include "AIBase.hxx"
26 #include "AIFlightPlan.hxx"
27 #include <simgear/scene/material/mat.hxx>
28
29 class FGAIManager;
30
31 class FGAIShip : public FGAIBase {
32
33 public:
34
35     FGAIShip(object_type ot = otShip);
36     virtual ~FGAIShip();
37
38     virtual void readFromScenario(SGPropertyNode* scFileNode);
39
40     virtual bool init(bool search_in_AI_path=false);
41     virtual void bind();
42     virtual void unbind();
43     virtual void update(double dt);
44     void setFlightPlan(FGAIFlightPlan* f);
45     void setName(const string&);
46     void setRudder(float r);
47     void setRoll(double rl);
48     void ProcessFlightPlan( double dt);
49     void AccelTo(double speed);
50     void PitchTo(double angle);
51     void RollTo(double angle);
52     void YawTo(double angle);
53     void ClimbTo(double altitude);
54     void TurnTo(double heading);
55     void setCurrName(const string&);
56     void setNextName(const string&);
57     void setPrevName(const string&);
58     void setLeadAngleGain(double g);
59     void setLeadAngleLimit(double l);
60     void setLeadAngleProp(double p);
61     void setRudderConstant(double rc);
62     void setSpeedConstant(double sc);
63     void setFixedTurnRadius(double ft);
64     void setWPNames();
65     double sign(double x);
66
67     bool _hdg_lock;
68     bool _serviceable;
69     bool _waiting;
70     bool _new_waypoint;
71
72     virtual const char* getTypeString(void) const { return "ship"; }
73     double _rudder_constant, _speed_constant, _hdg_constant, _limit ;
74     double _elevation_m, _elevation_ft;
75     double _missed_range, _tow_angle, _wait_count;
76
77     FGAIFlightPlan::waypoint* prev; // the one behind you
78     FGAIFlightPlan::waypoint* curr; // the one ahead
79     FGAIFlightPlan::waypoint* next; // the next plus 1
80
81 protected:
82
83     string _name; // The name of this ship.
84
85 private:
86
87
88
89     virtual void reinit() { init(); }
90
91     void setRepeat(bool r);
92     void setMissed(bool m);
93
94     void setServiceable(bool s);
95     void Run(double dt);
96     void setStartTime(const string&);
97     void setUntilTime(const string&);
98     void setWPPos();
99     void setWPAlt();
100     void setXTrackError();
101
102     SGGeod wppos;
103
104     const SGMaterial* _material;
105
106     double getRange(double lat, double lon, double lat2, double lon2) const;
107     double getCourse(double lat, double lon, double lat2, double lon2) const;
108     double getDaySeconds();
109     double processTimeString(const string& time);
110
111     bool initFlightPlan();
112     bool advanceFlightPlan (double elapsed_sec, double day_sec);
113
114     float _rudder, _tgt_rudder;
115
116     double _roll_constant, _roll_factor;
117     double _sp_turn_radius_ft, _rd_turn_radius_ft, _fixed_turn_radius;
118     double _wp_range, _old_range, _range_rate;
119     double _dt_count, _missed_count;
120     double _next_run;
121     double _missed_time_sec;
122     double _start_sec;
123     double _day;
124     double _lead_angle;
125     double _lead_angle_gain, _lead_angle_limit, _proportion;
126     double _course;
127     double _xtrack_error;
128
129     string _prev_name, _curr_name, _next_name;
130     string _path;
131     string _start_time, _until_time;
132
133     bool _repeat;
134     bool _fp_init;
135     bool _missed;
136
137 };
138
139 #endif  // _FG_AISHIP_HXX