]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/viewer.hxx
- removed references to FGSoundMgr
[flightgear.git] / src / Main / viewer.hxx
index 4e74425f0896ef0864420f6b33408e806db6c15f..ccb51e5c0665900a639503dda26dc835457a0409 100644 (file)
@@ -62,8 +62,11 @@ 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)
@@ -130,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;
@@ -142,6 +151,12 @@ 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;
@@ -170,7 +185,8 @@ 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; }