]> 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 62b2d6c4ebf9f3709253768ca9ffe86e3bced500..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 {
 
@@ -69,6 +135,8 @@ protected:
     fgViewType _type;
     fgScalingType scalingType;
 
+    FGViewPoint view_point;
+
     // the nominal field of view (angle, in degrees)
     double fov; 
 
@@ -167,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 ) {