X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Fviewer.hxx;h=107401a373fa572b73e82251c09718a63caaa104;hb=4141c6f8bb42b3491502f5e6b82595367da9fb69;hp=288c9543ca3a32d38bd0fba169f04a7ce3274b06;hpb=0175b4cd253a69f22cc28f8f42fc019af26641e5;p=flightgear.git diff --git a/src/Main/viewer.hxx b/src/Main/viewer.hxx index 288c9543c..107401a37 100644 --- a/src/Main/viewer.hxx +++ b/src/Main/viewer.hxx @@ -31,14 +31,25 @@ #endif #include -#include #include // plib include +#define FG_FOV_MIN 0.1 +#define FG_FOV_MAX 179.9 + + // Define a structure containing view information class FGViewer { +public: + + enum fgViewType { + FG_RPH = 0, + FG_LOOKAT = 1, + FG_HPR = 2 + }; + private: // flag forcing a recalc of derived view parameters @@ -46,13 +57,25 @@ private: protected: + fgViewType _type; + + // 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; + // 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; + // geodetic view position + sgdVec3 geod_view_pos; + // absolute view position in earth coordinates sgdVec3 abs_view_pos; @@ -67,25 +90,14 @@ protected: // translated to scenery.center sgVec3 zero_elev; + // height ASL of the terrain for our current view position + // (future?) double ground_elev; + // pilot offset from center of gravity. The X axis is positive // out the tail, Y is out the right wing, and Z is positive up. // Distances in meters of course. sgVec3 pilot_offset; - // vector in cartesian coordinates from current position to the - // postion on the earth's surface the sun is directly over - sgVec3 to_sun; - - // surface direction to go to head towards sun - sgVec3 surface_to_sun; - - // vector in cartesian coordinates from current position to the - // postion on the earth's surface the moon is directly over - sgVec3 to_moon; - - // surface direction to go to head towards moon - sgVec3 surface_to_moon; - // surface vector heading south sgVec3 surface_south; @@ -93,9 +105,9 @@ protected: // with sun) sgVec3 surface_east; - // local up vector (normal to the plane tangent to the earth's + // world up vector (normal to the plane tangent to the earth's // surface at the spot we are directly above - sgVec3 local_up; + sgVec3 world_up; // sg versions of our friendly matrices sgMat4 VIEW, VIEW_ROT, UP; @@ -104,7 +116,7 @@ protected: inline void set_clean() { dirty = false; } // Update the view volume, position, and orientation - virtual void update(); + virtual void update() = 0; public: @@ -114,12 +126,11 @@ public: // Destructor virtual ~FGViewer( void ); - // Initialize a view class - virtual void init( void ); - ////////////////////////////////////////////////////////////////////// // setter functions ////////////////////////////////////////////////////////////////////// + inline void set_fov( double amount ) { fov = amount; } + inline void set_win_ratio( double r ) { win_ratio = r; } inline void set_view_offset( double a ) { set_dirty(); view_offset = a; @@ -131,6 +142,22 @@ 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 + set_dirty(); + // cout << "set_geod_view_pos = " << lon << ", " << lat << ", " << alt + // << endl; + sgdSetVec3( geod_view_pos, lon, lat, alt ); } inline void set_pilot_offset( float x, float y, float z ) { set_dirty(); @@ -145,9 +172,15 @@ public: ////////////////////////////////////////////////////////////////////// // accessor functions ////////////////////////////////////////////////////////////////////// + inline int get_type() const { return _type ; } + 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_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; } inline double get_sea_level_radius() const { return sea_level_radius; } @@ -166,6 +199,11 @@ public: if ( dirty ) { update(); } return zero_elev; } + // (future?) + // inline double get_ground_elev() { + // if ( dirty ) { update(); } + // return ground_elev; + // } inline float *get_surface_south() { if ( dirty ) { update(); } return surface_south; @@ -174,9 +212,9 @@ public: if ( dirty ) { update(); } return surface_east; } - inline float *get_local_up() { + inline float *get_world_up() { if ( dirty ) { update(); } - return local_up; + return world_up; } inline const sgVec4 *get_VIEW() { if ( dirty ) { update(); } @@ -190,26 +228,6 @@ public: if ( dirty ) { update(); } return UP; } - - ////////////////////////////////////////////////////////////////////// - // need to fix these - ////////////////////////////////////////////////////////////////////// - inline float *get_to_sun() { return to_sun; } - inline void set_to_sun( float x, float y, float z ) { - sgSetVec3( to_sun, x, y, z ); - } - inline float *get_surface_to_sun() { return surface_to_sun; } - inline void set_surface_to_sun( float x, float y, float z) { - sgSetVec3( surface_to_sun, x, y, z ); - } - inline float *get_to_moon() { return to_moon; } - inline void set_to_moon( float x, float y, float z) { - sgSetVec3( to_moon, x, y, z ); - } - inline float *get_surface_to_moon() { return surface_to_moon; } - inline void set_surface_to_moon( float x, float y, float z) { - sgSetVec3( surface_to_moon, x, y, z ); - } };