X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FMain%2Fviewer.hxx;h=ccb51e5c0665900a639503dda26dc835457a0409;hb=f5c90088237d3272d8ebf917f94eb0b0033d0306;hp=8c9a9311629e29e9a3d73e0315636b9ed43a95d4;hpb=8830f5c6a837bf150020498219c98ea5b15d6d7a;p=flightgear.git diff --git a/src/Main/viewer.hxx b/src/Main/viewer.hxx index 8c9a93116..ccb51e5c0 100644 --- a/src/Main/viewer.hxx +++ b/src/Main/viewer.hxx @@ -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) @@ -116,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: @@ -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; }