]> git.mxchange.org Git - flightgear.git/commitdiff
David Culp:
authorehofman <ehofman>
Mon, 23 Feb 2004 20:55:07 +0000 (20:55 +0000)
committerehofman <ehofman>
Mon, 23 Feb 2004 20:55:07 +0000 (20:55 +0000)
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>

src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx
src/AIModel/AIManager.cxx

index 0ee8c8d9528d2df793cdb3a7c2d53fd7763dfa96..16f956ec67d60233493b3676a353fd4c5ec3cac7 100644 (file)
@@ -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;
index 8e9e7618543881c0781d33d6309d692482483e3a..568469542cccc699fc5500b6c1847a07b4719cbd 100644 (file)
@@ -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 );
index 1b39b9afa317f3ea893c69d8de26ee06cd7bff1c..52a1c0fd18c58f84a7fc9c6d783f91fb2c466e6d 100644 (file)
@@ -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();