]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIShip.hxx
c15b45731b311ff5d453f1790d21dd6f01184012
[flightgear.git] / src / AIModel / AIShip.hxx
1 // FGAIShip - AIBase derived class creates an AI ship\r
2 //\r
3 // Written by David Culp, started November 2003.\r
4 // with major amendments and additions by Vivian Meazza, 2004 - 2007 \r
5 //\r
6 // Copyright (C) 2003  David P. Culp - davidculp2@comcast.net\r
7 //\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
12 //\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
17 //\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
21 \r
22 #ifndef _FG_AISHIP_HXX\r
23 #define _FG_AISHIP_HXX\r
24 \r
25 #include "AIBase.hxx"\r
26 #include "AIFlightPlan.hxx"\r
27 #include <simgear/scene/material/mat.hxx>\r
28 \r
29 class FGAIManager;\r
30 \r
31 class FGAIShip : public FGAIBase {\r
32 \r
33 public:\r
34 \r
35     FGAIShip(object_type ot = otShip);\r
36     virtual ~FGAIShip();\r
37 \r
38     virtual void readFromScenario(SGPropertyNode* scFileNode);\r
39 \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
66 \r
67     void setWPNames();\r
68     void setWPPos();\r
69     double sign(double x);\r
70 \r
71     bool _hdg_lock;\r
72     bool _serviceable;\r
73     bool _waiting;\r
74     bool _new_waypoint;\r
75     bool _tunnel, _initial_tunnel;\r
76     bool _restart;\r
77 \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
83 \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
87 \r
88 protected:\r
89 \r
90 //    string _name; // The name of this ship.\r
91 \r
92 private:\r
93 \r
94 \r
95 \r
96     virtual void reinit() { init(); }\r
97 \r
98     void setRepeat(bool r);\r
99     void setRestart(bool r);\r
100     void setMissed(bool m);\r
101 \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
106     //void setWPPos();\r
107     void setWPAlt();\r
108     void setXTrackError();\r
109 \r
110     SGGeod wppos;\r
111 \r
112     const SGMaterial* _material;\r
113 \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
118 \r
119     bool initFlightPlan();\r
120     bool advanceFlightPlan (double elapsed_sec, double day_sec);\r
121 \r
122     float _rudder, _tgt_rudder;\r
123 \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
128     double _start_sec;\r
129     double _day;\r
130     double _lead_angle;\r
131     double _lead_angle_gain, _lead_angle_limit, _proportion;\r
132     double _course;\r
133     double _xtrack_error;\r
134     double _curr_alt, _prev_alt;\r
135 \r
136     string _prev_name, _curr_name, _next_name;\r
137     string _path;\r
138     string _start_time, _until_time;\r
139 \r
140     bool _repeat;\r
141     bool _fp_init;\r
142     bool _missed;\r
143    \r
144 \r
145 };\r
146 \r
147 #endif  // _FG_AISHIP_HXX\r