]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/viewer.hxx
Sync with latest JSBSim CVS
[flightgear.git] / src / Main / viewer.hxx
index 0854934c588586742598af6334aff0a7b39c9fa8..ccb51e5c0665900a639503dda26dc835457a0409 100644 (file)
@@ -62,12 +62,16 @@ protected:
     // the field of view in the x (width) direction
     double fov; 
 
-    // ratio of x and y fov's; fov(y) = fov(x) * win_ratio
-    double win_ratio;
+    // ratio of x and y fov's; fov(y) = fov(x) * fov_ratio
+    double fov_ratio;
+
+    // ratio of window width and height; height = width * aspect_ratio
+    double aspect_ratio;
 
     // the current view offset angle from forward (rotated about the
     // view_up vector)
     double view_offset;
+    bool reverse_view_offset;
 
     // the goal view offset angle  (used for smooth view changes)
     double goal_view_offset;
@@ -115,7 +119,7 @@ protected:
     inline void set_clean() { dirty = false; }
 
     // Update the view volume, position, and orientation
-    virtual void update();
+    virtual void update() = 0;
 
 public:
 
@@ -129,7 +133,13 @@ public:
     // setter functions
     //////////////////////////////////////////////////////////////////////
     inline void set_fov( double amount ) { fov = amount; }
-    inline void set_win_ratio( double r ) { win_ratio = r; }
+    // Don't provide set_fov_ratio explicitely. Use set_aspect_ratio
+    // instead.
+    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();
        view_offset = a;
@@ -141,6 +151,15 @@ 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 > 360.0 ) {
+           goal_view_offset -= 360.0;
+       }
+    }
+    inline void set_reverse_view_offset( bool val ) {
+       reverse_view_offset = val;
     }
     inline void set_geod_view_pos( double lon, double lat, double alt ) {
        // data should be in radians and meters asl
@@ -166,8 +185,10 @@ public:
     inline int is_a( int t ) const { return get_type() == t ; }
     inline bool is_dirty() const { return dirty; }
     inline double get_fov() const { return fov; }
-    inline double get_win_ratio() const { return win_ratio; }
+    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; }
     inline double *get_geod_view_pos() { return geod_view_pos; }
     inline float *get_pilot_offset() { return pilot_offset; }