1
0
Fork 0

Viewer update from Jim Wilson:

This patch renames the "goal" orientation offsets inputs/outputs to
conform with the naming of the new interface.
This commit is contained in:
david 2002-03-21 20:59:43 +00:00
parent 7b37a685b7
commit 825320e8bf
5 changed files with 79 additions and 55 deletions

View file

@ -175,7 +175,7 @@ static inline int right_button( void ) {
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 )
@ -185,7 +185,7 @@ 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 )
@ -198,7 +198,7 @@ static inline float get_view_offset() {
}
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) {
@ -665,3 +665,4 @@ void guiMouseFunc(int button, int updown, int x, int y)

View file

@ -885,7 +885,7 @@ parse_option (const string& arg)
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 ) {
@ -1299,3 +1299,4 @@ fgUsage ()
}

View file

@ -54,8 +54,6 @@
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),
@ -71,7 +69,9 @@ FGViewer::FGViewer( void ):
_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;
@ -255,6 +255,40 @@ FGViewer::setHeadingOffset_deg (double heading_offset_deg)
_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)
{
@ -290,7 +324,8 @@ FGViewer::getZeroElevViewPos ()
// 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 ()
{
@ -514,58 +549,58 @@ FGViewer::update (int dt)
{
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 );
}
}
@ -675,3 +710,4 @@ void FGViewer::fgMakeLOCAL( sgMat4 dst, const double Theta,
/* end from rph */

View file

@ -128,12 +128,20 @@ public:
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);
@ -201,10 +209,13 @@ private:
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:
@ -219,11 +230,6 @@ 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;
@ -297,16 +303,6 @@ public:
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;
}
@ -314,16 +310,6 @@ public:
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();
@ -351,8 +337,6 @@ public:
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();
@ -374,3 +358,4 @@ public:
#endif // _VIEWER_HXX

View file

@ -186,7 +186,7 @@ double
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
@ -194,7 +194,7 @@ FGViewMgr::setGoalViewOffset_deg (double offset)
{
FGViewer * view = get_current_view();
if (view != 0)
view->set_goal_view_offset(offset);
view->setGoalHeadingOffset_deg(offset);
}
double
@ -216,7 +216,7 @@ 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
@ -224,7 +224,7 @@ FGViewMgr::setGoalViewTilt_deg (double tilt)
{
FGViewer * view = get_current_view();
if (view != 0)
view->set_goal_view_tilt(tilt);
view->setGoalPitchOffset_deg(tilt);
}
double
@ -361,6 +361,7 @@ FGViewMgr::do_axes ()
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);
}