]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/viewer.hxx
Added a new 'delimiter' property to allow an alternative delimiter to
[flightgear.git] / src / Main / viewer.hxx
index 64cee08deb4360257461f66eee1b1958802055dd..7c1a5e58d27cb39f38f110bd23bbb64f7c015c09 100644 (file)
@@ -31,6 +31,7 @@
 #endif                                   
 
 #include <simgear/compiler.h>
+#include <simgear/constants.h>
 
 #include <plib/sg.h>           // plib include
 
 #define FG_FOV_MAX 179.9
 
 
+/**
+ * Representation of a single viewpoint in the FlightGear world.
+ */
+class FGViewPoint
+{
+public:
+  FGViewPoint ();
+  virtual ~FGViewPoint ();
+
+  /**
+   * Set the geodetic position for the view point.
+   */
+  virtual void setPosition (double lon_deg, double lat_deg, double alt_ft);
+
+
+  /**
+   * Get the longitude in degrees.
+   */
+  virtual double getLongitude_deg () const { return _lon_deg; }
+
+  /**
+   * Get the latitude in degrees.
+   */
+  virtual double getLatitude_deg () const { return _lat_deg; }
+
+  /**
+   * Get the altitude in feet ASL.
+   */
+  virtual double getAltitudeASL_ft () const { return _alt_ft; }
+
+  /**
+   * Get the absolute view position in fgfs coordinates.
+   */
+  virtual const double * getAbsoluteViewPos () const;
+
+
+  /**
+   * Get the relative view position in fgfs coordinates.
+   *
+   * The position is relative to the scenery centre.
+   */
+  virtual const float * getRelativeViewPos () const;
+
+
+  /**
+   * Get the absolute zero-elevation view position in fgfs coordinates.
+   */
+  virtual const float * getZeroElevViewPos () const;
+
+private:
+
+  void recalc () const;
+
+  mutable sgdVec3 _absolute_view_pos;
+  mutable sgVec3 _relative_view_pos;
+  mutable sgVec3 _zero_elev_view_pos;
+
+  bool _dirty;
+  double _lon_deg;
+  double _lat_deg;
+  double _alt_ft;
+
+};
+
+
 // Define a structure containing view information
 class FGViewer {
 
@@ -52,6 +118,13 @@ public:
        FG_HPR = 2
     };
 
+    enum fgScalingType {  // nominal Field Of View actually applies to ...
+       FG_SCALING_WIDTH,       // window width
+       FG_SCALING_MAX,         // max(width, height)
+       // FG_SCALING_G_MEAN,      // geometric_mean(width, height)
+       // FG_SCALING_INDEPENDENT  // whole screen
+    };
+
 private:
 
     // flag forcing a recalc of derived view parameters
@@ -60,12 +133,12 @@ private:
 protected:
 
     fgViewType _type;
+    fgScalingType scalingType;
 
-    // the field of view in the x (width) direction
-    double fov; 
+    FGViewPoint view_point;
 
-    // ratio of x and y fov's; fov(y) = fov(x) * fov_ratio
-    double fov_ratio;
+    // the nominal field of view (angle, in degrees)
+    double fov
 
     // ratio of window width and height; height = width * aspect_ratio
     double aspect_ratio;
@@ -143,13 +216,13 @@ public:
     //////////////////////////////////////////////////////////////////////
     // setter functions
     //////////////////////////////////////////////////////////////////////
-    inline void set_fov( double amount ) { fov = amount; }
-    // Don't provide set_fov_ratio explicitely. Use set_aspect_ratio
-    // instead.
+
+    inline void set_fov( double fov_deg ) {
+       fov = fov_deg;
+    }
+
     inline void set_aspect_ratio( double r ) {
        aspect_ratio = r;
-       fov_ratio = atan(tan(fov/2 * SG_DEGREES_TO_RADIANS) * aspect_ratio) *
-           SG_RADIANS_TO_DEGREES / (fov/2);
     }
     inline void set_view_offset( double a ) {
        set_dirty();
@@ -162,11 +235,11 @@ public:
     inline void set_goal_view_offset( double a) {
        set_dirty();
        goal_view_offset = a;
-       while ( goal_view_offset < 0 ) {
-           goal_view_offset += 360.0;
+       while ( goal_view_offset < 0.0 ) {
+           goal_view_offset += SGD_2PI;
        }
-       while ( goal_view_offset > 360.0 ) {
-           goal_view_offset -= 360.0;
+       while ( goal_view_offset > SGD_2PI ) {
+           goal_view_offset -= SGD_2PI;
        }
     }
     inline void set_reverse_view_offset( bool val ) {
@@ -215,7 +288,6 @@ public:
     inline bool is_dirty() const { return dirty; }
     inline double get_fov() const { return fov; }
     inline double get_aspect_ratio() const { return aspect_ratio; }
-    inline double get_fov_ratio() const { return fov_ratio; }
     inline double get_view_offset() const { return view_offset; }
     inline bool get_reverse_view_offset() const { return reverse_view_offset; }
     inline double get_goal_view_offset() const { return goal_view_offset; }
@@ -224,6 +296,10 @@ public:
     inline double *get_geod_view_pos() { return geod_view_pos; }
     inline float *get_pilot_offset() { return pilot_offset; }
     inline double get_sea_level_radius() const { return sea_level_radius; }
+    // Get horizontal field of view angle, in degrees.
+    double get_h_fov();
+    // Get vertical field of view angle, in degrees.
+    double get_v_fov();
 
     //////////////////////////////////////////////////////////////////////
     // derived values accessor functions