static inline void set_goal_view_offset( float offset )
{
- globals->get_current_view()->set_goal_view_offset(offset * SGD_RADIANS_TO_DEGREES);
+ globals->get_current_view()->setGoalHeadingOffset_deg(offset * SGD_RADIANS_TO_DEGREES);
}
static inline void set_view_offset( float offset )
static inline void set_goal_view_tilt( float tilt )
{
- globals->get_current_view()->set_goal_view_tilt(tilt);
+ globals->get_current_view()->setGoalPitchOffset_deg(tilt);
}
static inline void set_view_tilt( float tilt )
}
static inline float get_goal_view_offset() {
- return globals->get_current_view()->get_goal_view_offset() * SGD_DEGREES_TO_RADIANS;
+ return globals->get_current_view()->getGoalHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS;
}
static inline void move_brake(float offset) {
+
FGViewer *pilot_view =
(FGViewer *)globals->get_viewmgr()->get_view( 0 );
pilot_view->setHeadingOffset_deg( default_view_offset * SGD_RADIANS_TO_DEGREES );
- pilot_view->set_goal_view_offset( default_view_offset * SGD_RADIANS_TO_DEGREES );
+ pilot_view->setGoalHeadingOffset_deg( default_view_offset * SGD_RADIANS_TO_DEGREES );
fgSetDouble("/sim/view/offset-deg", default_view_offset * SGD_RADIANS_TO_DEGREES );
// $$$ end - added VS Renganathan, 14 Oct 2K
} else if ( arg.find( "--visibility=" ) == 0 ) {
}
+
FGViewer::FGViewer( void ):
scalingType(FG_SCALING_MAX),
fov(55.0),
- goal_view_offset(0.0),
- goal_view_tilt(0.0),
_dirty(true),
_lon_deg(0),
_lat_deg(0),
_z_offset_m(0),
_heading_offset_deg(0),
_pitch_offset_deg(0),
- _roll_offset_deg(0)
+ _roll_offset_deg(0),
+ _goal_heading_offset_deg(0.0),
+ _goal_pitch_offset_deg(0.0)
{
sgdZeroVec3(_absolute_view_pos);
sea_level_radius = SG_EQUATORIAL_RADIUS_M;
_heading_offset_deg = heading_offset_deg;
}
+void
+FGViewer::setGoalRollOffset_deg (double goal_roll_offset_deg)
+{
+ _dirty = true;
+ _goal_roll_offset_deg = goal_roll_offset_deg;
+}
+
+void
+FGViewer::setGoalPitchOffset_deg (double goal_pitch_offset_deg)
+{
+ _dirty = true;
+ _goal_pitch_offset_deg = goal_pitch_offset_deg;
+ while ( _goal_pitch_offset_deg < -90 ) {
+ _goal_pitch_offset_deg = -90.0;
+ }
+ while ( _goal_pitch_offset_deg > 90.0 ) {
+ _goal_pitch_offset_deg = 90.0;
+ }
+
+}
+
+void
+FGViewer::setGoalHeadingOffset_deg (double goal_heading_offset_deg)
+{
+ _dirty = true;
+ _goal_heading_offset_deg = goal_heading_offset_deg;
+ while ( _goal_heading_offset_deg < 0.0 ) {
+ _goal_heading_offset_deg += 360;
+ }
+ while ( _goal_heading_offset_deg > 360 ) {
+ _goal_heading_offset_deg -= 360;
+ }
+}
+
void
FGViewer::setOrientationOffsets (double roll_offset_deg, double pitch_offset_deg, double heading_offset_deg)
{
// recalc() is done every time one of the setters is called (making the
-// cached data "dirty"). It calculates all the outputs for viewer.
+// cached data "dirty") on the next "get". It calculates all the outputs
+// for viewer.
void
FGViewer::recalc ()
{
{
int i;
for ( i = 0; i < dt; i++ ) {
- if ( fabs(get_goal_view_offset() - getHeadingOffset_deg()) < 1 ) {
- setHeadingOffset_deg( get_goal_view_offset() );
+ if ( fabs( _goal_heading_offset_deg - _heading_offset_deg) < 1 ) {
+ setHeadingOffset_deg( _goal_heading_offset_deg );
break;
} else {
// move current_view.headingoffset towards
// current_view.goal_view_offset
- if ( get_goal_view_offset() > getHeadingOffset_deg() )
+ if ( _goal_heading_offset_deg > _heading_offset_deg )
{
- if ( get_goal_view_offset() - getHeadingOffset_deg() < 180 ){
+ if ( _goal_heading_offset_deg - _heading_offset_deg < 180 ){
inc_view_offset( 0.5 );
} else {
inc_view_offset( -0.5 );
}
} else {
- if ( getHeadingOffset_deg() - get_goal_view_offset() < 180 ){
+ if ( _heading_offset_deg - _goal_heading_offset_deg < 180 ){
inc_view_offset( -0.5 );
} else {
inc_view_offset( 0.5 );
}
}
- if ( getHeadingOffset_deg() > 360 ) {
+ if ( _heading_offset_deg > 360 ) {
inc_view_offset( -360 );
- } else if ( getHeadingOffset_deg() < 0 ) {
+ } else if ( _heading_offset_deg < 0 ) {
inc_view_offset( 360 );
}
}
}
for ( i = 0; i < dt; i++ ) {
- if ( fabs(get_goal_view_tilt() - getPitchOffset_deg()) < 1 ) {
- setPitchOffset_deg( get_goal_view_tilt() );
+ if ( fabs( _goal_pitch_offset_deg - _pitch_offset_deg ) < 1 ) {
+ setPitchOffset_deg( _goal_pitch_offset_deg );
break;
} else {
// move current_view.pitch_offset_deg towards
// current_view.goal_view_tilt
- if ( get_goal_view_tilt() > getPitchOffset_deg() )
+ if ( _goal_pitch_offset_deg > _pitch_offset_deg )
{
- if ( get_goal_view_tilt() - getPitchOffset_deg() < 0 ){
+ if ( _goal_pitch_offset_deg - _pitch_offset_deg < 0 ){
inc_view_tilt( 1.0 );
} else {
inc_view_tilt( -1.0 );
}
} else {
- if ( getPitchOffset_deg() - get_goal_view_tilt() < 0 ){
+ if ( _pitch_offset_deg - _goal_pitch_offset_deg < 0 ){
inc_view_tilt( -1.0 );
} else {
inc_view_tilt( 1.0 );
}
}
- if ( getPitchOffset_deg() > 90 ) {
+ if ( _pitch_offset_deg > 90 ) {
setPitchOffset_deg(90);
- } else if ( getPitchOffset_deg() < -90 ) {
+ } else if ( _pitch_offset_deg < -90 ) {
setPitchOffset_deg( -90 );
}
}
/* end from rph */
+
double z_offset_m);
// Orientation offsets from reference
+ // Goal settings are for smooth transition from prior
+ // offset when changing view direction.
virtual double getRollOffset_deg () const { return _roll_offset_deg; }
virtual double getPitchOffset_deg () const { return _pitch_offset_deg; }
virtual double getHeadingOffset_deg () const { return _heading_offset_deg; }
+ virtual double getGoalRollOffset_deg () const { return _goal_roll_offset_deg; }
+ virtual double getGoalPitchOffset_deg () const { return _goal_pitch_offset_deg; }
+ virtual double getGoalHeadingOffset_deg () const {return _goal_heading_offset_deg; }
virtual void setRollOffset_deg (double roll_offset_deg);
virtual void setPitchOffset_deg (double pitch_offset_deg);
virtual void setHeadingOffset_deg (double heading_offset_deg);
+ virtual void setGoalRollOffset_deg (double goal_roll_offset_deg);
+ virtual void setGoalPitchOffset_deg (double goal_pitch_offset_deg);
+ virtual void setGoalHeadingOffset_deg (double goal_heading_offset_deg);
virtual void setOrientationOffsets (double roll_offset_deg,
double heading_offset_deg,
double pitch_offset_deg);
double _y_offset_m;
double _z_offset_m;
- // orientation offsets from reference
+ // orientation offsets from reference (_goal* are for smoothed transitions)
double _roll_offset_deg;
double _pitch_offset_deg;
double _heading_offset_deg;
+ double _goal_roll_offset_deg;
+ double _goal_pitch_offset_deg;
+ double _goal_heading_offset_deg;
protected:
bool reverse_view_offset;
- // the goal view offset angle (used for smooth view changes)
- double goal_view_offset;
-
- double goal_view_tilt;
-
// view position in opengl world coordinates (this is the
// abs_view_pos translated to scenery.center)
sgVec3 view_pos;
set_dirty();
_heading_offset_deg += amt;
}
- inline void set_goal_view_offset( double a) {
- set_dirty();
- goal_view_offset = a;
- while ( goal_view_offset < 0.0 ) {
- goal_view_offset += 360;
- }
- while ( goal_view_offset > 360 ) {
- goal_view_offset -= 360;
- }
- }
inline void set_reverse_view_offset( bool val ) {
reverse_view_offset = val;
}
set_dirty();
_pitch_offset_deg += amt;
}
- inline void set_goal_view_tilt( double a) {
- set_dirty();
- goal_view_tilt = a;
- while ( goal_view_tilt < -90 ) {
- goal_view_tilt = -90.0;
- }
- while ( goal_view_tilt > 90.0 ) {
- goal_view_tilt = 90.0;
- }
- }
inline void set_sea_level_radius( double r ) {
// data should be in meters from the center of the earth
set_dirty();
inline double get_fov() const { return fov; }
inline double get_aspect_ratio() const { return aspect_ratio; }
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_goal_view_tilt() const { return goal_view_tilt; }
inline double get_sea_level_radius() const { return sea_level_radius; }
// Get horizontal field of view angle, in degrees.
double get_h_fov();
#endif // _VIEWER_HXX
+
FGViewMgr::getGoalViewOffset_deg () const
{
const FGViewer * view = get_current_view();
- return (view == 0 ? 0 : view->get_goal_view_offset());
+ return (view == 0 ? 0 : view->getGoalHeadingOffset_deg());
}
void
{
FGViewer * view = get_current_view();
if (view != 0)
- view->set_goal_view_offset(offset);
+ view->setGoalHeadingOffset_deg(offset);
}
double
FGViewMgr::getGoalViewTilt_deg () const
{
const FGViewer * view = get_current_view();
- return (view == 0 ? 0 : view->get_goal_view_tilt());
+ return (view == 0 ? 0 : view->getGoalPitchOffset_deg());
}
void
{
FGViewer * view = get_current_view();
if (view != 0)
- view->set_goal_view_tilt(tilt);
+ view->setGoalPitchOffset_deg(tilt);
}
double
viewDir = SGD_RADIANS_TO_DEGREES * atan2 ( -axis_lat, -axis_long );
if ( viewDir < -1 ) viewDir += 360;
- get_current_view()->set_goal_view_offset(viewDir);
+ get_current_view()->setGoalHeadingOffset_deg(viewDir);
}
+