]> git.mxchange.org Git - flightgear.git/commitdiff
This patch only affects aircraft (AI Models) that have no predefined
authorcurt <curt>
Fri, 16 Jun 2006 14:22:21 +0000 (14:22 +0000)
committercurt <curt>
Fri, 16 Jun 2006 14:22:21 +0000 (14:22 +0000)
flightplan.  Such aircraft are given some initial conditions that they
fly with.  They proceed on in "freeflight" mode indefinitely.  For example,
there is a refueling demo where the tanker starts at 3000', 280 kts, and
in a 15 degree bank, and then continues to orbit indefinitely.

For these aircraft with no flightplan, I have added several control nodes in
controls/flight that allow a script or menu or external application to set
heading, altitude, bank angle, and speed.  This permits some level of interactive
or scripted control over AI aircraft.

src/AIModel/AIAircraft.cxx
src/AIModel/AIBase.cxx

index cdc1fbf7eb9af16212394f3ad1623b6c805f68cd..0f1295276452c0e932abedb66b2934d9fd3e8482 100644 (file)
@@ -184,6 +184,35 @@ void FGAIAircraft::Run(double dt) {
             }
             return;
         }
+    } else {
+        // no flight plan, update target heading, speed, and altitude
+        // from control properties.  These default to the initial
+        // settings in the config file, but can be changed "on the
+        // fly".
+
+        string lat_mode = props->getStringValue("controls/flight/lateral-mode");
+        if ( lat_mode == "roll" ) {
+            double angle
+                = props->getDoubleValue("controls/flight/target-roll" );
+            RollTo( angle );
+        } else {
+             double angle
+                = props->getDoubleValue("controls/flight/target-hdg" );
+            TurnTo( angle );
+        }
+
+        string lon_mode
+            = props->getStringValue("controls/flight/longitude-mode");
+        if ( lon_mode == "alt" ) {
+            double alt = props->getDoubleValue("controls/flight/target-alt" );
+            ClimbTo( alt );
+        } else {
+            double angle
+                = props->getDoubleValue("controls/flight/target-pitch" );
+            PitchTo( angle );
+        }
+
+        AccelTo( props->getDoubleValue("controls/flight/target-spd" ) );
     }
 
     double turn_radius_ft;
index 8746af4c1048d3ebafa57bb7fa8e5371d75b5b37..1b73b39e7030213659474250c7d3eccd95f91453 100644 (file)
@@ -223,6 +223,17 @@ void FGAIBase::bind() {
    props->setBoolValue("controls/lighting/beacon", true);
    props->setBoolValue("controls/lighting/strobe", true);
    props->setBoolValue("controls/glide-path", true);
+
+   props->setStringValue("controls/flight/lateral-mode", "roll");
+   props->setDoubleValue("controls/flight/target-hdg", hdg);
+   props->setDoubleValue("controls/flight/target-roll", roll);
+
+   props->setStringValue("controls/flight/longitude-mode", "alt");
+   props->setDoubleValue("controls/flight/target-alt", altitude);
+   props->setDoubleValue("controls/flight/target-pitch", pitch);
+
+   props->setDoubleValue("controls/flight/target-spd", speed);
+
 }
 
 void FGAIBase::unbind() {