I went through the AI code to put the "bank" node back into the config file,
so the models can fly circles. While I was in there I made some other
changes.
*) Moved the initialization of roll, tgt-roll, pitch ... etc, from init()
into the constructor, so it wouldn't over-write the config settings.
*) Changed the altitude getter to remove the meters-to-feet conversion. The
altitude is kept internally in feet. Only the scenery code needs meters.
*) Added "bank" item for config file (for type=aircraft). Left bank is
negative.
*) Added "rudder" item for config file (for type=ship). Left rudder is
negative. Internally this is stored in the "roll" variable, but the ship
model doesn't roll. It uses the "roll" variable for turning though.
The following puts a tanker at 3000 feet, 6 nm northwest of KSFO. On takeoff,
the tanker is visible over the hanger building at one-o'clock.
<entry>
<type>aircraft</type>
<class>jet_transport</class>
<path>Aircraft/737/Models/boeing733.xml</path>
<speed-KTAS type="double">320.0</speed-KTAS>
<altitude-ft type="double">3000.0</altitude-ft>
<longitude type="double">-122.455</longitude>
<latitude type="double">37.69667</latitude>
<heading type="double">200.0</heading>
<bank type="double">-15.0</bank>
</entry>
FGAIBase::FGAIBase() {
_self = this;
_type_str = "model";
+ tgt_roll = roll = tgt_pitch = tgt_yaw = tgt_vs = vs = pitch = 0.0;
}
FGAIBase::~FGAIBase() {
SG_LOG(SG_INPUT, SG_WARN, "AIBase: Could not load aircraft model.");
}
- tgt_roll = tgt_pitch = tgt_yaw = tgt_vs = vs = roll = pitch = 0.0;
setDie(false);
return true;
void setHeading( double heading );
void setLatitude( double latitude );
void setLongitude( double longitude );
+ void setBank( double bank );
void setDie( bool die );
bool getDie();
pos.setelev(altitude * SG_FEET_TO_METER);
}
+inline void FGAIBase::setBank( double bank ) {
+ roll = tgt_roll = bank;
+}
+
inline void FGAIBase::setLongitude( double longitude ) {
pos.setlon( longitude );
}
inline void FGAIBase::_setVS_fps( double _vs ) { _self->vs = _vs/60.0; }
inline double FGAIBase::_getAltitude() {
- return _self->altitude * SG_METER_TO_FEET;
+ return _self->altitude;
}
inline void FGAIBase::_setAltitude( double _alt ) {
_self->setAltitude( _alt );
ai_plane->setAltitude(entry->getDoubleValue("altitude-ft"));
ai_plane->setLongitude(entry->getDoubleValue("longitude"));
ai_plane->setLatitude(entry->getDoubleValue("latitude"));
+ ai_plane->setBank(entry->getDoubleValue("bank"));
ai_plane->init();
ai_plane->bind();
ai_ship->setAltitude(entry->getDoubleValue("altitude-ft"));
ai_ship->setLongitude(entry->getDoubleValue("longitude"));
ai_ship->setLatitude(entry->getDoubleValue("latitude"));
+ ai_ship->setBank(entry->getDoubleValue("rudder"));
ai_ship->init();
ai_ship->bind();