]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/YASim/Airplane.hpp
simplify name/number handling
[flightgear.git] / src / FDM / YASim / Airplane.hpp
index 4bed725ea169e77ed64889be5ee6c2ad3fb7343d..ad8b2c13e1678c6574e3f9337bff75cdb91dd56b 100644 (file)
@@ -10,6 +10,8 @@
 namespace yasim {
 
 class Gear;
+class Hook;
+class Launchbar;
 class Thruster;
 
 class Airplane {
@@ -18,7 +20,7 @@ public:
     ~Airplane();
 
     void iterate(float dt);
-    void consumeFuel(float dt);
+    void calcFuelWeights();
 
     ControlMap* getControlMap();
     Model* getModel();
@@ -34,34 +36,41 @@ public:
     void setTail(Wing* tail);
     void addVStab(Wing* vstab);
 
-    void addRotor(Rotor* Rotor);
-    int getNumRotors() {return _rotors.size();}
-    Rotor* getRotor(int i) {return (Rotor*)_rotors.get(i);}
-
     void addFuselage(float* front, float* back, float width,
                      float taper=1, float mid=0.5);
     int addTank(float* pos, float cap, float fuelDensity);
     void addGear(Gear* g);
+    void addHook(Hook* h);
+    void addLaunchbar(Launchbar* l);
     void addThruster(Thruster* t, float mass, float* cg);
     void addBallast(float* pos, float mass);
 
     int addWeight(float* pos, float size);
     void setWeight(int handle, float mass);
 
-    void setApproach(float speed, float altitude);
-    void setApproach(float speed, float altitude, float aoa); 
-    void setCruise(float speed, float altitude);
+    void setApproach(float speed, float altitude, float aoa, float fuel);
+    void setCruise(float speed, float altitude, float fuel);
 
     void setElevatorControl(int control);
     void addApproachControl(int control, float val);
     void addCruiseControl(int control, float val);
 
+    void addSolutionWeight(bool approach, int idx, float wgt);
+
     int numGear();
     Gear* getGear(int g);
-
+    Hook* getHook();
+    Rotorgear* getRotorgear();
+    Launchbar* getLaunchbar();
+
+    int numThrusters() { return _thrusters.size(); }
+    Thruster* getThruster(int n) {
+        return ((ThrustRec*)_thrusters.get(n))->thruster; }
+    
     int numTanks();
     void setFuelFraction(float frac); // 0-1, total amount of fuel
     float getFuel(int tank); // in kg!
+    float setFuel(int tank, float fuel); // in kg!
     float getFuelDensity(int tank); // kg/m^3
     float getTankCapacity(int tank);
 
@@ -78,6 +87,8 @@ public:
     float getApproachElevator() { return _approachElevator.val; }
     char* getFailureMsg();
 
+    static void setupState(float aoa, float speed, State* s); // utility
+
 private:
     struct Tank { float pos[3]; float cap; float fill;
                  float density; int handle; };
@@ -87,14 +98,16 @@ private:
                       int handle; float cg[3]; float mass; };
     struct Control { int control; float val; };
     struct WeightRec { int handle; Surface* surf; };
+    struct SolveWeight { bool approach; int idx; float wgt; };
+    struct ContactRec { Gear* gear; float p[3]; };
 
     void runCruise();
     void runApproach();
-    void setupState(float aoa, float speed, State* s);
     void solveGear();
     void solve();
+    void solveHelicopter();
     float compileWing(Wing* w);
-    float compileRotor(Rotor* w);
+    float compileRotorgear();
     float compileFuselage(Fuselage* f);
     void compileGear(GearRec* gr);
     void applyDragFactor(float factor);
@@ -104,6 +117,7 @@ private:
     void compileContactPoints();
     float normFactor(float f);
     void updateGearState();
+    void setupWeights(bool isApproach);
 
     Model _model;
     ControlMap _controls;
@@ -125,7 +139,7 @@ private:
     Vector _weights;
     Vector _surfs; // NON-wing Surfaces
 
-    Vector _rotors;
+    Vector _solveWeights;
 
     Vector _cruiseControls;
     State _cruiseState;
@@ -133,6 +147,7 @@ private:
     float _cruiseT;
     float _cruiseSpeed;
     float _cruiseWeight;
+    float _cruiseFuel;
 
     Vector _approachControls;
     State _approachState;
@@ -141,6 +156,7 @@ private:
     float _approachSpeed;
     float _approachAoA;
     float _approachWeight;
+    float _approachFuel;
 
     int _solutionIterations;
     float _dragFactor;