1
0
Fork 0

1. Tidies up h-FOV/v-FOV handling and makes window scale depend on

max(width, height) by default (easily changeable) rather than just width.
(src/GUI/gui.cxx, src/Main/main.cxx, src/Main/viewer.cxx, src/Main/viewer.hxx)
This commit is contained in:
curt 2002-02-05 05:51:11 +00:00
parent e12f6757d5
commit f149bcba97
5 changed files with 76 additions and 22 deletions

View file

@ -525,8 +525,8 @@ void fgHiResDump()
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
float fov = globals->get_current_view()->get_fov();
ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
ssgSetFOV( globals->get_current_view()->get_h_fov(),
globals->get_current_view()->get_v_fov() );
// ssgSetNearFar( 10.0f, 120000.0f );
ssgSetNearFar( 0.5f, 1200000.0f );

View file

@ -668,8 +668,8 @@ void fgRenderFrame( void ) {
// glMatrixMode( GL_PROJECTION );
// glLoadIdentity();
float fov = globals->get_current_view()->get_fov();
ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
ssgSetFOV( globals->get_current_view()->get_h_fov(),
globals->get_current_view()->get_v_fov() );
double agl = current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER
- scenery.get_cur_elev();
@ -1309,8 +1309,8 @@ void fgReshape( int width, int height ) {
fgSetInt("/sim/startup/xsize", width);
fgSetInt("/sim/startup/ysize", height);
float fov = globals->get_current_view()->get_fov();
ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
ssgSetFOV( globals->get_current_view()->get_h_fov(),
globals->get_current_view()->get_v_fov() );
fgHUDReshape();
}

View file

@ -37,6 +37,7 @@
// Constructor
FGViewer::FGViewer( void ):
fov(55.0),
scalingType(FG_SCALING_MAX),
view_offset(0.0),
goal_view_offset(0.0),
view_tilt(0.0),
@ -69,6 +70,47 @@ FGViewer::unbind ()
{
}
double
FGViewer::get_h_fov()
{
switch (scalingType) {
case FG_SCALING_WIDTH: // h_fov == fov
return fov;
case FG_SCALING_MAX:
if (aspect_ratio < 1.0) {
// h_fov == fov
return fov;
} else {
// v_fov == fov
return atan(tan(fov/2 * SG_DEGREES_TO_RADIANS) / aspect_ratio) *
SG_RADIANS_TO_DEGREES * 2;
}
default:
assert(false);
}
}
double
FGViewer::get_v_fov()
{
switch (scalingType) {
case FG_SCALING_WIDTH: // h_fov == fov
return atan(tan(fov/2 * SG_DEGREES_TO_RADIANS) * aspect_ratio) *
SG_RADIANS_TO_DEGREES * 2;
case FG_SCALING_MAX:
if (aspect_ratio < 1.0) {
// h_fov == fov
return atan(tan(fov/2 * SG_DEGREES_TO_RADIANS) * aspect_ratio) *
SG_RADIANS_TO_DEGREES * 2;
} else {
// v_fov == fov
return fov;
}
default:
assert(false);
}
}
void
FGViewer::update (int dt)
{

View file

@ -52,6 +52,13 @@ public:
FG_HPR = 2
};
enum fgScalingType { // nominal Field Of View actually applies to ...
FG_SCALING_WIDTH, // window width
FG_SCALING_MAX, // max(width, height)
// FG_SCALING_G_MEAN, // geometric_mean(width, height)
// FG_SCALING_INDEPENDENT // whole screen
};
private:
// flag forcing a recalc of derived view parameters
@ -60,13 +67,11 @@ private:
protected:
fgViewType _type;
fgScalingType scalingType;
// the field of view in the x (width) direction
// the nominal field of view (angle, in degrees)
double fov;
// 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;
@ -143,13 +148,13 @@ public:
//////////////////////////////////////////////////////////////////////
// setter functions
//////////////////////////////////////////////////////////////////////
inline void set_fov( double amount ) { fov = amount; }
// Don't provide set_fov_ratio explicitely. Use set_aspect_ratio
// instead.
inline void set_fov( double fov_deg ) {
fov = fov_deg;
}
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();
@ -215,7 +220,6 @@ public:
inline bool is_dirty() const { return dirty; }
inline double get_fov() const { return fov; }
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; }
@ -224,6 +228,10 @@ public:
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; }
// Get horizontal field of view angle, in degrees.
double get_h_fov();
// Get vertical field of view angle, in degrees.
double get_v_fov();
//////////////////////////////////////////////////////////////////////
// derived values accessor functions

View file

@ -64,14 +64,18 @@ FGSimpleSound::~FGSimpleSound() {
// constructor
FGSoundMgr::FGSoundMgr() {
audio_sched = new slScheduler( 8000 );
audio_sched -> setMaxConcurrent ( 6 );
if ( audio_sched->notWorking() ) {
SG_LOG( SG_GENERAL, SG_ALERT, "Audio initialization failed!" );
} else {
audio_sched -> setMaxConcurrent ( 6 );
audio_mixer = new smMixer;
audio_mixer = new smMixer;
SG_LOG( SG_GENERAL, SG_INFO,
"Rate = " << audio_sched->getRate()
<< " Bps = " << audio_sched->getBps()
<< " Stereo = " << audio_sched->getStereo() );
SG_LOG( SG_GENERAL, SG_INFO,
"Rate = " << audio_sched->getRate()
<< " Bps = " << audio_sched->getBps()
<< " Stereo = " << audio_sched->getStereo() );
}
}
// destructor