1
0
Fork 0

Moved fov and win_ration from FGOptions to FGViewer so we can control these

on a per view basis.
Fixed some compile warnings in Main/*.cxx
This commit is contained in:
curt 2000-11-01 23:27:32 +00:00
parent f24b6a4098
commit 08fd9cc36d
13 changed files with 74 additions and 43 deletions

View file

@ -235,7 +235,7 @@ float get_frame_rate( void )
float get_fov( void )
{
float fov = globals->get_options()->get_fov();
float fov = globals->get_current_view()->get_fov();
return (fov);
}

View file

@ -45,7 +45,6 @@ bool
fgPanelVisible ()
{
return ((globals->get_options()->get_panel_status()) &&
(globals->get_options()->get_view_mode() == FGOptions::FG_VIEW_PILOT) &&
(globals->get_current_view()->get_view_offset() == 0.0));
}

View file

@ -20,7 +20,7 @@ NETWORK_LIBS = \
endif
if OLD_AUTOMAKE
CXXFLAGS += -DPKGLIBDIR=\"$(pkglibdir)\"
# nothing CXXFLAGS += -DPKGLIBDIR=\"$(pkglibdir)\"
else
AM_CXXFLAGS = -DPKGLIBDIR=\"$(pkglibdir)\"
endif

View file

@ -107,8 +107,8 @@ reinit ()
double apAltitude = FGBFI::getAPAltitude();
const string &targetAirport = FGBFI::getTargetAirport();
bool gpsLock = FGBFI::getGPSLock();
double gpsLatitude = FGBFI::getGPSTargetLatitude();
double gpsLongitude = FGBFI::getGPSTargetLongitude();
// double gpsLatitude = FGBFI::getGPSTargetLatitude();
// double gpsLongitude = FGBFI::getGPSTargetLongitude();
FGBFI::setTargetAirport("");
cout << "Target airport is " << globals->get_options()->get_airport_id() << endl;
@ -753,6 +753,8 @@ FGBFI::getEGT ()
{
if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
return current_aircraft.fdm_state->get_engine(0)->get_EGT();
} else {
return 0.0;
}
}
@ -765,6 +767,8 @@ FGBFI::getCHT ()
{
if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
return current_aircraft.fdm_state->get_engine(0)->get_CHT();
} else {
return 0.0;
}
}
@ -777,6 +781,8 @@ FGBFI::getMP ()
{
if ( current_aircraft.fdm_state->get_engine(0) != NULL ) {
return current_aircraft.fdm_state->get_engine(0)->get_Manifold_Pressure();
} else {
return 0.0;
}
}

View file

@ -221,7 +221,7 @@ bool fgSetPosFromAirportID( const string& id ) {
bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
FGRunway r;
FGRunway found_r;
double found_dir;
double found_dir = 0.0;
if ( id.length() ) {
// set initial position from runway and heading
@ -564,10 +564,12 @@ bool fgInitSubsystems( void ) {
&fgEVENT_MGR::PrintStats),
fgEVENT::FG_EVENT_READY, 60000 );
// Initialize win ratio parameters
globals->get_options()->set_win_ratio( globals->get_options()->get_xsize() /
globals->get_options()->get_ysize()
);
// Initialize win_ratio parameters
for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
globals->get_viewmgr()->get_view(i)->
set_win_ratio( globals->get_options()->get_xsize() /
globals->get_options()->get_ysize() );
}
// Initialize pilot view
FGViewerRPH *pilot_view =

View file

@ -213,12 +213,12 @@ void GLUTkey(unsigned char k, int x, int y) {
#endif
return;
case 88: // X key
fov = globals->get_options()->get_fov();
fov = globals->get_current_view()->get_fov();
fov *= 1.05;
if ( fov > FG_FOV_MAX ) {
fov = FG_FOV_MAX;
}
globals->get_options()->set_fov(fov);
globals->get_current_view()->set_fov(fov);
// v->force_update_fov_math();
return;
case 90: // Z key
@ -375,12 +375,12 @@ void GLUTkey(unsigned char k, int x, int y) {
globals->get_options()->get_ysize() );
return;
case 120: // x key
fov = globals->get_options()->get_fov();
fov = globals->get_current_view()->get_fov();
fov /= 1.05;
if ( fov < FG_FOV_MIN ) {
fov = FG_FOV_MIN;
}
globals->get_options()->set_fov(fov);
globals->get_current_view()->set_fov(fov);
// v->force_update_fov_math();
return;
case 122: // z key
@ -519,7 +519,7 @@ void GLUTspecialkey(int k, int x, int y) {
switch (k) {
case GLUT_KEY_F2: // F2 Reload Tile Cache...
{
bool freeze;
bool freeze = globals->get_freeze();
FG_LOG(FG_INPUT, FG_INFO, "ReIniting TileCache");
if ( !freeze )
globals->set_freeze( true );

View file

@ -387,6 +387,12 @@ void fgRenderFrame( void ) {
#endif
// update view port
fgReshape( globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
#if 0
// swing and a miss
if ( ! fgPanelVisible() ) {
xglViewport( 0, 0 ,
(GLint)(globals->get_options()->get_xsize()),
@ -401,6 +407,7 @@ void fgRenderFrame( void ) {
(GLint)(globals->get_options()->get_xsize()),
(GLint)(view_h) );
}
#endif
// set the sun position
glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
@ -554,8 +561,8 @@ void fgRenderFrame( void ) {
// glMatrixMode( GL_PROJECTION );
// glLoadIdentity();
float fov = globals->get_options()->get_fov();
ssgSetFOV(fov, fov * globals->get_options()->get_win_ratio());
float fov = globals->get_current_view()->get_fov();
ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
double agl = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER
- scenery.cur_elev;
@ -1165,16 +1172,27 @@ static void fgIdleFunction ( void ) {
// options.cxx needs to see this for toggle_panel()
// Handle new window size or exposure
void fgReshape( int width, int height ) {
// for all views
for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
if ( ! fgPanelVisible() || idle_state != 1000 ) {
globals->get_viewmgr()->get_view(i)->
set_win_ratio( (float)height / (float)width );
} else {
int view_h =
int((current_panel->getViewHeight() -
current_panel->getYOffset())
* (height / 768.0)) + 1;
globals->get_viewmgr()->get_view(i)->
set_win_ratio( (float)view_h / (float)width );
}
}
if ( ! fgPanelVisible() || idle_state != 1000 ) {
globals->get_options()->set_win_ratio( (float)height /
(float)width );
glViewport(0, 0 , (GLint)(width), (GLint)(height) );
} else {
int view_h =
int((current_panel->getViewHeight() - current_panel->getYOffset())
* (height / 768.0)) + 1;
globals->get_options()->set_win_ratio( (float)view_h /
(float)width );
int((current_panel->getViewHeight() - current_panel->getYOffset())
* (height / 768.0)) + 1;
glViewport(0, (GLint)(height - view_h),
(GLint)(width), (GLint)(view_h) );
}
@ -1182,8 +1200,8 @@ void fgReshape( int width, int height ) {
globals->get_options()->set_xsize( width );
globals->get_options()->set_ysize( height );
float fov = globals->get_options()->get_fov();
ssgSetFOV(fov, fov * globals->get_options()->get_win_ratio());
float fov = globals->get_current_view()->get_fov();
ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
fgHUDReshape();
}
@ -1545,8 +1563,8 @@ int main( int argc, char **argv ) {
sgMat4 tux_matrix;
float h_rot =
current_properties.getFloatValue("/sim/model/h-rotation", 0.0);
float p_rot =
current_properties.getFloatValue("/sim/model/p-rotation", 0.0);
/* float p_rot =
current_properties.getFloatValue("/sim/model/p-rotation", 0.0); */
float r_rot =
current_properties.getFloatValue("/sim/model/r-rotation", 0.0);
sgMakeRotMat4(tux_matrix, h_rot, h_rot, r_rot);

View file

@ -180,7 +180,6 @@ FGOptions::FGOptions() :
fog(FG_FOG_NICEST), // nicest
clouds(true),
clouds_asl(5000*FEET_TO_METER),
fov(55.0),
fullscreen(0),
shading(1),
skyblend(1),
@ -547,9 +546,11 @@ FGOptions::parse_fov( const string& arg ) {
if ( fov < FG_FOV_MIN ) { fov = FG_FOV_MIN; }
if ( fov > FG_FOV_MAX ) { fov = FG_FOV_MAX; }
globals->get_current_view()->set_fov( fov );
// printf("parse_fov(): result = %.4f\n", fov);
return(fov);
return fov;
}
@ -670,7 +671,6 @@ int FGOptions::parse_option( const string& arg ) {
current_properties.setBoolValue("/sim/panel/visibility", true);
if ( current_panel != NULL )
current_panel->setVisibility(true);
// fov *= 0.4232; /* NO!!! */
} else if ( arg == "--disable-sound" ) {
sound = false;
} else if ( arg == "--enable-sound" ) {
@ -798,7 +798,7 @@ int FGOptions::parse_option( const string& arg ) {
clouds_asl = atof( arg.substr(13) );
}
} else if ( arg.find( "--fov=" ) != string::npos ) {
fov = parse_fov( arg.substr(6) );
parse_fov( arg.substr(6) );
} else if ( arg == "--disable-fullscreen" ) {
fullscreen = false;
} else if ( arg== "--enable-fullscreen") {

View file

@ -56,8 +56,6 @@ FG_USING_STD(vector);
FG_USING_STD(string);
#define NEW_DEFAULT_MODEL_HZ 120
#define FG_FOV_MIN 0.1
#define FG_FOV_MAX 179.9
class FGOptions {
@ -186,14 +184,12 @@ private:
fgFogKind fog; // Fog nicest/fastest/disabled
bool clouds; // Enable clouds
double clouds_asl; // Cloud layer height above sea level
double fov; // Field of View
bool fullscreen; // Full screen mode enabled/disabled
int shading; // shading method, 0 = Flat, 1 = Smooth
bool skyblend; // Blend sky to haze (using polygons) or just clear
bool textures; // Textures enabled/disabled
bool wireframe; // Wireframe mode enabled/disabled
int xsize, ysize; // window size derived from geometry string
double win_ratio; // ratio of x and y fov's; fov(y) = fov(x) * win_ratio
int bpp; // bits per pixel
fgViewMode view_mode; // view mode
double default_view_offset; // default forward view offset (for use by
@ -296,7 +292,6 @@ public:
inline fgFogKind get_fog() const { return fog; }
inline bool get_clouds() const { return clouds; }
inline double get_clouds_asl() const { return clouds_asl; }
inline double get_fov() const { return fov; }
inline bool get_fullscreen() const { return fullscreen; }
inline int get_shading() const { return shading; }
inline bool get_skyblend() const { return skyblend; }
@ -304,7 +299,6 @@ public:
inline bool get_wireframe() const { return wireframe; }
inline int get_xsize() const { return xsize; }
inline int get_ysize() const { return ysize; }
inline double get_win_ratio() const { return win_ratio; }
inline int get_bpp() const { return bpp; }
inline fgViewMode get_view_mode() const { return view_mode; }
inline double get_default_view_offset() const {
@ -359,7 +353,6 @@ public:
inline void set_fog (fgFogKind value) { fog = value; }
inline void set_clouds( bool value ) { clouds = value; }
inline void set_clouds_asl( double value ) { clouds_asl = value; }
inline void set_fov( double amount ) { fov = amount; }
inline void set_fullscreen (bool value) { fullscreen = value; }
inline void set_shading (int value) { shading = value; }
inline void set_skyblend (bool value) { skyblend = value; }
@ -379,7 +372,6 @@ public:
void toggle_panel();
inline void set_xsize( int x ) { xsize = x; }
inline void set_ysize( int y ) { ysize = y; }
inline void set_win_ratio( double r ) { win_ratio = r; }
inline void set_view_mode (fgViewMode value) { view_mode = value; }
inline void set_tile_radius (int value) { tile_radius = value; }
inline void set_tile_diameter (int value) { tile_diameter = value; }

View file

@ -68,7 +68,7 @@ fgLoadFlight (istream &input)
// it would be better if FGFS just
// noticed the new lat/lon.
if (retval) {
bool freeze;
bool freeze = globals->get_freeze();
FG_LOG(FG_INPUT, FG_INFO, "ReIniting TileCache");
if ( !freeze )
globals->set_freeze( true );

View file

@ -34,7 +34,8 @@
// Constructor
FGViewer::FGViewer( void )
FGViewer::FGViewer( void ):
fov(55.0)
{
}

View file

@ -35,6 +35,10 @@
#include <plib/sg.h> // plib include
#define FG_FOV_MIN 0.1
#define FG_FOV_MAX 179.9
// Define a structure containing view information
class FGViewer {
@ -55,6 +59,12 @@ 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;
@ -115,6 +125,8 @@ public:
//////////////////////////////////////////////////////////////////////
// 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;
@ -150,6 +162,8 @@ public:
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 double get_goal_view_offset() const { return goal_view_offset; }
inline double *get_geod_view_pos() { return geod_view_pos; }

View file

@ -102,8 +102,7 @@ static void print_sgMat4( sgMat4 &in) {
// Update the view parameters
void FGViewerLookAt::update() {
Point3D tmp;
sgVec3 minus_z, forward;
sgMat4 VIEWo;
sgVec3 minus_z;
// calculate the cartesion coords of the current lat/lon/0 elev
Point3D p = Point3D( geod_view_pos[0],