From 4b424a29e7eccc229bacc1aa94464c164b972e4d Mon Sep 17 00:00:00 2001 From: ehofman Date: Mon, 23 Feb 2004 20:55:07 +0000 Subject: [PATCH] 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. aircraft jet_transport Aircraft/737/Models/boeing733.xml 320.0 3000.0 -122.455 37.69667 200.0 -15.0 --- src/AIModel/AIBase.cxx | 2 +- src/AIModel/AIBase.hxx | 7 ++++++- src/AIModel/AIManager.cxx | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 0ee8c8d95..16f956ec6 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -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; diff --git a/src/AIModel/AIBase.hxx b/src/AIModel/AIBase.hxx index 8e9e76185..568469542 100644 --- a/src/AIModel/AIBase.hxx +++ b/src/AIModel/AIBase.hxx @@ -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 ); diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index 1b39b9afa..52a1c0fd1 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -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(); -- 2.39.5