diff --git a/Main/GLUTmain.cxx b/Main/GLUTmain.cxx index 1a896331f..097ff62de 100644 --- a/Main/GLUTmain.cxx +++ b/Main/GLUTmain.cxx @@ -72,10 +72,6 @@ // This is a record containing global housekeeping information fgGENERAL general; -// view parameters -static GLfloat win_ratio = 1.0; -static GLint winWidth, winHeight; - // Another hack int use_signals = 0; @@ -233,21 +229,22 @@ static void fgUpdateViewParams( void ) { o = ¤t_options; v = ¤t_view; - fgViewUpdate(f, v, l); + v->Update(f); + v->UpdateWorldToEye(f); if (displayInstruments) { - xglViewport( 0, (GLint)(winHeight / 2 ) , - (GLint)winWidth, (GLint)winHeight / 2 ); + xglViewport( 0, (GLint)((v->winHeight) / 2 ) , + (GLint)(v->winWidth), (GLint)(v->winHeight) / 2 ); // Tell GL we are about to modify the projection parameters xglMatrixMode(GL_PROJECTION); xglLoadIdentity(); - gluPerspective(o->fov, 2.0/win_ratio, 1.0, 100000.0); + gluPerspective(o->fov, v->win_ratio / 2.0, 1.0, 100000.0); } else { - xglViewport(0, 0 , (GLint)winWidth, (GLint) winHeight); + xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) ); // Tell GL we are about to modify the projection parameters xglMatrixMode(GL_PROJECTION); xglLoadIdentity(); - gluPerspective(o->fov, 1.0/win_ratio, 10.0, 100000.0); + gluPerspective(o->fov, v->win_ratio, 10.0, 100000.0); } xglMatrixMode(GL_MODELVIEW); @@ -288,7 +285,11 @@ static void fgUpdateViewParams( void ) { // Draw a basic instrument panel static void fgUpdateInstrViewParams( void ) { - xglViewport(0, 0 , (GLint)winWidth, (GLint)winHeight / 2); + fgVIEW *v; + + v = ¤t_view; + + xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) / 2); xglMatrixMode(GL_PROJECTION); xglPushMatrix(); @@ -618,14 +619,18 @@ static void fgMainLoop( void ) { // Handle new window size or exposure static void fgReshape( int width, int height ) { + fgVIEW *v; + + v = ¤t_view; + // Do this so we can call fgReshape(0,0) ourselves without having // to know what the values of width & height are. if ( (height > 0) && (width > 0) ) { - win_ratio = (GLfloat) height / (GLfloat) width; + v->win_ratio = (GLfloat) width / (GLfloat) height; } - winWidth = width; - winHeight = height; + v->winWidth = width; + v->winHeight = height; // Inform gl of our view window size (now handled elsewhere) // xglViewport(0, 0, (GLint)width, (GLint)height); @@ -768,6 +773,14 @@ extern "C" { // $Log$ +// Revision 1.15 1998/05/16 13:08:34 curt +// C++ - ified views.[ch]xx +// Shuffled some additional view parameters into the fgVIEW class. +// Changed tile-radius to tile-diameter because it is a much better +// name. +// Added a WORLD_TO_EYE transformation to views.cxx. This allows us +// to transform world space to eye space for view frustum culling. +// // Revision 1.14 1998/05/13 18:29:57 curt // Added a keyboard binding to dynamically adjust field of view. // Added a command line option to specify fov. diff --git a/Main/Makefile.am b/Main/Makefile.am index 08cc5d65b..2497c22c0 100644 --- a/Main/Makefile.am +++ b/Main/Makefile.am @@ -1,6 +1,6 @@ EXTRA_DIST = runfg.in runfg.bat.in -bin_PROGRAMS = fg +bin_PROGRAMS = fg ttest bin_SCRIPTS = runfg runfg.bat @@ -31,6 +31,10 @@ fg_LDADD = \ $(top_builddir)/Lib/Debug/libDebug.la \ $(top_builddir)/Lib/zlib/libz.la +ttest_SOURCES = ttest.cxx + +ttest_LDADD = $(top_builddir)/Lib/Math/libMath.la \ + INCLUDES += \ -DGLUT \ -I$(top_builddir) \ diff --git a/Main/Makefile.in b/Main/Makefile.in index 64171d5f9..07339a381 100644 --- a/Main/Makefile.in +++ b/Main/Makefile.in @@ -73,7 +73,7 @@ VERSION = @VERSION@ EXTRA_DIST = runfg.in runfg.bat.in -bin_PROGRAMS = fg +bin_PROGRAMS = fg ttest bin_SCRIPTS = runfg runfg.bat @@ -103,6 +103,8 @@ fg_LDADD = \ $(top_builddir)/Lib/Bucket/libBucket.la \ $(top_builddir)/Lib/Debug/libDebug.la \ $(top_builddir)/Lib/zlib/libz.la + +ttest_SOURCES = ttest.cxx mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../../Include/config.h CONFIG_CLEAN_FILES = runfg runfg.bat @@ -135,6 +137,10 @@ $(top_builddir)/Lib/Math/libMath.la \ $(top_builddir)/Lib/Bucket/libBucket.la \ $(top_builddir)/Lib/Debug/libDebug.la $(top_builddir)/Lib/zlib/libz.la fg_LDFLAGS = +ttest_OBJECTS = ttest.o +ttest_LDADD = $(LDADD) +ttest_DEPENDENCIES = +ttest_LDFLAGS = SCRIPTS = $(bin_SCRIPTS) CXXFLAGS = @CXXFLAGS@ @@ -149,10 +155,10 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP = --best DEP_FILES = .deps/GLUTkey.P .deps/GLUTmain.P .deps/airports.P \ -.deps/fg_init.P .deps/options.P .deps/views.P +.deps/fg_init.P .deps/options.P .deps/ttest.P .deps/views.P CXXMKDEP = $(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS) -SOURCES = $(fg_SOURCES) -OBJECTS = $(fg_OBJECTS) +SOURCES = $(fg_SOURCES) $(ttest_SOURCES) +OBJECTS = $(fg_OBJECTS) $(ttest_OBJECTS) all: Makefile $(PROGRAMS) $(SCRIPTS) @@ -231,6 +237,10 @@ fg: $(fg_OBJECTS) $(fg_DEPENDENCIES) @rm -f fg $(CXXLINK) $(fg_LDFLAGS) $(fg_OBJECTS) $(fg_LDADD) $(LIBS) +ttest: $(ttest_OBJECTS) $(ttest_DEPENDENCIES) + @rm -f ttest + $(CXXLINK) $(ttest_LDFLAGS) $(ttest_OBJECTS) $(ttest_LDADD) $(LIBS) + install-binSCRIPTS: $(bin_SCRIPTS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(bindir) diff --git a/Main/fg_init.cxx b/Main/fg_init.cxx index 133689ef7..ba9429073 100644 --- a/Main/fg_init.cxx +++ b/Main/fg_init.cxx @@ -133,8 +133,8 @@ int fgInitPosition( void ) { // Test Position // FG_Longitude = ( 8.5 ) * DEG_TO_RAD; // FG_Latitude = ( 47.5 ) * DEG_TO_RAD; - // FG_Runway_altitude = ( 6000 ); - // FG_Altitude = FG_Runway_altitude + 3.758099; + FG_Runway_altitude = ( 6000 ); + FG_Altitude = FG_Runway_altitude + 3.758099; if ( strlen(o->airport_id) ) { fgAIRPORTS airports; @@ -271,9 +271,9 @@ int fgInitSubsystems( void ) { fgTimeUpdate(f, t); // Initialize view parameters - // ----> - fgViewInit(v); - fgViewUpdate(f, v, l); + v->Init(); + v->Update(f); + v->UpdateWorldToEye(f); // Initialize the orbital elements of sun, moon and mayor planets fgSolarSystemInit(*t); @@ -297,11 +297,9 @@ int fgInitSubsystems( void ) { // fgUpdateSunPos() needs a few position and view parameters set // so it can calculate local relative sun angle and a few other // things for correctly orienting the sky. - // ----> fgUpdateSunPos(); // Initialize Lighting interpolation tables - // ----> fgLightInit(); // update the lighting parameters (based on sun angle) @@ -323,7 +321,6 @@ int fgInitSubsystems( void ) { } // Initialize the "sky" - // ----> fgSkyInit(); // Initialize the Scenery Management subsystem @@ -384,6 +381,14 @@ int fgInitSubsystems( void ) { // $Log$ +// Revision 1.13 1998/05/16 13:08:35 curt +// C++ - ified views.[ch]xx +// Shuffled some additional view parameters into the fgVIEW class. +// Changed tile-radius to tile-diameter because it is a much better +// name. +// Added a WORLD_TO_EYE transformation to views.cxx. This allows us +// to transform world space to eye space for view frustum culling. +// // Revision 1.12 1998/05/13 18:29:58 curt // Added a keyboard binding to dynamically adjust field of view. // Added a command line option to specify fov. diff --git a/Main/options.cxx b/Main/options.cxx index 61eaf96f8..838838623 100644 --- a/Main/options.cxx +++ b/Main/options.cxx @@ -33,6 +33,7 @@ #include #include +#include #include #include "options.hxx" @@ -79,7 +80,7 @@ fgOPTIONS::fgOPTIONS( void ) { wireframe = 0; // Scenery options - tile_radius = 7; + tile_diameter = 7; // Time options time_offset = 0; @@ -229,22 +230,16 @@ static int parse_time_offset(char *time_str) { } -// Parse --tile-radius=n type option +// Parse --tile-diameter=n type option -#define FG_RADIUS_MIN 3 -#define FG_RADIUS_MAX 9 +#define FG_RADIUS_MIN 1 +#define FG_RADIUS_MAX 4 static int parse_tile_radius(char *arg) { int radius, tmp; radius = parse_int(arg); - // radius must be odd - tmp = radius / 2; - if ( radius == ( tmp * 2 ) ) { - radius -= 1; - } - if ( radius < FG_RADIUS_MIN ) { radius = FG_RADIUS_MIN; } if ( radius > FG_RADIUS_MAX ) { radius = FG_RADIUS_MAX; } @@ -255,10 +250,6 @@ static int parse_tile_radius(char *arg) { // Parse --fov=x.xx type option - -#define FG_FOV_MIN 0.1 -#define FG_FOV_MAX 179.9 - static double parse_fov(char *arg) { double fov; @@ -318,6 +309,7 @@ int fgOPTIONS::parse_option( char *arg ) { wireframe = 1; } else if ( strncmp(arg, "--tile-radius=", 14) == 0 ) { tile_radius = parse_tile_radius(arg); + tile_diameter = tile_radius * 2 + 1; } else if ( strncmp(arg, "--time-offset=", 14) == 0 ) { time_offset = parse_time_offset(arg); } else { @@ -424,7 +416,7 @@ void fgOPTIONS::usage ( void ) { printf("\n"); printf("Scenery Options:\n"); - printf("\t--tile-radius=n: specify tile radius, must be odd 3, 5, or 7\n"); + printf("\t--tile-radius=n: specify tile radius, must be 1 - 4\n"); printf("\n"); printf("Time Options:\n"); @@ -438,6 +430,14 @@ fgOPTIONS::~fgOPTIONS( void ) { // $Log$ +// Revision 1.10 1998/05/16 13:08:36 curt +// C++ - ified views.[ch]xx +// Shuffled some additional view parameters into the fgVIEW class. +// Changed tile-radius to tile-diameter because it is a much better +// name. +// Added a WORLD_TO_EYE transformation to views.cxx. This allows us +// to transform world space to eye space for view frustum culling. +// // Revision 1.9 1998/05/13 18:29:59 curt // Added a keyboard binding to dynamically adjust field of view. // Added a command line option to specify fov. diff --git a/Main/options.hxx b/Main/options.hxx index 1ed98a66b..dc88b418c 100644 --- a/Main/options.hxx +++ b/Main/options.hxx @@ -59,8 +59,10 @@ public: int wireframe; // Wireframe mode enabled/disabled // Scenery options - int tile_radius; // Square radius of rendered tiles. for instance - // if tile_radius = 3 then a 3 x 3 grid of tiles will + int tile_radius; // Square radius of rendered tiles (around center + // square.) + int tile_diameter; // Diameter of rendered tiles. for instance + // if tile_diameter = 3 then a 3 x 3 grid of tiles will // be drawn. Increase this to see terrain that is // further away. @@ -95,6 +97,14 @@ extern fgOPTIONS current_options; // $Log$ +// Revision 1.8 1998/05/16 13:08:36 curt +// C++ - ified views.[ch]xx +// Shuffled some additional view parameters into the fgVIEW class. +// Changed tile-radius to tile-diameter because it is a much better +// name. +// Added a WORLD_TO_EYE transformation to views.cxx. This allows us +// to transform world space to eye space for view frustum culling. +// // Revision 1.7 1998/05/13 18:29:59 curt // Added a keyboard binding to dynamically adjust field of view. // Added a command line option to specify fov. diff --git a/Main/views.cxx b/Main/views.cxx index 8952347d9..d9ac0d6e6 100644 --- a/Main/views.cxx +++ b/Main/views.cxx @@ -1,5 +1,5 @@ -// -// views.cxx -- data structures and routines for managing and view parameters. +// views.cxx -- data structures and routines for managing and view +// parameters. // // Written by Curtis Olson, started August 1997. // @@ -23,7 +23,6 @@ // (Log is kept at end of this file) - #ifdef HAVE_CONFIG_H # include #endif @@ -37,6 +36,7 @@ #include #include