]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIWingman.hxx
Don't duplicate userpos in in AIObjects.
[flightgear.git] / src / AIModel / AIWingman.hxx
1 // FGAIWingman - FGAIBllistic-derived class creates an AI Wingman
2 //
3 // Written by Vivian Meazza, started February 2008.
4 // - vivian.meazza at lineone.net
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License as
8 // published by the Free Software Foundation; either version 2 of the
9 // License, or (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19
20 #ifndef _FG_AIWINGMAN_HXX
21 #define _FG_AIWINGMAN_HXX
22
23 #include "AIBallistic.hxx"
24
25 #include "AIManager.hxx"
26 #include "AIBase.hxx"
27
28 #include <simgear/sg_inlines.h>
29
30
31 class FGAIWingman : public FGAIBallistic {
32 public:
33     FGAIWingman();
34     virtual ~FGAIWingman();
35
36     virtual void readFromScenario(SGPropertyNode* scFileNode);
37
38     bool init(bool search_in_AI_path=false);
39     virtual void bind();
40     virtual void reinit();
41     virtual void update (double dt);
42
43     virtual const char* getTypeString(void) const { return "wingman"; }
44
45 private:
46     void formateToAC(double dt);
47     void Break(double dt);
48     void Join(double dt);
49     void Run(double dt);
50
51     double getDistanceToOffset() const;
52     double getElevToOffset() const;
53
54     double calcAngle(double rangeM, SGGeod pos1, SGGeod pos2);
55     double calcDistanceM(SGGeod pos1, SGGeod pos2) const;
56
57     bool   _formate_to_ac;
58     bool   _break;
59     bool   _join;
60
61     double _break_angle; //degrees relative
62     double _coeff_hdg; //dimensionless coefficient
63     double _coeff_pch; //dimensionless coefficient
64     double _coeff_bnk; //dimensionless coefficient
65     double _coeff_spd; //dimensionless coefficient
66
67     SGPropertyNode_ptr user_WoW_node;
68
69     inline void setFormate(bool f);
70     inline void setTgtHdg(double hdg);
71     inline void setTgtSpd(double spd);
72     inline void setBrkHdg(double angle);
73     inline void setBrkAng(double angle);
74     inline void setCoeffHdg(double h);
75     inline void setCoeffPch(double p);
76     inline void setCoeffBnk(double r);
77     inline void setCoeffSpd(double s);
78
79     inline bool getFormate() const { return _formate_to_ac;}
80
81     inline double getTgtHdg() const { return tgt_heading;}
82     inline double getTgtSpd() const { return tgt_speed;}
83     inline double getBrkAng() const { return _break_angle;}
84
85     inline SGVec3d getCartInPos(SGGeod in_pos) const;
86
87 };
88
89 void FGAIWingman::setFormate(bool f) {
90     _formate_to_ac = f;
91 }
92
93 void FGAIWingman::setTgtHdg(double h) {
94     tgt_heading = h;
95 }
96
97 void FGAIWingman::setTgtSpd(double s) {
98     tgt_speed = s;
99 }
100
101 void FGAIWingman::setBrkHdg(double a){
102     tgt_heading = hdg + a ;
103     SG_NORMALIZE_RANGE(tgt_heading, 0.0, 360.0);
104 }
105
106 void FGAIWingman::setBrkAng(double a){
107     _break_angle = a ;
108     SG_NORMALIZE_RANGE(_break_angle, -180.0, 180.0);
109 }
110
111 void FGAIWingman::setCoeffHdg(double h){
112     _coeff_hdg = h;
113 }
114
115 void FGAIWingman::setCoeffPch(double p){
116     _coeff_pch = p;
117 }
118
119 void FGAIWingman::setCoeffBnk(double b){
120     _coeff_bnk = b;
121 }
122
123 void FGAIWingman::setCoeffSpd(double s){
124     _coeff_spd = s;
125 }
126
127 //bool FGAIWingman::getFormate() const {
128 //    return _formate_to_ac;
129 //}
130
131 //double FGAIWingman::getTgtHdg() const{
132 //    return tgt_heading;
133 //}
134
135 //double FGAIWingman::getTgtSpd() const{
136 //    return tgt_speed;
137 //}
138
139 //double FGAIWingman::getBrkAng() const{
140 //    return _break_angle;
141 //}
142
143 SGVec3d FGAIWingman::getCartInPos(SGGeod in_pos) const {
144     SGVec3d cartPos = SGVec3d::fromGeod(in_pos);
145     return cartPos;
146 }
147
148 #endif  // FG_AIWINGMAN_HXX