diff --git a/src/AIModel/AIBallistic.cxx b/src/AIModel/AIBallistic.cxx index 0306c3ec5..2f5bb4f6f 100644 --- a/src/AIModel/AIBallistic.cxx +++ b/src/AIModel/AIBallistic.cxx @@ -479,6 +479,10 @@ bool FGAIBallistic::getSlaved() const { return _slave_to_ac; } +bool FGAIBallistic::getFormate() const { + return _formate_to_ac; +} + double FGAIBallistic::getMass() const { return _mass; } diff --git a/src/AIModel/AIBallistic.hxx b/src/AIModel/AIBallistic.hxx index c9613de89..91a50acbd 100644 --- a/src/AIModel/AIBallistic.hxx +++ b/src/AIModel/AIBallistic.hxx @@ -105,6 +105,7 @@ public: bool getHtAGL(double start); bool getSlaved() const; + bool getFormate() const; bool getSlavedLoad() const; virtual const char* getTypeString(void) const { return "ballistic"; } diff --git a/src/AIModel/AIEscort.cxx b/src/AIModel/AIEscort.cxx index c9901ca24..20d09d252 100644 --- a/src/AIModel/AIEscort.cxx +++ b/src/AIModel/AIEscort.cxx @@ -142,7 +142,7 @@ bool FGAIEscort::init(bool search_in_AI_path) { no_roll = false; props->setStringValue("controls/parent-name", _parent.c_str()); - setParent(); + setParentNode(); pos = _tgtpos; speed = _parent_speed; hdg = _parent_hdg; @@ -233,7 +233,7 @@ bool FGAIEscort::getGroundElev(SGGeod inpos) { } -void FGAIEscort::setParent() { +void FGAIEscort::setParentNode() { const SGPropertyNode_ptr ai = fgGetNode("/ai/models", true); @@ -263,29 +263,75 @@ void FGAIEscort::setParent() { if (_selected_ac != 0){ const string name = _selected_ac->getStringValue("name"); - double lat = _selected_ac->getDoubleValue("position/latitude-deg"); - double lon = _selected_ac->getDoubleValue("position/longitude-deg"); - double elevation = _selected_ac->getDoubleValue("position/altitude-ft"); - _MPControl = _selected_ac->getBoolValue("controls/mp-control"); + setParent(); - _selectedpos.setLatitudeDeg(lat); - _selectedpos.setLongitudeDeg(lon); - _selectedpos.setElevationFt(elevation); + //double lat = _selected_ac->getDoubleValue("position/latitude-deg"); + //double lon = _selected_ac->getDoubleValue("position/longitude-deg"); + //double elevation = _selected_ac->getDoubleValue("position/altitude-ft"); + //_MPControl = _selected_ac->getBoolValue("controls/mp-control"); - _parent_speed = _selected_ac->getDoubleValue("velocities/speed-kts"); - _parent_hdg = _selected_ac->getDoubleValue("orientation/true-heading-deg"); + //_selectedpos.setLatitudeDeg(lat); + //_selectedpos.setLongitudeDeg(lon); + //_selectedpos.setElevationFt(elevation); - if(!_stn_deg_true){ - _stn_truebrg = calcTrueBearingDeg(_stn_brg, _parent_hdg); - _stn_relbrg = _stn_brg; - //cout << _name <<" set rel"<getDoubleValue("velocities/speed-kts"); + //_parent_hdg = _selected_ac->getDoubleValue("orientation/true-heading-deg"); - double course2; + //if(!_stn_deg_true){ + // _stn_truebrg = calcTrueBearingDeg(_stn_brg, _parent_hdg); + // _stn_relbrg = _stn_brg; + // //cout << _name <<" set rel"<getDoubleValue("position/latitude-deg"); + double lon = _selected_ac->getDoubleValue("position/longitude-deg"); + double elevation = _selected_ac->getDoubleValue("position/altitude-ft"); + _MPControl = _selected_ac->getBoolValue("controls/mp-control"); + + _selectedpos.setLatitudeDeg(lat); + _selectedpos.setLongitudeDeg(lon); + _selectedpos.setElevationFt(elevation); + + _parent_speed = _selected_ac->getDoubleValue("velocities/speed-kts"); + _parent_hdg = _selected_ac->getDoubleValue("orientation/true-heading-deg"); + + if(!_stn_deg_true){ + _stn_truebrg = calcTrueBearingDeg(_stn_brg, _parent_hdg); + _stn_relbrg = _stn_brg; + //cout << _name <<" set rel"<getBoolValue("no-roll", true)); setName(scFileNode->getStringValue("name", "groundvehicle")); - setSMPath(scFileNode->getStringValue("submodel-path", "")); + setParentName(scFileNode->getStringValue("parent", "")); + setNoRoll(scFileNode->getBoolValue("no-roll", true)); setContactX1offset(scFileNode->getDoubleValue("contact-x1-offset", 0.0)); setContactX2offset(scFileNode->getDoubleValue("contact-x2-offset", 0.0)); setXOffset(scFileNode->getDoubleValue("hitch-x-offset", 35.0)); @@ -74,7 +74,6 @@ void FGAIGroundVehicle::readFromScenario(SGPropertyNode* scFileNode) { setYawoffset(scFileNode->getDoubleValue("yaw-offset", 0.0)); setPitchCoeff(scFileNode->getDoubleValue("pitch-coefficient", 0.1)); setElevCoeff(scFileNode->getDoubleValue("elevation-coefficient", 0.25)); - setParentName(scFileNode->getStringValue("parent", "")); setTowAngleGain(scFileNode->getDoubleValue("tow-angle-gain", 1.0)); setTowAngleLimit(scFileNode->getDoubleValue("tow-angle-limit-deg", 2.0)); setInitialTunnel(scFileNode->getBoolValue("tunnel", false)); @@ -125,7 +124,7 @@ void FGAIGroundVehicle::unbind() { FGAIShip::unbind(); props->untie("controls/constants/elevation-coeff"); - props->untie("controls/constants/pitch-coeff"); + props->untie("controls/constants/pitch-coeff"); props->untie("position/ht-AGL-ft"); props->untie("hitch/rel-bearing-deg"); props->untie("hitch/tow-angle-deg"); @@ -149,6 +148,9 @@ bool FGAIGroundVehicle::init(bool search_in_AI_path) { invisible = false; _limit = 200; no_roll = true; + + props->setStringValue("controls/parent-name", _parent.c_str()); + setParentNode(); return true; } @@ -342,12 +344,15 @@ bool FGAIGroundVehicle::getPitch() { } - getGroundElev(pos); + //getGroundElev(pos); return true; } -void FGAIGroundVehicle::setParent() { +void FGAIGroundVehicle::setParentNode() { + + if(_parent == "") + return; const SGPropertyNode_ptr ai = fgGetNode("/ai/models", true); @@ -377,40 +382,16 @@ void FGAIGroundVehicle::setParent() { if (_selected_ac != 0){ const string name = _selected_ac->getStringValue("name"); - double lat = _selected_ac->getDoubleValue("position/latitude-deg"); - double lon = _selected_ac->getDoubleValue("position/longitude-deg"); - double elevation = _selected_ac->getDoubleValue("position/altitude-ft"); - double hitch_x_offset_m = _selected_ac->getDoubleValue("hitch/x-offset-ft") - * SG_FEET_TO_METER; - double hitch_y_offset_m = _selected_ac->getDoubleValue("hitch/y-offset-ft") - * SG_FEET_TO_METER; - double hitch_z_offset_m = _selected_ac->getDoubleValue("hitch/z-offset-ft") - * SG_FEET_TO_METER; - - _selectedpos.setLatitudeDeg(lat); - _selectedpos.setLongitudeDeg(lon); - _selectedpos.setElevationFt(elevation); - _parent_x_offset = _selected_ac->getDoubleValue("hitch/x-offset-ft"); _parent_y_offset = _selected_ac->getDoubleValue("hitch/y-offset-ft"); _parent_z_offset = _selected_ac->getDoubleValue("hitch/z-offset-ft"); - - _parent_speed = _selected_ac->getDoubleValue("velocities/true-airspeed-kt"); - - SGVec3d rear_hitch(-hitch_x_offset_m, hitch_y_offset_m, 0); - SGVec3d RearHitch = getCartHitchPosAt(rear_hitch); - - SGGeod rearpos = SGGeod::fromCart(RearHitch); - - double user_lat = rearpos.getLatitudeDeg(); - double user_lon = rearpos.getLongitudeDeg(); - - double range, bearing; - - calcRangeBearing(pos.getLatitudeDeg(), pos.getLongitudeDeg(), - user_lat, user_lon, range, bearing); - _range_ft = range * 6076.11549; - _relbrg = calcRelBearingDeg(bearing, hdg); + _hitch_x_offset_m = _selected_ac->getDoubleValue("hitch/x-offset-ft") + * SG_FEET_TO_METER; + _hitch_y_offset_m = _selected_ac->getDoubleValue("hitch/y-offset-ft") + * SG_FEET_TO_METER; + _hitch_z_offset_m = _selected_ac->getDoubleValue("hitch/z-offset-ft") + * SG_FEET_TO_METER; + setParent(); } else { SG_LOG(SG_GENERAL, SG_ALERT, "AIGroundVeh1cle: " << _name << " parent not found: dying "); @@ -419,6 +400,34 @@ void FGAIGroundVehicle::setParent() { } +void FGAIGroundVehicle::setParent(){ + + double lat = _selected_ac->getDoubleValue("position/latitude-deg"); + double lon = _selected_ac->getDoubleValue("position/longitude-deg"); + double elevation = _selected_ac->getDoubleValue("position/altitude-ft"); + + _selectedpos.setLatitudeDeg(lat); + _selectedpos.setLongitudeDeg(lon); + _selectedpos.setElevationFt(elevation); + + _parent_speed = _selected_ac->getDoubleValue("velocities/true-airspeed-kt"); + + SGVec3d rear_hitch(-_hitch_x_offset_m, _hitch_y_offset_m, 0); + SGVec3d RearHitch = getCartHitchPosAt(rear_hitch); + + SGGeod rearpos = SGGeod::fromCart(RearHitch); + + double user_lat = rearpos.getLatitudeDeg(); + double user_lon = rearpos.getLongitudeDeg(); + + double range, bearing; + + calcRangeBearing(pos.getLatitudeDeg(), pos.getLongitudeDeg(), + user_lat, user_lon, range, bearing); + _range_ft = range * 6076.11549; + _relbrg = calcRelBearingDeg(bearing, hdg); +} + void FGAIGroundVehicle::calcRangeBearing(double lat, double lon, double lat2, double lon2, double &range, double &bearing) const { diff --git a/src/AIModel/AIGroundVehicle.hxx b/src/AIModel/AIGroundVehicle.hxx index 721ebf303..4ea7eea98 100644 --- a/src/AIModel/AIGroundVehicle.hxx +++ b/src/AIModel/AIGroundVehicle.hxx @@ -65,6 +65,7 @@ private: void setParentName(const string& p); void setTrainSpeed(double s, double dt, double coeff); void setParent(); + void setParentNode(); void AdvanceFP(); void setTowSpeed(); void RunGroundVehicle(double dt); @@ -93,6 +94,7 @@ private: double _range_ft; double _relbrg; double _parent_speed, _parent_x_offset, _parent_y_offset, _parent_z_offset; + double _hitch_x_offset_m, _hitch_y_offset_m, _hitch_z_offset_m; double _dt_count, _next_run, _break_count; const SGMaterial* _material; diff --git a/src/AIModel/AIShip.cxx b/src/AIModel/AIShip.cxx index 41f09550e..b27b21d96 100644 --- a/src/AIModel/AIShip.cxx +++ b/src/AIModel/AIShip.cxx @@ -99,6 +99,7 @@ void FGAIShip::readFromScenario(SGPropertyNode* scFileNode) { setRudderConstant(scFileNode->getDoubleValue("rudder-constant", 0.5)); setFixedTurnRadius(scFileNode->getDoubleValue("fixed-turn-radius-ft", 500)); setSpeedConstant(scFileNode->getDoubleValue("speed-constant", 0.5)); + setSMPath(scFileNode->getStringValue("submodel-path", "")); if (!flightplan.empty()) { SG_LOG(SG_GENERAL, SG_ALERT, "getting flightplan: " << _name ); @@ -250,12 +251,12 @@ void FGAIShip::update(double dt) { // Update the velocity information stored in those nodes. // Transform that one to the horizontal local coordinate system. SGQuatd ec2hl = SGQuatd::fromLonLat(pos); - // The orientation of the carrier wrt the horizontal local frame + // The orientation of the ship wrt the horizontal local frame SGQuatd hl2body = SGQuatd::fromYawPitchRollDeg(hdg, pitch, roll); // and postrotate the orientation of the AIModel wrt the horizontal // local frame SGQuatd ec2body = ec2hl*hl2body; - // The cartesian position of the carrier in the wgs84 world + // The cartesian position of the ship in the wgs84 world SGVec3d cartPos = SGVec3d::fromGeod(pos); // The simulation time this transform is meant for @@ -680,7 +681,7 @@ void FGAIShip::ProcessFlightPlan(double dt) { if (_next_name == "TUNNEL"){ _tunnel = !_tunnel; - SG_LOG(SG_GENERAL, SG_ALERT, "AIShip: " << _name << " " << sp_turn_radius_nm ); + SG_LOG(SG_GENERAL, SG_DEBUG, "AIShip: " << _name << " " << sp_turn_radius_nm ); fp->IncrementWaypoint(false); next = fp->getNextWaypoint(); @@ -697,7 +698,7 @@ void FGAIShip::ProcessFlightPlan(double dt) { }else if(_next_name == "END" || fp->getNextWaypoint() == 0) { if (_repeat) { - SG_LOG(SG_GENERAL, SG_ALERT, "AIShip: "<< _name << " Flightplan repeating "); + SG_LOG(SG_GENERAL, SG_INFO, "AIShip: "<< _name << " Flightplan repeating "); fp->restart(); prev = curr; curr = fp->getCurrentWaypoint(); @@ -711,7 +712,7 @@ void FGAIShip::ProcessFlightPlan(double dt) { _lead_angle = 0; AccelTo(prev->speed); } else if (_restart){ - SG_LOG(SG_GENERAL, SG_ALERT, "AIShip: " << _name << " Flightplan restarting "); + SG_LOG(SG_GENERAL, SG_INFO, "AIShip: " << _name << " Flightplan restarting "); _missed_count = 0; initFlightPlan(); } else { @@ -755,7 +756,7 @@ void FGAIShip::ProcessFlightPlan(double dt) { _until_time = next->time; setUntilTime(next->time); if (until_time_sec > time_sec) { - SG_LOG(SG_GENERAL, SG_ALERT, "AIShip: " << _name << " " + SG_LOG(SG_GENERAL, SG_INFO, "AIShip: " << _name << " " << curr->name << " waiting until: " << _until_time << " " << until_time_sec << " now " << time_sec ); setSpeed(0); @@ -763,7 +764,7 @@ void FGAIShip::ProcessFlightPlan(double dt) { _waiting = true; return; } else { - SG_LOG(SG_GENERAL, SG_DEBUG, "AIShip: " + SG_LOG(SG_GENERAL, SG_INFO, "AIShip: " << _name << " wait until done: getting new waypoints "); setUntilTime(""); fp->IncrementWaypoint(false); diff --git a/src/AIModel/AIWingman.cxx b/src/AIModel/AIWingman.cxx index 39c20bbc6..2bc8e2c0f 100644 --- a/src/AIModel/AIWingman.cxx +++ b/src/AIModel/AIWingman.cxx @@ -75,6 +75,11 @@ void FGAIWingman::bind() { &FGAIBase::_getLongitude, &FGAIBase::_setLongitude)); + props->tie("controls/formate-to-ac", + SGRawValueMethods + (*this, &FGAIBallistic::getFormate, &FGAIBallistic::setFormate)); + + props->tie("orientation/pitch-deg", SGRawValuePointer(&pitch)); props->tie("orientation/roll-deg", SGRawValuePointer(&roll)); props->tie("orientation/true-heading-deg", SGRawValuePointer(&hdg)); @@ -122,6 +127,8 @@ void FGAIWingman::unbind() { props->untie("orientation/roll-deg"); props->untie("orientation/true-heading-deg"); + props->untie("controls/formate-to-ac"); + props->untie("submodels/serviceable"); props->untie("velocities/true-airspeed-kt"); diff --git a/src/MultiPlayer/multiplaymgr.cxx b/src/MultiPlayer/multiplaymgr.cxx index f20777714..7574332b2 100644 --- a/src/MultiPlayer/multiplaymgr.cxx +++ b/src/MultiPlayer/multiplaymgr.cxx @@ -159,6 +159,7 @@ FGMultiplayMgr::sIdPropertyList[] = { {1101, "sim/model/livery/file", simgear::props::STRING}, {1200, "environment/wildfire/data", simgear::props::STRING}, + {1201, "environment/contrail", simgear::props::INT}, {1300, "tanker", simgear::props::INT},