int fgSolarSystemInit(fgTIME t)
{
- fgOPTIONS *o;
char path[256], gzpath[256];
int i, ret_val;
fgPrintf( FG_ASTRO, FG_INFO, "Initializing solar system\n");
/* build the full path name to the orbital elements database file */
- o = ¤t_options;
- path[0] = '\0';
- strcat(path, o->fg_root);
+ current_options.get_fg_root(path);
strcat(path, "/Scenery/");
strcat(path, "Planets");
/* $Log$
-/* Revision 1.6 1998/05/29 20:35:41 curt
-/* Added zlib support for reading in compressed data files.
+/* Revision 1.7 1998/07/13 21:00:09 curt
+/* Wrote access functions for current fgOPTIONS.
/*
+ * Revision 1.6 1998/05/29 20:35:41 curt
+ * Added zlib support for reading in compressed data files.
+ *
* Revision 1.5 1998/05/13 18:25:34 curt
* Root path info moved to fgOPTIONS.
*
/* Initialize the Star Management Subsystem */
int fgStarsInit( void ) {
fgFile fd;
- fgOPTIONS *o;
/* struct CelestialCoord pltPos; */
char path[256], gzpath[256];
char line[256], name[256];
fgPrintf( FG_ASTRO, FG_INFO, "Initializing stars\n");
- o = ¤t_options;
-
/* build the full path name to the stars data base file */
- path[0] = '\0';
- strcat(path, o->fg_root);
+ current_options.get_fg_root(path);
strcat(path, "/Scenery/");
strcat(path, "Stars");
/* $Log$
-/* Revision 1.7 1998/05/29 20:35:42 curt
-/* Added zlib support for reading in compressed data files.
+/* Revision 1.8 1998/07/13 21:00:10 curt
+/* Wrote access functions for current fgOPTIONS.
/*
+ * Revision 1.7 1998/05/29 20:35:42 curt
+ * Added zlib support for reading in compressed data files.
+ *
* Revision 1.6 1998/05/13 18:25:35 curt
* Root path info moved to fgOPTIONS.
*
void guiInit()
{
fgGENERAL *g;
- fgOPTIONS *o;
char *mesa_win_state;
g = &general;
- o = ¤t_options;
// Initialize PUI
puInit();
- if ( o->mouse_pointer == 0 ) {
+ if ( current_options.get_mouse_pointer() == 0 ) {
// no preference specified for mouse pointer, attempt to autodetect...
// Determine if we need to render the cursor, or if the windowing
// system will do it. First test if we are rendering with glide.
}
}
}
- } else if ( o->mouse_pointer == 1 ) {
+ } else if ( current_options.get_mouse_pointer() == 1 ) {
// don't show pointer
- } else if ( o->mouse_pointer == 2 ) {
+ } else if ( current_options.get_mouse_pointer() == 2 ) {
// force showing pointer
puShowCursor();
}
/* Handle keyboard events */
void GLUTkey(unsigned char k, int x, int y) {
fgCONTROLS *c;
- fgOPTIONS *o;
fgTIME *t;
fgVIEW *v;
struct fgWEATHER *w;
- float tmp;
+ float fov, tmp;
+ int status;
c = current_aircraft.controls;
- o = ¤t_options;
t = &cur_time_params;
v = ¤t_view;
w = ¤t_weather;
v->goal_view_offset = FG_PI * 1.75;
return;
case 72: /* H key */
- o->hud_status = !(o->hud_status);
+ status = current_options.get_hud_status();
+ current_options.set_hud_status(!status);
return;
case 77: /* M key */
t->warp -= 60;
#endif
return;
case 88: /* X key */
- o->fov *= 1.05;
- if ( o->fov > FG_FOV_MAX ) {
- o->fov = FG_FOV_MAX;
+ fov = current_options.get_fov();
+ fov *= 1.05;
+ if ( fov > FG_FOV_MAX ) {
+ fov = FG_FOV_MAX;
}
+ current_options.set_fov(fov);
v->update_fov = TRUE;
return;
case 90: /* Z key */
t->warp_delta += 30;
return;
case 120: /* X key */
- o->fov /= 1.05;
- if ( o->fov < FG_FOV_MIN ) {
- o->fov = FG_FOV_MIN;
+ fov = current_options.get_fov();
+ fov /= 1.05;
+ if ( fov < FG_FOV_MIN ) {
+ fov = FG_FOV_MIN;
}
+ current_options.set_fov(fov);
v->update_fov = TRUE;
return;
case 122: /* z key */
/* $Log$
-/* Revision 1.14 1998/07/06 02:42:02 curt
-/* Added support for switching between fullscreen and window mode for
-/* Mesa/3dfx/glide.
-/*
-/* Added a basic splash screen. Restructured the main loop and top level
-/* initialization routines to do this.
-/*
-/* Hacked in some support for playing a startup mp3 sound file while rest
-/* of sim initializes. Currently only works in Unix using the mpg123 player.
-/* Waits for the mpg123 player to finish before initializing internal
-/* sound drivers.
+/* Revision 1.15 1998/07/13 21:01:34 curt
+/* Wrote access functions for current fgOPTIONS.
/*
+ * Revision 1.14 1998/07/06 02:42:02 curt
+ * Added support for switching between fullscreen and window mode for
+ * Mesa/3dfx/glide.
+ *
+ * Added a basic splash screen. Restructured the main loop and top level
+ * initialization routines to do this.
+ *
+ * Hacked in some support for playing a startup mp3 sound file while rest
+ * of sim initializes. Currently only works in Unix using the mpg123 player.
+ * Waits for the mpg123 player to finish before initializing internal
+ * sound drivers.
+ *
* Revision 1.13 1998/06/27 16:54:32 curt
* Replaced "extern displayInstruments" with a entry in fgOPTIONS.
* Don't change the view port when displaying the panel.
// fgInitVisuals() -- Initialize various GL/view parameters
static void fgInitVisuals( void ) {
fgLIGHT *l;
- fgOPTIONS *o;
struct fgWEATHER *w;
l = &cur_light_params;
- o = ¤t_options;
w = ¤t_weather;
// Go full screen if requested ...
- if ( o->fullscreen ) {
+ if ( current_options.get_fullscreen() ) {
glutFullScreen();
}
xglFogi (GL_FOG_MODE, GL_EXP2);
// Fog density is now set when the weather system is initialized
// xglFogf (GL_FOG_DENSITY, w->fog_density);
- if ( (o->fog == 1) || (o->shading == 0) ) {
+ if ( (current_options.get_fog() == 1) ||
+ (current_options.get_shading() == 0) ) {
// if fastest fog requested, or if flat shading force fastest
xglHint (GL_FOG_HINT, GL_FASTEST );
- } else if ( o->fog == 2 ) {
+ } else if ( current_options.get_fog() == 2 ) {
xglHint (GL_FOG_HINT, GL_NICEST );
}
- if ( o->wireframe ) {
+ if ( current_options.get_wireframe() ) {
// draw wire frame
xglPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
}
static void fgUpdateViewParams( void ) {
fgFLIGHT *f;
fgLIGHT *l;
- fgOPTIONS *o;
fgVIEW *v;
f = current_aircraft.flight;
l = &cur_light_params;
- o = ¤t_options;
v = ¤t_view;
v->Update(f);
xglMatrixMode(GL_PROJECTION);
xglLoadIdentity();
if ( FG_Altitude * FEET_TO_METER - scenery.cur_elev > 10.0 ) {
- gluPerspective(o->fov, v->win_ratio, 10.0, 100000.0);
+ gluPerspective(current_options.get_fov(), v->win_ratio, 10.0, 100000.0);
} else {
- gluPerspective(o->fov, v->win_ratio, 1.0, 100000.0);
+ gluPerspective(current_options.get_fov(), v->win_ratio, 1.0, 100000.0);
// printf("Near ground, minimizing near clip plane\n");
}
// }
static void fgRenderFrame( void ) {
fgFLIGHT *f;
fgLIGHT *l;
- fgOPTIONS *o;
fgTIME *t;
fgVIEW *v;
double angle;
f = current_aircraft.flight;
l = &cur_light_params;
- o = ¤t_options;
t = &cur_time_params;
v = ¤t_view;
if ( idle_state != 1000 ) {
// still initializing, draw the splash screen
- if ( o->splash_screen == 1 ) {
+ if ( current_options.get_splash_screen() == 1 ) {
fgSplashUpdate(0.0);
}
} else {
fgUpdateViewParams();
clear_mask = GL_DEPTH_BUFFER_BIT;
- if ( o->wireframe ) {
+ if ( current_options.get_wireframe() ) {
clear_mask |= GL_COLOR_BUFFER_BIT;
}
- if ( o->skyblend ) {
+ if ( current_options.get_skyblend() ) {
glClearColor(black[0], black[1], black[2], black[3]);
} else {
glClearColor(l->sky_color[0], l->sky_color[1],
xglDisable( GL_CULL_FACE );
xglDisable( GL_FOG );
xglShadeModel( GL_SMOOTH );
- if ( o->skyblend ) {
+ if ( current_options.get_skyblend() ) {
fgSkyRender();
}
xglPopMatrix();
// draw scenery
- if ( o->shading ) {
+ if ( current_options.get_shading() ) {
xglShadeModel( GL_SMOOTH );
} else {
xglShadeModel( GL_FLAT );
}
xglEnable( GL_DEPTH_TEST );
- if ( o->fog > 0 ) {
+ if ( current_options.get_fog() > 0 ) {
xglEnable( GL_FOG );
xglFogfv (GL_FOG_COLOR, l->fog_color);
}
xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
- if ( o->textures ) {
+ if ( current_options.get_textures() ) {
// texture parameters
xglEnable( GL_TEXTURE_2D );
xglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) ;
static void fgIdleFunction ( void ) {
fgGENERAL *g;
- fgOPTIONS *o;
char path[256], mp3file[256], command[256], slfile[256];
static char *lockfile = "/tmp/mpg123.running";
g = &general;
- o = ¤t_options;
// printf("idle state == %d\n", idle_state);
if ( idle_state == 0 ) {
// Initialize the splash screen right away
- if ( o->splash_screen ) {
+ if ( current_options.get_splash_screen() ) {
fgSplashInit();
}
} else if ( idle_state == 1 ) {
// Start the intro music
#if !defined(WIN32)
- if ( o->intro_music ) {
- strcpy(mp3file, o->fg_root);
+ if ( current_options.get_intro_music() ) {
+ current_options.get_fg_root(mp3file);
strcat(mp3file, "/Sounds/");
strcat(mp3file, "intro.mp3");
sprintf(command,
#ifdef HAVE_AUDIO_SUPPORT
#if !defined(WIN32)
- if ( o->intro_music ) {
+ if ( current_options.get_intro_music() ) {
// Let's wait for mpg123 to finish
struct stat stat_buf;
audio_mixer = new smMixer;
audio_mixer -> setMasterVolume ( 30 ) ; /* 50% of max volume. */
audio_sched -> setSafetyMargin ( 1.0 ) ;
- strcpy(path, o->fg_root);
+ current_options.get_fg_root(path);
strcat(path, "/Sounds/");
strcpy(slfile, path);
fgMainLoop();
} else {
- if ( o->splash_screen == 1 ) {
+ if ( current_options.get_splash_screen() == 1 ) {
fgSplashUpdate(0.0);
}
}
// Main ...
int main( int argc, char **argv ) {
fgFLIGHT *f;
- fgOPTIONS *o;
char config[256];
int result; // Used in command line argument.
f = current_aircraft.flight;
- o = ¤t_options;
#ifdef HAVE_BC5PLUS
_control87(MCW_EM, MCW_EM); /* defined in float.h */
// Attempt to locate and parse a config file
// First check fg_root
- strcpy(config, o->fg_root);
+ current_options.get_fg_root(config);
strcat(config, "/system.fgfsrc");
- result = o->parse_config_file(config);
+ result = current_options.parse_config_file(config);
// Next check home directory
if ( getenv("HOME") != NULL ) {
strcpy(config, getenv("HOME"));
strcat(config, "/.fgfsrc");
- result = o->parse_config_file(config);
+ result = current_options.parse_config_file(config);
}
// Parse remaining command line options
// These will override anything specified in a config file
- result = o->parse_command_line(argc, argv);
+ result = current_options.parse_command_line(argc, argv);
if ( result != FG_OPTIONS_OK ) {
// Something must have gone horribly wrong with the command
// line parsing or maybe the user just requested help ... :-)
- o->usage();
+ current_options.usage();
fgPrintf( FG_GENERAL, FG_EXIT, "\nExiting ...\n");
}
// $Log$
+// Revision 1.35 1998/07/13 21:01:36 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.34 1998/07/13 15:32:37 curt
// Clear color buffer if drawing wireframe.
// When specifying and airport, start elevation at -1000 and let the system
// load the data
int fgAIRPORTS::load( char *file ) {
fgAIRPORT a;
- fgOPTIONS *o;
char path[256], fgpath[256], line[256];
char id[5];
string id_str;
fgFile f;
- o = ¤t_options;
-
// build the path name to the airport file
- strcpy(path, o->fg_root);
+ current_options.get_fg_root(path);
strcat(path, "/Scenery/");
strcat(path, "Airports");
strcpy(fgpath, path);
// $Log$
+// Revision 1.8 1998/07/13 21:01:37 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.7 1998/06/03 22:01:07 curt
// Tweaking sound library usage.
//
// Set initial position
int fgInitPosition( void ) {
+ char id[5];
fgFLIGHT *f;
- fgOPTIONS *o;
f = current_aircraft.flight;
- o = ¤t_options;
// If nothing else is specified, default initial position is
// Globe, AZ (P13)
FG_Longitude = ( -110.6642444 ) * DEG_TO_RAD;
FG_Latitude = ( 33.3528917 ) * DEG_TO_RAD;
- FG_Runway_altitude = (3234.5 + 300);
- FG_Altitude = FG_Runway_altitude + 3.758099;
+ FG_Runway_altitude = (3234.5);
+ FG_Altitude = -1000 /* FG_Runway_altitude + 3.758099 */;
// Initial Position north of the city of Globe
// FG_Longitude = ( -398673.28 / 3600.0 ) * DEG_TO_RAD;
// 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) ) {
+ current_options.get_airport_id(id);
+ if ( strlen(id) ) {
fgAIRPORTS airports;
fgAIRPORT a;
fgPrintf( FG_GENERAL, FG_INFO,
"Attempting to set starting position from airport code %s.\n",
- o->airport_id);
+ id);
airports.load("Airports");
- a = airports.search(o->airport_id);
+ a = airports.search(id);
if ( (fabs(a.longitude) < FG_EPSILON) &&
(fabs(a.latitude) < FG_EPSILON) &&
(fabs(a.elevation) < FG_EPSILON) ) {
fgPrintf( FG_GENERAL, FG_EXIT,
- "Failed to find %s in database.\n", o->airport_id);
+ "Failed to find %s in database.\n", id);
} else {
FG_Longitude = ( a.longitude ) * DEG_TO_RAD;
FG_Latitude = ( a.latitude ) * DEG_TO_RAD;
// General house keeping initializations
int fgInitGeneral( void ) {
fgGENERAL *g;
- fgOPTIONS *o;
+ char root[256];
int i;
g = &general;
- o = ¤t_options;
fgPrintf( FG_GENERAL, FG_INFO, "General Initialization\n" );
fgPrintf( FG_GENERAL, FG_INFO, "======= ==============\n" );
g->glRenderer = glGetString ( GL_RENDERER );
g->glVersion = glGetString ( GL_VERSION );
- if ( !strlen(o->fg_root) ) {
- // No root path set? Then assume, we will exit if this is
- // wrong when looking for support files.
+ current_options.get_fg_root(root);
+ if ( !strlen(root) ) {
+ // No root path set? Then bail ...
fgPrintf( FG_GENERAL, FG_EXIT, "%s %s\n",
"Cannot continue without environment variable FG_ROOT",
"being defined.");
}
- fgPrintf( FG_GENERAL, FG_INFO, "FG_ROOT = %s\n\n", o->fg_root);
+ fgPrintf( FG_GENERAL, FG_INFO, "FG_ROOT = %s\n\n", root);
// prime the frame rate counter pump
for ( i = 0; i < FG_FRAME_RATE_HISTORY; i++ ) {
// $Log$
+// Revision 1.25 1998/07/13 21:01:38 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.24 1998/07/13 15:32:39 curt
// Clear color buffer if drawing wireframe.
// When specifying and airport, start elevation at -1000 and let the system
}
+// Query functions
+void fgOPTIONS::get_fg_root(char *root) { strcpy(root, fg_root); }
+void fgOPTIONS::get_airport_id(char *id) { strcpy(id, airport_id); }
+int fgOPTIONS::get_splash_screen( void ) { return(splash_screen); }
+int fgOPTIONS::get_intro_music( void ) { return(intro_music); }
+int fgOPTIONS::get_mouse_pointer( void ) { return(mouse_pointer); }
+int fgOPTIONS::get_hud_status( void ) { return(hud_status); }
+int fgOPTIONS::get_panel_status( void ) { return(panel_status); }
+int fgOPTIONS::get_fog( void ) { return(fog); }
+double fgOPTIONS::get_fov( void ) { return(fov); }
+int fgOPTIONS::get_fullscreen( void ) { return(fullscreen); }
+int fgOPTIONS::get_shading( void ) { return(shading); }
+int fgOPTIONS::get_skyblend( void ) { return(skyblend); }
+int fgOPTIONS::get_textures( void ) { return(textures); }
+int fgOPTIONS::get_wireframe( void ) { return(wireframe); }
+int fgOPTIONS::get_tile_radius( void ) { return(tile_radius); }
+int fgOPTIONS::get_tile_diameter( void ) { return(tile_diameter); }
+int fgOPTIONS::get_time_offset( void ) { return(time_offset); }
+
+
+// Update functions
+void fgOPTIONS::set_hud_status( int status ) { hud_status = status; }
+void fgOPTIONS::set_fov( double amount ) { fov = amount; }
+
// Destructor
fgOPTIONS::~fgOPTIONS( void ) {
}
// $Log$
+// Revision 1.16 1998/07/13 21:01:39 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.15 1998/07/06 21:34:19 curt
// Added an enable/disable splash screen option.
// Added an enable/disable intro music option.
class fgOPTIONS {
-public:
// The flight gear "root" directory
char fg_root[256];
// Time options
int time_offset; // Offset true time by this many seconds
+public:
+
// Constructor
fgOPTIONS( void );
// Print usage message
void usage ( void );
+ // Query functions
+ void get_fg_root(char *root);
+ void get_airport_id(char *id);
+ int get_splash_screen( void );
+ int get_intro_music( void );
+ int get_mouse_pointer( void );
+ int get_hud_status( void );
+ int get_panel_status( void );
+ int get_fog( void );
+ double get_fov( void );
+ int get_fullscreen( void );
+ int get_shading( void );
+ int get_skyblend( void );
+ int get_textures( void );
+ int get_wireframe( void );
+ int get_tile_radius( void );
+ int get_tile_diameter( void );
+ int get_time_offset( void );
+
+ // Update functions
+ void set_hud_status( int status );
+ void set_fov( double amount );
+
// Destructor
~fgOPTIONS( void );
// $Log$
+// Revision 1.11 1998/07/13 21:01:39 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.10 1998/07/06 21:34:20 curt
// Added an enable/disable splash screen option.
// Added an enable/disable intro music option.
// Initialize the splash screen
void fgSplashInit ( void ) {
- fgOPTIONS *o;
char tpath[256], fg_tpath[256];
int width, height;
- o = ¤t_options;
-
fgPrintf( FG_GENERAL, FG_INFO, "Initializing splash screen\n");
#ifdef GL_VERSION_1_1
xglGenTextures(1, &splash_texid);
xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// load in the texture data
- tpath[0] = '\0';
- strcat(tpath, o->fg_root);
+ current_options.get_fg_root(tpath);
strcat(tpath, "/Textures/");
strcat(tpath, "Splash2.rgb");
// $Log$
+// Revision 1.2 1998/07/13 21:01:40 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.1 1998/07/06 02:42:36 curt
// Initial revision.
//
// Update the field of view parameters
void fgVIEW::UpdateFOV( fgOPTIONS *o ) {
- double theta_x, theta_y;
+ double fov, theta_x, theta_y;
+
+ fov = o->get_fov();
// printf("win_ratio = %.2f\n", win_ratio);
// calculate sin() and cos() of fov / 2 in X direction;
- theta_x = (o->fov * win_ratio * DEG_TO_RAD) / 2.0;
+ theta_x = (fov * win_ratio * DEG_TO_RAD) / 2.0;
// printf("theta_x = %.2f\n", theta_x);
sin_fov_x = sin(theta_x);
cos_fov_x = cos(theta_x);
// printf("slope_x = %.2f\n", slope_x);
// calculate sin() and cos() of fov / 2 in Y direction;
- theta_y = (o->fov * DEG_TO_RAD) / 2.0;
+ theta_y = (fov * DEG_TO_RAD) / 2.0;
// printf("theta_y = %.2f\n", theta_y);
sin_fov_y = sin(theta_y);
cos_fov_y = cos(theta_y);
// Update the view parameters
void fgVIEW::Update( fgFLIGHT *f ) {
- fgOPTIONS *o;
fgPoint3d p;
MAT3vec vec, forward, v0, minus_z;
MAT3mat R, TMP, UP, LOCAL, VIEW;
double ntmp;
- o = ¤t_options;
-
if(update_fov == TRUE) {
// printf("Updating fov\n");
- UpdateFOV(o);
+ UpdateFOV(¤t_options);
update_fov = FALSE;
}
// $Log$
+// Revision 1.16 1998/07/13 21:01:41 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.15 1998/07/12 03:14:43 curt
// Added ground collision detection.
// Did some serious horsing around to be able to "hug" the ground properly
// Load a library of material properties
int fgMATERIAL_MGR::load_lib ( void ) {
fgMATERIAL m;
- fgOPTIONS *o;
char material_name[256];
char mpath[256], fg_mpath[256], tpath[256], fg_tpath[256];
char line[256], *line_ptr, value[256];
int width, height;
int alpha;
- o = ¤t_options;
-
// build the path name to the material db
- mpath[0] = '\0';
- strcat(mpath, o->fg_root);
+ current_options.get_fg_root(mpath);
strcat(mpath, "/Scenery/");
strcat(mpath, "Materials");
strcpy(fg_mpath, mpath);
GL_LINEAR_MIPMAP_LINEAR ) ;
/* load in the texture data */
- tpath[0] = '\0';
- strcat(tpath, o->fg_root);
+ current_options.get_fg_root(tpath);
strcat(tpath, "/Textures/");
strcat(tpath, m.texture_name);
strcat(tpath, ".rgb");
// $Log$
+// Revision 1.9 1998/07/13 21:01:57 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.8 1998/07/08 14:47:20 curt
// Fix GL_MODULATE vs. GL_DECAL problem introduced by splash screen.
// polare3d.h renamed to polar3d.hxx
// Load a .obj file and build the GL fragment list
int fgObjLoad(char *path, fgTILE *t) {
- fgOPTIONS *o;
fgFRAGMENT fragment;
fgPoint3d pp;
char fgpath[256], line[256], material[256];
// GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 };
GLint display_list;
fgFile f;
+ int shading;
int in_fragment, in_faces, vncount, n1, n2, n3, n4;
int last1, last2, odd;
- o = ¤t_options;
-
// First try "path.gz" (compressed format)
strcpy(fgpath, path);
strcat(fgpath, ".gz");
}
}
+ shading = current_options.get_shading();
+
in_fragment = 0;
t->ncount = 1;
vncount = 1;
odd = 1;
scale = 1.0;
- if ( o->shading ) {
+ if ( shading ) {
// Shading model is "GL_SMOOTH" so use precalculated
// (averaged) normals
MAT3_SCALE_VEC(normal, normals[n1], scale);
if ( n4 > 0 ) {
fragment.add_face(n3, n2, n4);
- if ( o->shading ) {
+ if ( shading ) {
// Shading model is "GL_SMOOTH"
MAT3_SCALE_VEC(normal, normals[n4], scale);
} else {
fragment.add_face(last2, last1, n1);
}
- if ( o->shading ) {
+ if ( shading ) {
// Shading model is "GL_SMOOTH"
MAT3_SCALE_VEC(normal, normals[n1], scale);
xglNormal3dv(normal);
fragment.add_face(last2, last1, n2);
}
- if ( o->shading ) {
+ if ( shading ) {
// Shading model is "GL_SMOOTH"
MAT3_SCALE_VEC(normal, normals[n2], scale);
xglNormal3dv(normal);
// $Log$
+// Revision 1.19 1998/07/13 21:01:58 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.18 1998/07/12 03:18:27 curt
// Added ground collision detection. This involved:
// - saving the entire vertex list for each tile with the tile records.
/* Tell the scenery manager where we are so it can load the proper data, and
* build the proper structures. */
void fgSceneryUpdate(double lon, double lat, double elev) {
- fgOPTIONS *o;
- // double max_radius;
- char path[1024];
-
- o = ¤t_options;
-
- /* a hardcoded hack follows */
-
- /* this routine should parse the file, and make calls back to the
- * scenery management system to build the appropriate structures */
- path[0] = '\0';
- strcat(path, o->fg_root);
- strcat(path, "/Scenery/");
- strcat(path, "mesa-e.obj");
-
- // fgPrintf(FG_TERRAIN, FG_DEBUG, " Loading Scenery: %s\n", path);
-
- // area_terrain = fgObjLoad(path, &scenery.center, &max_radius);
+ // does nothing;
}
/* $Log$
-/* Revision 1.6 1998/07/12 03:18:27 curt
-/* Added ground collision detection. This involved:
-/* - saving the entire vertex list for each tile with the tile records.
-/* - saving the face list for each fragment with the fragment records.
-/* - code to intersect the current vertical line with the proper face in
-/* an efficient manner as possible.
-/* Fixed a bug where the tiles weren't being shifted to "near" (0,0,0)
+/* Revision 1.7 1998/07/13 21:01:59 curt
+/* Wrote access functions for current fgOPTIONS.
/*
+ * Revision 1.6 1998/07/12 03:18:27 curt
+ * Added ground collision detection. This involved:
+ * - saving the entire vertex list for each tile with the tile records.
+ * - saving the face list for each fragment with the fragment records.
+ * - code to intersect the current vertical line with the proper face in
+ * an efficient manner as possible.
+ * Fixed a bug where the tiles weren't being shifted to "near" (0,0,0)
+ *
* Revision 1.5 1998/06/17 21:36:41 curt
* Load and manage multiple textures defined in the Materials library.
* Boost max material fagments for each material property to 800.
// Fill in a tile cache entry with real data for the specified bucket
void fgTILECACHE::EntryFillIn( int index, fgBUCKET *p ) {
- fgOPTIONS *o;
+ char root[256];
char base_path[256];
char file_name[256];
- o = ¤t_options;
-
// Mark this cache entry as used
tile_cache[index].used = 1;
// Load the appropriate data file and built tile fragment list
fgBucketGenBasePath(p, base_path);
- sprintf(file_name, "%s/Scenery/%s/%ld", o->fg_root,
+ current_options.get_fg_root(root);
+ sprintf(file_name, "%s/Scenery/%s/%ld", root,
base_path, fgBucketGenIndex(p));
fgObjLoad(file_name, &tile_cache[index]);
/*
// $Log$
+// Revision 1.13 1998/07/13 21:02:00 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.12 1998/07/12 03:18:29 curt
// Added ground collision detection. This involved:
// - saving the entire vertex list for each tile with the tile records.
int fgTileMgrUpdate( void ) {
fgTILECACHE *c;
fgFLIGHT *f;
- fgOPTIONS *o;
fgBUCKET p1, p2;
static fgBUCKET p_last = {-1000, 0, 0, 0};
+ int tile_diameter;
int i, j, dw, dh;
c = &global_tile_cache;
f = current_aircraft.flight;
- o = ¤t_options;
+
+ tile_diameter = current_options.get_tile_diameter();
fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p1);
- dw = o->tile_diameter / 2;
- dh = o->tile_diameter / 2;
+ dw = tile_diameter / 2;
+ dh = tile_diameter / 2;
if ( (p1.lon == p_last.lon) && (p1.lat == p_last.lat) &&
(p1.x == p_last.x) && (p1.y == p_last.y) ) {
fgPrintf( FG_TERRAIN, FG_INFO, " Updating Tile list for %d,%d %d,%d\n",
p1.lon, p1.lat, p1.x, p1.y);
fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
- o->tile_diameter * o->tile_diameter);
+ tile_diameter * tile_diameter);
// wipe/initialize tile cache
c->Init();
// build the local area list and update cache
- for ( j = 0; j < o->tile_diameter; j++ ) {
- for ( i = 0; i < o->tile_diameter; i++ ) {
+ for ( j = 0; j < tile_diameter; j++ ) {
+ for ( i = 0; i < tile_diameter; i++ ) {
fgBucketOffset(&p1, &p2, i - dw, j - dh);
- fgTileMgrLoadTile(&p2, &tiles[(j*o->tile_diameter) + i]);
+ fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) + i]);
}
}
} else {
if ( (p1.lon > p_last.lon) ||
( (p1.lon == p_last.lon) && (p1.x > p_last.x) ) ) {
fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
- o->tile_diameter);
- for ( j = 0; j < o->tile_diameter; j++ ) {
+ tile_diameter);
+ for ( j = 0; j < tile_diameter; j++ ) {
// scrolling East
- for ( i = 0; i < o->tile_diameter - 1; i++ ) {
- tiles[(j*o->tile_diameter) + i] =
- tiles[(j*o->tile_diameter) + i + 1];
+ for ( i = 0; i < tile_diameter - 1; i++ ) {
+ tiles[(j*tile_diameter) + i] =
+ tiles[(j*tile_diameter) + i + 1];
}
// load in new column
fgBucketOffset(&p_last, &p2, dw + 1, j - dh);
- fgTileMgrLoadTile(&p2, &tiles[(j*o->tile_diameter) +
- o->tile_diameter - 1]);
+ fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) +
+ tile_diameter - 1]);
}
} else if ( (p1.lon < p_last.lon) ||
( (p1.lon == p_last.lon) && (p1.x < p_last.x) ) ) {
fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
- o->tile_diameter);
- for ( j = 0; j < o->tile_diameter; j++ ) {
+ tile_diameter);
+ for ( j = 0; j < tile_diameter; j++ ) {
// scrolling West
- for ( i = o->tile_diameter - 1; i > 0; i-- ) {
- tiles[(j*o->tile_diameter) + i] =
- tiles[(j*o->tile_diameter) + i - 1];
+ for ( i = tile_diameter - 1; i > 0; i-- ) {
+ tiles[(j*tile_diameter) + i] =
+ tiles[(j*tile_diameter) + i - 1];
}
// load in new column
fgBucketOffset(&p_last, &p2, -dw - 1, j - dh);
- fgTileMgrLoadTile(&p2, &tiles[(j*o->tile_diameter) + 0]);
+ fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) + 0]);
}
}
if ( (p1.lat > p_last.lat) ||
( (p1.lat == p_last.lat) && (p1.y > p_last.y) ) ) {
fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
- o->tile_diameter);
- for ( i = 0; i < o->tile_diameter; i++ ) {
+ tile_diameter);
+ for ( i = 0; i < tile_diameter; i++ ) {
// scrolling North
- for ( j = 0; j < o->tile_diameter - 1; j++ ) {
- tiles[(j * o->tile_diameter) + i] =
- tiles[((j+1) * o->tile_diameter) + i];
+ for ( j = 0; j < tile_diameter - 1; j++ ) {
+ tiles[(j * tile_diameter) + i] =
+ tiles[((j+1) * tile_diameter) + i];
}
// load in new column
fgBucketOffset(&p_last, &p2, i - dw, dh + 1);
- fgTileMgrLoadTile(&p2, &tiles[((o->tile_diameter-1) *
- o->tile_diameter) + i]);
+ fgTileMgrLoadTile(&p2, &tiles[((tile_diameter-1) *
+ tile_diameter) + i]);
}
} else if ( (p1.lat < p_last.lat) ||
( (p1.lat == p_last.lat) && (p1.y < p_last.y) ) ) {
fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
- o->tile_diameter);
- for ( i = 0; i < o->tile_diameter; i++ ) {
+ tile_diameter);
+ for ( i = 0; i < tile_diameter; i++ ) {
// scrolling South
- for ( j = o->tile_diameter - 1; j > 0; j-- ) {
- tiles[(j * o->tile_diameter) + i] =
- tiles[((j-1) * o->tile_diameter) + i];
+ for ( j = tile_diameter - 1; j > 0; j-- ) {
+ tiles[(j * tile_diameter) + i] =
+ tiles[((j-1) * tile_diameter) + i];
}
// load in new column
fgBucketOffset(&p_last, &p2, i - dw, -dh - 1);
void fgTileMgrRender( void ) {
fgTILECACHE *c;
fgFLIGHT *f;
- fgOPTIONS *o;
fgTILE *t, *last_tile_ptr;
fgVIEW *v;
fgBUCKET p;
list < fgFRAGMENT > :: iterator current;
list < fgFRAGMENT > :: iterator last;
int i, j, size;
+ int tile_diameter, textures;
int index;
int culled = 0;
int drawn = 0;
c = &global_tile_cache;
f = current_aircraft.flight;
- o = ¤t_options;
v = ¤t_view;
+ tile_diameter = current_options.get_tile_diameter();
+ textures = current_options.get_textures();
+
// Find current translation offset
fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p);
index = c->Exists(&p);
// Pass 1
// traverse the potentially viewable tile list
- for ( i = 0; i < (o->tile_diameter * o->tile_diameter); i++ ) {
+ for ( i = 0; i < (tile_diameter * tile_diameter); i++ ) {
index = tiles[i];
// fgPrintf( FG_TERRAIN, FG_DEBUG, "Index = %d\n", index);
t = c->GetTile(index);
size = mtl_ptr->list_size;
if ( size > 0 ) {
- if ( o->textures ) {
+ if ( textures ) {
#ifdef GL_VERSION_1_1
xglBindTexture(GL_TEXTURE_2D, mtl_ptr->texture_id);
#elif GL_EXT_texture_object
// $Log$
+// Revision 1.25 1998/07/13 21:02:01 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.24 1998/07/12 03:18:29 curt
// Added ground collision detection. This involved:
// - saving the entire vertex list for each tile with the tile records.
#include <deque> // STL double ended queue
#include <list> // STL list
+#ifdef NEEDNAMESPACESTD
+using namespace std;
+#endif
#include "fg_time.hxx"
// $Log$
+// Revision 1.5 1998/07/13 21:02:07 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.4 1998/06/12 00:59:52 curt
// Build only static libraries.
// Declare memmove/memset for Sloaris.
// Initialize the time dependent variables
void fgTimeInit(fgTIME *t) {
- fgOPTIONS *o;
-
- o = ¤t_options;
-
fgPrintf( FG_EVENT, FG_INFO, "Initializing Time\n");
t->gst_diff = -9999.0;
- fgPrintf( FG_EVENT, FG_DEBUG, "o->time_offset = %d\n", o->time_offset);
- t->warp = o->time_offset;
+ fgPrintf( FG_EVENT, FG_DEBUG, "time offset = %d\n",
+ current_options.get_time_offset() );
+
+ t->warp = current_options.get_time_offset();
t->warp_delta = 0;
}
// $Log$
+// Revision 1.10 1998/07/13 21:02:07 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.9 1998/06/12 00:59:53 curt
// Build only static libraries.
// Declare memmove/memset for Sloaris.
// initialize lighting tables
void fgLIGHT::Init( void ) {
- fgOPTIONS *o;
char path[256];
fgPrintf( FG_EVENT, FG_INFO,
"Initializing Lighting interpolation tables.\n" );
- o = ¤t_options;
-
// build the path name to the ambient lookup table
- path[0] = '\0';
- strcat(path, o->fg_root);
+ current_options.get_fg_root(path);
strcat(path, "/Scenery/");
strcat(path, "Ambient");
// initialize ambient table
ambient_tbl = new fgINTERPTABLE(path);
// build the path name to the diffuse lookup table
- path[0] = '\0';
- strcat(path, o->fg_root);
+ current_options.get_fg_root(path);
strcat(path, "/Scenery/");
strcat(path, "Diffuse");
// initialize diffuse table
diffuse_tbl = new fgINTERPTABLE(path);
// build the path name to the sky lookup table
- path[0] = '\0';
- strcat(path, o->fg_root);
+ current_options.get_fg_root(path);
strcat(path, "/Scenery/");
strcat(path, "Sky");
// initialize sky table
// $Log$
+// Revision 1.11 1998/07/13 21:02:08 curt
+// Wrote access functions for current fgOPTIONS.
+//
// Revision 1.10 1998/07/08 14:48:38 curt
// polar3d.h renamed to polar3d.hxx
//