1 // FGAIWingman - FGAIBllistic-derived class creates an AI Wingman
3 // Written by Vivian Meazza, started February 2008.
4 // - vivian.meazza at lineone.net
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.
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.
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.
24 #include "AIWingman.hxx"
26 FGAIWingman::FGAIWingman() : FGAIBallistic(otWingman)
29 _formate_to_ac = true;
32 FGAIWingman::~FGAIWingman() {}
34 void FGAIWingman::readFromScenario(SGPropertyNode* scFileNode) {
38 FGAIBase::readFromScenario(scFileNode);
40 setAzimuth(scFileNode->getDoubleValue("azimuth", 0.0));
41 setElevation(scFileNode->getDoubleValue("elevation", 0.0));
42 setLife(scFileNode->getDoubleValue("life", -1));
43 setNoRoll(scFileNode->getBoolValue("no-roll", false));
44 setName(scFileNode->getStringValue("name", "Wingman"));
45 setSMPath(scFileNode->getStringValue("submodel-path", ""));
46 setSubID(scFileNode->getIntValue("SubID", 0));
47 setXoffset(scFileNode->getDoubleValue("x-offset", 0.0));
48 setYoffset(scFileNode->getDoubleValue("y-offset", 0.0));
49 setZoffset(scFileNode->getDoubleValue("z-offset", 0.0));
50 setPitchoffset(scFileNode->getDoubleValue("pitch-offset", 0.0));
51 setRolloffset(scFileNode->getDoubleValue("roll-offset", 0.0));
52 setYawoffset(scFileNode->getDoubleValue("yaw-offset", 0.0));
53 setGroundOffset(scFileNode->getDoubleValue("ground-offset", 0.0));
54 setFormate(scFileNode->getBoolValue("formate", true));
57 void FGAIWingman::bind() {
58 FGAIBallistic::bind();
60 props->tie("load/rel-brg-to-user-deg",
61 SGRawValueMethods<FGAIBallistic,double>
62 (*this, &FGAIBallistic::getRelBrgHitchToUser));
63 props->tie("load/elev-to-user-deg",
64 SGRawValueMethods<FGAIBallistic,double>
65 (*this, &FGAIBallistic::getElevHitchToUser));
66 props->tie("velocities/vertical-speed-fps",
67 SGRawValuePointer<double>(&vs));
68 props->tie("position/x-offset",
69 SGRawValueMethods<FGAIBase,double>(*this, &FGAIBase::_getXOffset, &FGAIBase::setXoffset));
70 props->tie("position/y-offset",
71 SGRawValueMethods<FGAIBase,double>(*this, &FGAIBase::_getYOffset, &FGAIBase::setYoffset));
72 props->tie("position/z-offset",
73 SGRawValueMethods<FGAIBase,double>(*this, &FGAIBase::_getZOffset, &FGAIBase::setZoffset));
74 props->tie("position/tgt-x-offset",
75 SGRawValueMethods<FGAIWingman,double>(*this, &FGAIWingman::getTgtXOffset, &FGAIWingman::setTgtXOffset));
76 props->tie("position/tgt-y-offset",
77 SGRawValueMethods<FGAIWingman,double>(*this, &FGAIWingman::getTgtYOffset, &FGAIWingman::setTgtYOffset));
78 props->tie("position/tgt-z-offset",
79 SGRawValueMethods<FGAIWingman,double>(*this, &FGAIWingman::getTgtZOffset, &FGAIWingman::setTgtZOffset));
82 void FGAIWingman::unbind() {
83 FGAIBallistic::unbind();
85 props->untie("load/rel-brg-to-user-deg");
86 props->untie("load/elev-to-user-deg");
87 props->untie("velocities/vertical-speed-fps");
88 props->untie("position/x-offset");
89 props->untie("position/y-offset");
90 props->untie("position/z-offset");
91 props->untie("position/tgt-x-offset");
92 props->untie("position/tgt-y-offset");
93 props->untie("position/tgt-z-offset");
96 bool FGAIWingman::init(bool search_in_AI_path) {
97 if (!FGAIBallistic::init(search_in_AI_path))
102 _tgt_x_offset = _x_offset;
103 _tgt_y_offset = _y_offset;
104 _tgt_z_offset = _z_offset;
114 void FGAIWingman::update(double dt) {
115 FGAIBallistic::update(dt);