]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/YASim/FGFDM.cpp
Fix stall widths for the "auxilliary" (reverse flow) stalls so they
[flightgear.git] / src / FDM / YASim / FGFDM.cpp
index 57d95c041571e5e58d2b296c7d922f31f80f655c..1ebc5247681432a96a2d633fb696f5247dd4fe97 100644 (file)
@@ -7,6 +7,8 @@
 #include "Jet.hpp"
 #include "SimpleJet.hpp"
 #include "Gear.hpp"
+#include "Hook.hpp"
+#include "Launchbar.hpp"
 #include "Atmosphere.hpp"
 #include "PropEngine.hpp"
 #include "Propeller.hpp"
@@ -46,6 +48,8 @@ static const float NM2FTLB = (1/(LBS2N*FT2M));
 
 FGFDM::FGFDM()
 {
+    _vehicle_radius = 0.0f;
+
     _nextEngine = 0;
 
     // Map /controls/flight/elevator to the approach elevator control.  This
@@ -104,7 +108,7 @@ void FGFDM::iterate(float dt)
     } 
     _airplane.calcFuelWeights();
     
-    setOutputProperties();
+    setOutputProperties(dt);
 }
 
 Airplane* FGFDM::getAirplane()
@@ -216,6 +220,8 @@ void FGFDM::startElement(const char* name, const XMLAttributes &atts)
        if(a->hasAttribute("epr"))  j->setEPR(attrf(a, "epr"));
        if(a->hasAttribute("exhaust-speed"))
            j->setVMax(attrf(a, "exhaust-speed") * KTS2MPS);
+       if(a->hasAttribute("spool-time"))
+           j->setSpooling(attrf(a, "spool-time"));
        
        j->setPosition(v);
        _airplane.addThruster(j, mass, v);
@@ -231,9 +237,21 @@ void FGFDM::startElement(const char* name, const XMLAttributes &atts)
        v[1] = attrf(a, "y");
        v[2] = attrf(a, "z");
        g->setPosition(v);
-       v[0] = 0;
-       v[1] = 0;
-       v[2] = attrf(a, "compression", 1);
+        float nrm = Math::mag3(v);
+        if (_vehicle_radius < nrm)
+            _vehicle_radius = nrm;
+        if(a->hasAttribute("upx")) {
+            v[0] = attrf(a, "upx");
+            v[1] = attrf(a, "upy");
+            v[2] = attrf(a, "upz");
+            Math::unit3(v, v);
+        } else {
+            v[0] = 0;
+            v[1] = 0;
+            v[2] = 1;
+        }
+        for(int i=0; i<3; i++)
+            v[i] *= attrf(a, "compression", 1);
        g->setCompression(v);
         g->setBrake(attrf(a, "skid", 0));
        g->setStaticFriction(attrf(a, "sfric", 0.8));
@@ -241,6 +259,37 @@ void FGFDM::startElement(const char* name, const XMLAttributes &atts)
         g->setSpring(attrf(a, "spring", 1));
         g->setDamping(attrf(a, "damp", 1));
        _airplane.addGear(g);
+    } else if(eq(name, "hook")) {
+       Hook* h = new Hook();
+       _currObj = h;
+       v[0] = attrf(a, "x");
+       v[1] = attrf(a, "y");
+       v[2] = attrf(a, "z");
+       h->setPosition(v);
+        float length = attrf(a, "length", 1.0);
+        h->setLength(length);
+        float nrm = length+Math::mag3(v);
+        if (_vehicle_radius < nrm)
+            _vehicle_radius = nrm;
+        h->setDownAngle(attrf(a, "down-angle", 70) * DEG2RAD);
+        h->setUpAngle(attrf(a, "up-angle", 0) * DEG2RAD);
+       _airplane.addHook(h);
+    } else if(eq(name, "launchbar")) {
+       Launchbar* l = new Launchbar();
+       _currObj = l;
+       v[0] = attrf(a, "x");
+       v[1] = attrf(a, "y");
+       v[2] = attrf(a, "z");
+       l->setLaunchbarMount(v);
+       v[0] = attrf(a, "holdback-x", v[0]);
+       v[1] = attrf(a, "holdback-y", v[1]);
+       v[2] = attrf(a, "holdback-z", v[2]);
+       l->setHoldbackMount(v);
+        float length = attrf(a, "length", 1.0);
+        l->setLength(length);
+        l->setDownAngle(attrf(a, "down-angle", 30) * DEG2RAD);
+        l->setUpAngle(attrf(a, "up-angle", -30) * DEG2RAD);
+       _airplane.addLaunchbar(l);
     } else if(eq(name, "fuselage")) {
        float b[3];
        v[0] = attrf(a, "ax");
@@ -391,7 +440,19 @@ void FGFDM::getExternalInput(float dt)
     }
 }
 
-void FGFDM::setOutputProperties()
+// Linearly "seeks" a property by the specified fraction of the way to
+// the target value.  Used to emulate "slowly changing" output values.
+static void moveprop(SGPropertyNode* node, const char* prop,
+                    float target, float frac)
+{
+    float val = node->getFloatValue(prop);
+    if(frac > 1) frac = 1;
+    if(frac < 0) frac = 0;
+    val += (target - val) * frac;
+    node->setFloatValue(prop, val);
+}
+
+void FGFDM::setOutputProperties(float dt)
 {
     // char buf[256];
     int i;
@@ -470,6 +531,10 @@ void FGFDM::setOutputProperties()
                 node->setFloatValue("mp-inhg", pe->getMP() * (1/INHG2PA));
                 node->setFloatValue("egt-degf",
                                     pe->getEGT() * K2DEGF + K2DEGFOFFSET);
+                node->setFloatValue("oil-temperature-degf",
+                                    pe->getOilTemp() * K2DEGF + K2DEGFOFFSET);
+                node->setFloatValue("boost-gauge-inhg",
+                                    pe->getBoost() * (1/INHG2PA));
             } else if(p->getEngine()->isTurbineEngine()) {
                 TurbineEngine* te = p->getEngine()->isTurbineEngine();
                 node->setFloatValue("n2", te->getN2());
@@ -483,6 +548,15 @@ void FGFDM::setOutputProperties()
             node->setFloatValue("epr", j->getEPR());
             node->setFloatValue("egr-degf",
                                 j->getEGT() * K2DEGF + K2DEGFOFFSET);
+
+            // These are "unmodeled" values that are still needed for
+            // many cockpits.  Tie them all to the N1 speed, but
+            // normalize the numbers to the range [0:1] so the
+            // cockpit code can scale them to the right values.
+            float pnorm = j->getPerfNorm();
+            moveprop(node, "oilp-norm", pnorm, dt/3); // 3s seek time
+            moveprop(node, "oilt-norm", pnorm, dt/30); // 30s 
+            moveprop(node, "itt-norm", pnorm, dt/1); // 1s
         }
     }
 }
@@ -696,6 +770,9 @@ void FGFDM::parsePropeller(XMLAttributes* a)
        thruster->setVariableProp(min, max);
     }
 
+    if(attrb(a, "contra"))
+        thruster->setContraPair(true);
+
     if(a->hasAttribute("manual-pitch")) {
        prop->setManualPitch();
     }
@@ -748,6 +825,8 @@ int FGFDM::parseOutput(const char* name)
     if(eq(name, "BRAKE"))     return ControlMap::BRAKE;
     if(eq(name, "STEER"))     return ControlMap::STEER;
     if(eq(name, "EXTEND"))    return ControlMap::EXTEND;
+    if(eq(name, "HEXTEND"))   return ControlMap::HEXTEND;
+    if(eq(name, "LEXTEND"))   return ControlMap::LEXTEND;
     if(eq(name, "INCIDENCE")) return ControlMap::INCIDENCE;
     if(eq(name, "FLAP0"))     return ControlMap::FLAP0;
     if(eq(name, "FLAP1"))     return ControlMap::FLAP1;