]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/viewer.hxx
Merge branch 'jmt/gps' into next
[flightgear.git] / src / Main / viewer.hxx
index 709523d8127410c96e85bde375162cb115f477bf..7cd58adae583058a48911b57a9d553581ebba261 100644 (file)
 
 
 #ifndef _VIEWER_HXX
-#define _VIEWER_HXX
-
-
-#ifndef __cplusplus                                                          
-# error This library requires C++
-#endif                                   
+#define _VIEWER_HXX                                
 
 namespace flightgear
 {
@@ -42,9 +37,7 @@ class CameraGroup;
 #include <simgear/compiler.h>
 #include <simgear/constants.h>
 #include <simgear/structure/subsystem_mgr.hxx>
-#include <simgear/scene/model/location.hxx>
-
-#include <plib/sg.h>           // plib include
+#include <simgear/math/SGMath.hxx>
 
 #define FG_FOV_MIN 0.1
 #define FG_FOV_MAX 179.9
@@ -105,23 +98,12 @@ public:
     //   pilot view, model in model view).
     //   FIXME: the model view position (ie target positions) 
     //   should be in the model class.
-    virtual double getLongitude_deg () const { return _lon_deg; }
-    virtual double getLatitude_deg () const { return _lat_deg; }
-    virtual double getAltitudeASL_ft () const { return _alt_ft; }
-    virtual void setLongitude_deg (double lon_deg);
-    virtual void setLatitude_deg (double lat_deg);
-    virtual void setAltitude_ft (double alt_ft);
     virtual void setPosition (double lon_deg, double lat_deg, double alt_ft);
+    const SGGeod& getPosition() const { return _position; }
 
     // Reference geodetic target position...
-    virtual double getTargetLongitude_deg () const { return _target_lon_deg; }
-    virtual double getTargetLatitude_deg () const { return _target_lat_deg; }
-    virtual double getTargetAltitudeASL_ft () const { return _target_alt_ft; }
-    virtual void setTargetLongitude_deg (double lon_deg);
-    virtual void setTargetLatitude_deg (double lat_deg);
-    virtual void setTargetAltitude_ft (double alt_ft);
     virtual void setTargetPosition (double lon_deg, double lat_deg, double alt_ft);
-
+    const SGGeod& getTargetPosition() const { return _target; }
 
 
 
@@ -137,6 +119,7 @@ public:
     //   orientation rotations listed below.  This has the effect of the 
     //   eye moving around and "looking at" the object (model) from 
     //   different angles.
+    virtual SGVec3d getOffset_m () const { return _offset_m; }
     virtual double getXOffset_m () const { return _offset_m.x(); }
     virtual double getYOffset_m () const { return _offset_m.y(); }
     virtual double getZOffset_m () const { return _offset_m.z(); }
@@ -219,6 +202,7 @@ public:
     const SGVec3d& get_view_pos() { if ( _dirty ) { recalc(); } return _absolute_view_pos; }
     const SGVec3d& getViewPosition() { if ( _dirty ) { recalc(); } return _absolute_view_pos; }
     const SGQuatd& getViewOrientation() { if ( _dirty ) { recalc(); } return mViewOrientation; }
+    const SGQuatd& getViewOrientationOffset() { if ( _dirty ) { recalc(); } return mViewOffsetOr; }
 
     //////////////////////////////////////////////////////////////////////
     // Part 4: View and frustrum data setters and getters
@@ -255,10 +239,6 @@ public:
     inline void set_dirty() { _dirty = true; }
     inline void set_clean() { _dirty = false; }
     
-    // return eye location...
-    virtual SGLocation * getSGLocation () const { return _location; }
-
-
 private:
 
     //////////////////////////////////////////////////////////////////
@@ -269,14 +249,11 @@ private:
     bool _dirty;
 
     SGQuatd mViewOrientation;
+    SGQuatd mViewOffsetOr;
     SGVec3d _absolute_view_pos;
 
-    double _lon_deg;
-    double _lat_deg;
-    double _alt_ft;
-    double _target_lon_deg;
-    double _target_lat_deg;
-    double _target_alt_ft;
+    SGGeod _position;
+    SGGeod _target;
 
     double _roll_deg;
     double _pitch_deg;
@@ -285,15 +262,10 @@ private:
     double _target_pitch_deg;
     double _target_heading_deg;
 
-    double _damp_sync;
-    double _damp_roll;
-    double _damp_pitch;
-    double _damp_heading;
-
-    double _damped_roll_deg;
-    double _damped_pitch_deg;
-    double _damped_heading_deg;
-
+    SGVec3d _dampTarget; ///< current target value we are damping towards
+    SGVec3d _dampOutput; ///< current output of damping filter
+    SGVec3d _dampFactor; ///< weighting of the damping filter
+    
     // Position offsets from FDM origin.  The X axis is positive
     // out the tail, Y is out the right wing, and Z is positive up.
     // distance in meters
@@ -330,9 +302,6 @@ private:
     bool _at_model;
     int _at_model_index;  // number of model (for multi model)
 
-    SGLocation * _location;
-    SGLocation * _target_location;
-
     // the nominal field of view (angle, in degrees)
     double _fov_deg;
 
@@ -354,8 +323,12 @@ private:
     void recalc ();
     void recalcLookFrom();
     void recalcLookAt();
-    void dampEyeData(double &roll_deg, double &pitch_deg, double &heading_deg);
 
+    void setDampTarget(double h, double p, double r);
+    void getDampOutput(double& roll, double& pitch, double& heading);
+    
+    void updateDampOutput(double dt);
+    
     // add to _heading_offset_deg
     inline void incHeadingOffset_deg( double amt ) {
        set_dirty();