David Culp:
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>
This commit is contained in:
parent
31e563c2a4
commit
4b424a29e7
3 changed files with 9 additions and 2 deletions
|
@ -47,6 +47,7 @@ FGAIBase *FGAIBase::_self = NULL;
|
|||
FGAIBase::FGAIBase() {
|
||||
_self = this;
|
||||
_type_str = "model";
|
||||
tgt_roll = roll = tgt_pitch = tgt_yaw = tgt_vs = vs = pitch = 0.0;
|
||||
}
|
||||
|
||||
FGAIBase::~FGAIBase() {
|
||||
|
@ -84,7 +85,6 @@ bool FGAIBase::init() {
|
|||
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;
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
void setHeading( double heading );
|
||||
void setLatitude( double latitude );
|
||||
void setLongitude( double longitude );
|
||||
void setBank( double bank );
|
||||
|
||||
void setDie( bool die );
|
||||
bool getDie();
|
||||
|
@ -118,6 +119,10 @@ inline void FGAIBase::setAltitude( double altitude_ft ) {
|
|||
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 );
|
||||
}
|
||||
|
@ -142,7 +147,7 @@ inline double FGAIBase::_getVS_fps() { return _self->vs*60.0; }
|
|||
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 );
|
||||
|
|
|
@ -71,6 +71,7 @@ void FGAIManager::init() {
|
|||
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();
|
||||
|
||||
|
@ -83,6 +84,7 @@ void FGAIManager::init() {
|
|||
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();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue