]> git.mxchange.org Git - flightgear.git/blobdiff - src/Environment/environment_ctrl.hxx
Add Nasal Vs. 1.5
[flightgear.git] / src / Environment / environment_ctrl.hxx
index 17ed581d79a131b4154ba248797304c5c0c0cda5..75a8a00a74db1bacf598a338b1bea780802b7cca 100644 (file)
@@ -24,6 +24,7 @@
 #define _ENVIRONMENT_CTRL_HXX
 
 #include <simgear/compiler.h>
+#include <simgear/structure/subsystem_mgr.hxx>
 
 #ifdef SG_HAVE_STD_INCLUDES
 #  include <cmath>
 #  include <math.h>
 #endif
 
+#include <vector>
+
+SG_USING_STD(vector);
+
 class SGPropertyNode;
 
 #include "environment.hxx"
@@ -40,7 +45,7 @@ class SGPropertyNode;
 /**
  * Interface to control environment information for a specific location.
  */
-class FGEnvironmentCtrl
+class FGEnvironmentCtrl : public SGSubsystem
 {
 
 public:
@@ -61,9 +66,6 @@ public:
   virtual double getLatitudeDeg () const { return _lat_deg; }
   virtual double getElevationFt () const { return _elev_ft; }
 
-  virtual void init () = 0;
-  virtual void update (double dt) = 0;
-
 protected:
 
   FGEnvironment * _environment;
@@ -97,4 +99,38 @@ private:
 
 };
 
+
+\f
+/**
+ * Interplation controller using user-supplied parameters.
+ */
+class FGInterpolateEnvironmentCtrl : public FGEnvironmentCtrl
+{
+public:
+    FGInterpolateEnvironmentCtrl ();
+    virtual ~FGInterpolateEnvironmentCtrl ();
+    
+    virtual void init ();
+    virtual void reinit ();
+    virtual void update (double delta_time_sec);
+
+private:
+    
+    struct bucket {
+        double altitude_ft;
+        FGEnvironment environment;
+        bool operator< (const bucket &b) const;
+    };
+
+    void read_table (const SGPropertyNode * node, vector<bucket *> &table);
+    void do_interpolate (vector<bucket *> &table, double altitude_ft,
+                         FGEnvironment * environment);
+
+    FGEnvironment env1, env2;   // temporaries
+
+    vector<bucket *> _boundary_table;
+    vector<bucket *> _aloft_table;
+};
+
+
 #endif // _ENVIRONMENT_CTRL_HXX