init_gear();
// Set initial fuel levels if provided.
- for (int i = 0; i < Propulsion->GetNumTanks(); i++) {
+ for (unsigned int i = 0; i < Propulsion->GetNumTanks(); i++) {
SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
if (node->getChild("level-gal_us", 0, false) != 0)
Propulsion->GetTank(i)
int i;
- double save_alt = 0.0;
+ // double save_alt = 0.0;
copy_to_JSBsim();
// Convert from the FGInterface struct to the JSBsim generic_ struct
bool FGJSBsim::copy_to_JSBsim() {
- int i;
+ unsigned int i;
// copy control positions into the JSBsim structure
node->setBoolValue("cranking", eng->GetCranking());
}
- // Copy the fuel levels from JSBSim.
- for (i = 0; i < Propulsion->GetNumTanks(); i++) {
- SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
- double contents = Propulsion->GetTank(i)->GetContents();
- node->setDoubleValue("level-gal_us", contents/6.6);
-// node->setDoubleValue("level-lb", contents);
+ static const SGPropertyNode *fuel_freeze
+ = fgGetNode("/sim/freeze/fuel");
+
+ // Copy the fuel levels from JSBSim if fuel
+ // freeze not enabled.
+ if ( ! fuel_freeze->getBoolValue() ) {
+ for (i = 0; i < Propulsion->GetNumTanks(); i++) {
+ SGPropertyNode * node
+ = fgGetNode("/consumables/fuel/tank", i, true);
+ double contents = Propulsion->GetTank(i)->GetContents();
+ node->setDoubleValue("level-gal_us", contents/6.6);
+ // node->setDoubleValue("level-lb", contents);
+ }
}
update_gear();
fgSetDouble("/engines/engine/running", eng.getRunningFlag());
fgSetDouble("/engines/engine/cranking", eng.getCrankingFlag());
- //Assume we are using both tanks equally for now
- fgSetDouble("/consumables/fuel/tank[0]/level-gal_us",
- fgGetDouble("/consumables/fuel/tank[0]")
- - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
- * get_delta_t());
- fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
- fgGetDouble("/consumables/fuel/tank[1]")
- - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
- * get_delta_t());
+ static const SGPropertyNode *fuel_freeze
+ = fgGetNode("/sim/freeze/fuel");
+
+ if ( ! fuel_freeze->getBoolValue() ) {
+ //Assume we are using both tanks equally for now
+ fgSetDouble("/consumables/fuel/tank[0]/level-gal_us",
+ fgGetDouble("/consumables/fuel/tank[0]")
+ - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
+ * get_delta_t());
+ fgSetDouble("/consumables/fuel/tank[1]/level-gal_us",
+ fgGetDouble("/consumables/fuel/tank[1]")
+ - (eng.get_fuel_flow_gals_hr() / (2 * 3600))
+ * get_delta_t());
+ }
F_X_engine = eng.get_prop_thrust_lbs();
// cout << "F_X_engine = " << F_X_engine << '\n';
= fgGetNode("/position/longitude-deg");
static const SGPropertyNode *latitude
= fgGetNode("/position/latitude-deg");
+ static const SGPropertyNode *master_freeze
+ = fgGetNode("/sim/freeze/master");
SGPath path( globals->get_fg_root() );
path.append( "Airports" );
FGAirport a;
- int freeze = globals->get_freeze();
- if(!freeze)
- globals->set_freeze( true );
+ bool freeze = master_freeze->getBoolValue();
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", true);
+ }
char *s;
AptDialogInput->getValue(&s);
SGD_RADIANS_TO_DEGREES);
// BusyCursor(0);
fgReInitSubsystems();
- // if ( global_tile_mgr.init() ) {
- // Load the local scenery data
global_tile_mgr.update( longitude->getDoubleValue(),
latitude->getDoubleValue() );
- // } else {
- // SG_LOG( SG_GENERAL, SG_ALERT,
- // "Error in Tile Manager initialization!" );
- // exit(-1);
- // }
// BusyCursor(1);
} else {
AptId += " not in database.";
}
}
if ( !freeze ) {
- globals->set_freeze( false );
+ fgSetBool("/sim/freeze/master", false);
}
}
char *filename = new char [24];
static int count = 1;
- int freeze = globals->get_freeze();
- if(!freeze)
- globals->set_freeze( true );
+ static const SGPropertyNode *master_freeze
+ = fgGetNode("/sim/freeze/master");
+
+ bool freeze = master_freeze->getBoolValue();
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", true);
+ }
if(gui_menu_on) {
show_menu = true;
puShowCursor();
}
- if(!freeze)
- globals->set_freeze( false );
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", false);
+ }
}
#endif // #if defined( TR_HIRES_SNAP)
string message;
static int count = 1;
- int freeze = globals->get_freeze();
- if(!freeze)
- globals->set_freeze( true );
+ static const SGPropertyNode *master_freeze
+ = fgGetNode("/sim/freeze/master");
+
+ bool freeze = master_freeze->getBoolValue();
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", true);
+ }
mainMenuBar->hide();
TurnCursorOff();
mainMenuBar->reveal();
}
- if(!freeze)
- globals->set_freeze( false );
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", false);
+ }
}
#ifdef FG_NETWORK_OLK
// BusyCursor(0);
Quat0();
- int freeze = globals->get_freeze();
- if(!freeze)
- globals->set_freeze( true );
+ static const SGPropertyNode *master_freeze
+ = fgGetNode("/sim/freeze/master");
+
+ bool freeze = master_freeze->getBoolValue();
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", true);
+ }
cur_fdm_state->unbind();
// BusyCursor(1);
if ( !freeze ) {
- globals->set_freeze( false );
+ fgSetBool("/sim/freeze/master", false);
}
}
void NetIdDialog_OK (puObject *)
{
- string NetId;
+ string NetId;
+
+ static const SGPropertyNode *master_freeze
+ = fgGetNode("/sim/freeze/master");
+
+ bool freeze = master_freeze->getBoolValue();
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", true);
+ }
- bool freeze = globals->get_freeze();
- if(!freeze)
- globals->set_freeze( true );
/*
The following needs some cleanup because
"string options.NetId" and "char *net_callsign"
*/
- NetIdDialogInput->getValue(&net_callsign);
- NetId = net_callsign;
+ NetIdDialogInput->getValue(&net_callsign);
+ NetId = net_callsign;
- NetIdDialog_Cancel( NULL );
- fgSetString("/networking/call-sign", NetId.c_str() );
- strcpy( fgd_callsign, net_callsign);
+ NetIdDialog_Cancel( NULL );
+ fgSetString("/networking/call-sign", NetId.c_str() );
+ strcpy( fgd_callsign, net_callsign);
// strcpy( fgd_callsign, fgGetString("/sim/networking/call-sign").c_str());
/* Entering a callsign indicates : user wants Net HUD Info */
- net_hud_display = 1;
+ net_hud_display = 1;
- if(!freeze)
- globals->set_freeze( false );
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", false);
+ }
}
void NewCallSign(puObject *cb)
void NetFGDDialog_OK (puObject *)
{
- char *NetFGD;
-
- bool freeze = globals->get_freeze();
- if(!freeze)
- globals->set_freeze( true );
- NetFGDHostDialogInput->getValue( &NetFGD );
- strcpy( fgd_host, NetFGD);
- NetFGDPortLoDialogInput->getValue( (int *) &base_port );
- NetFGDPortHiDialogInput->getValue( (int *) &end_port );
- NetFGDDialog_Cancel( NULL );
- if(!freeze)
- globals->set_freeze( false );
+ char *NetFGD;
+
+ static const SGPropertyNode *master_freeze
+ = fgGetNode("/sim/freeze/master");
+
+ bool freeze = master_freeze->getBoolValue();
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", true);
+ }
+
+ NetFGDHostDialogInput->getValue( &NetFGD );
+ strcpy( fgd_host, NetFGD);
+ NetFGDPortLoDialogInput->getValue( (int *) &base_port );
+ NetFGDPortHiDialogInput->getValue( (int *) &end_port );
+ NetFGDDialog_Cancel( NULL );
+
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", false);
+ }
}
void NetFGDDialog_SCAN (puObject *)
{
- char *NetFGD;
- int fgd_port;
+ char *NetFGD;
+ int fgd_port;
+
+ static const SGPropertyNode *master_freeze
+ = fgGetNode("/sim/freeze/master");
+
+ bool freeze = master_freeze->getBoolValue();
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", true);
+ }
- bool freeze = globals->get_freeze();
- if(!freeze)
- globals->set_freeze( true );
// printf("Vor getvalue %s\n");
- NetFGDHostDialogInput->getValue( &NetFGD );
+ NetFGDHostDialogInput->getValue( &NetFGD );
// printf("Vor strcpy %s\n", (char *) NetFGD);
- strcpy( fgd_host, NetFGD);
- NetFGDPortLoDialogInput->getValue( (int *) &base_port );
- NetFGDPortHiDialogInput->getValue( (int *) &end_port );
- printf("FGD: %s Port-Start: %d Port-End: %d\n", fgd_host,
- base_port, end_port);
- net_resolv_fgd(fgd_host);
- printf("Resolve : %d\n", net_r);
- if(!freeze)
- globals->set_freeze( false );
- if ( net_r == 0 ) {
- fgd_port = 10000;
- strcpy( fgd_name, "");
- for( current_port = base_port; ( current_port <= end_port); current_port++) {
- fgd_send_com("0" , FGFS_host);
- sprintf( NewNetFGDLabel , "Scanning for deamon Port: %d", current_port);
- printf("FGD: searching %s\n", fgd_name);
- if ( strcmp( fgd_name, "") != 0 ) {
- sprintf( NewNetFGDLabel , "Found %s at Port: %d",
- fgd_name, current_port);
- fgd_port = current_port;
- current_port = end_port+1;
- }
- }
- current_port = end_port = base_port = fgd_port;
+ strcpy( fgd_host, NetFGD);
+ NetFGDPortLoDialogInput->getValue( (int *) &base_port );
+ NetFGDPortHiDialogInput->getValue( (int *) &end_port );
+ printf("FGD: %s Port-Start: %d Port-End: %d\n", fgd_host,
+ base_port, end_port);
+ net_resolv_fgd(fgd_host);
+ printf("Resolve : %d\n", net_r);
+
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", false);
+ }
+
+ if ( net_r == 0 ) {
+ fgd_port = 10000;
+ strcpy( fgd_name, "");
+ for( current_port = base_port; ( current_port <= end_port); current_port++) {
+ fgd_send_com("0" , FGFS_host);
+ sprintf( NewNetFGDLabel , "Scanning for deamon Port: %d", current_port);
+ printf("FGD: searching %s\n", fgd_name);
+ if ( strcmp( fgd_name, "") != 0 ) {
+ sprintf( NewNetFGDLabel , "Found %s at Port: %d",
+ fgd_name, current_port);
+ fgd_port = current_port;
+ current_port = end_port+1;
+ }
}
- NetFGDDialog_Cancel( NULL );
+ current_port = end_port = base_port = fgd_port;
+ }
+ NetFGDDialog_Cancel( NULL );
}
static bool
do_tile_cache_reload (const SGPropertyNode * arg, SGCommandState ** state)
{
- bool freeze = globals->get_freeze();
- SG_LOG(SG_INPUT, SG_INFO, "ReIniting TileCache");
- if ( !freeze )
- globals->set_freeze( true );
- // BusyCursor(0);
- if ( global_tile_mgr.init() ) {
- // Load the local scenery data
- global_tile_mgr.update(fgGetDouble("/position/longitude-deg"),
- fgGetDouble("/position/latitude-deg"));
- } else {
- SG_LOG( SG_GENERAL, SG_ALERT,
- "Error in Tile Manager initialization!" );
- exit(-1);
- }
- // BusyCursor(1);
- if ( !freeze )
- globals->set_freeze( false );
- return true;
+ static const SGPropertyNode *master_freeze
+ = fgGetNode("/sim/freeze/master");
+ bool freeze = master_freeze->getBoolValue();
+ SG_LOG(SG_INPUT, SG_INFO, "ReIniting TileCache");
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", true);
+ }
+ // BusyCursor(0);
+ if ( global_tile_mgr.init() ) {
+ // Load the local scenery data
+ global_tile_mgr.update(fgGetDouble("/position/longitude-deg"),
+ fgGetDouble("/position/latitude-deg"));
+ } else {
+ SG_LOG( SG_GENERAL, SG_ALERT,
+ "Error in Tile Manager initialization!" );
+ exit(-1);
+ }
+ // BusyCursor(1);
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", false);
+ }
+ return true;
}
= fgGetNode("/position/latitude-deg");
static const SGPropertyNode *altitude
= fgGetNode("/position/altitude-ft");
+ static const SGPropertyNode *master_freeze
+ = fgGetNode("/sim/freeze/master");
SG_LOG( SG_GENERAL, SG_INFO,
"/position/altitude = " << altitude->getDoubleValue() );
- bool freeze = globals->get_freeze();
- if( !freeze ) {
- globals->set_freeze( true );
+ bool freeze = master_freeze->getBoolValue();
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", true);
}
// Initialize the Scenery Management subsystem
cur_light_params.Update();
fgUpdateLocalTime();
- if( !freeze )
- globals->set_freeze( false );
+ if ( !freeze ) {
+ fgSetBool("/sim/freeze/master", false);
+ }
}
}
+#if 0
/**
* Get the pause state of the sim.
*/
current_atcdisplay->CancelRepeatingMessage();
}
}
+#endif
/**
* Return the current aircraft directory (UIUC) as a string.
// Simulation
fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority);
fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses);
- fgTie("/sim/freeze", getFreeze, setFreeze);
+ // fgTie("/sim/freeze", getFreeze, setFreeze);
fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
fgTie("/sim/view/offset-deg", getViewOffset, setViewOffset, false);
fgSetArchivable("/sim/view/offset-deg");
// Constructor
FGGlobals::FGGlobals() :
- freeze( false ),
#if defined(FX) && defined(XMESA)
fullscreen( true ),
#endif
// Root of FlightGear scenery tree
string fg_scenery;
+#if 0
// Freeze sim
bool freeze;
+#endif
// Fullscreen mode for old 3DFX cards.
#if defined(FX) && defined(XMESA)
fg_scenery = scenery;
}
+#if 0
inline bool get_freeze() const { return freeze; }
inline void set_freeze( bool f ) { freeze = f; }
+#endif
#if defined(FX) && defined(XMESA)
inline bool get_fullscreen() const { return fullscreen; }
// Update internal time dependent calculations (i.e. flight model)
void fgUpdateTimeDepCalcs() {
static bool inited = false;
+ static const SGPropertyNode *master_freeze
+ = fgGetNode("/sim/freeze/master");
// cout << "Updating time dep calcs()" << endl;
// instance ...
if ( !cur_fdm_state->get_inited() ) {
// do nothing, fdm isn't inited yet
- } else if ( globals->get_freeze() ) {
+ } else if ( master_freeze->getBoolValue() ) {
// we are frozen, run the fdm's with 0 time slices in case
// they want to do something with that.
glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, -0.5 ) ;
#endif
-#if 0
-#ifdef GL_EXT_texture_filter_anisotropic
- float max_anisotropy;
- glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,
- max_anisotropy );
- cout << "Max anisotropy = " << max_anisotropy << endl;
-#endif
-#endif
-
// set current_options lon/lat if an airport id is specified
// cout << "3. airport_id = " << fgGetString("/sim/startup/airport-id") << endl;
if ( fgGetString("/sim/startup/airport-id").length() ) {
fgSetBool("/sim/networking/network-olk", false);
fgSetString("/sim/networking/call-sign", "Johnny");
+
+ // Freeze options
+ fgSetBool("/sim/freeze/master", false);
+ fgSetBool("/sim/freeze/position", false);
+ fgSetBool("/sim/freeze/fuel", false);
+ fgSetBool("/sim/freeze/time-of-day", false);
}
} else if ( arg == "--enable-mouse-pointer" ) {
fgSetString("/sim/startup/mouse-pointer", "enabled");
} else if ( arg == "--disable-freeze" ) {
- fgSetBool("/sim/freeze", false);
+ fgSetBool("/sim/freeze/master", false);
} else if ( arg == "--enable-freeze" ) {
- fgSetBool("/sim/freeze", true);
+ fgSetBool("/sim/freeze/master", true);
} else if ( arg == "--disable-anti-alias-hud" ) {
fgSetBool("/sim/hud/antialiased", false);
} else if ( arg == "--enable-anti-alias-hud" ) {
textured->enable( GL_TEXTURE_2D );
textured->disable( GL_BLEND );
textured->disable( GL_ALPHA_TEST );
+#if 0
+# ifdef GL_EXT_texture_filter_anisotropic
+ float max_anisotropy;
+ glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy );
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,
+ max_anisotropy );
+ cout << "Max anisotropy = " << max_anisotropy << endl;
+# endif
+#endif
if ( !defer_tex_load ) {
textured->setTexture( (char *)texture_path.c_str(), wrapu, wrapv );
texture_loaded = true;
}
+// Set up lights rendering call backs
+static int fgLightsPredraw( ssgEntity *e ) {
+#ifdef GL_EXT_point_parameters
+ if (glutExtensionSupported("GL_EXT_point_parameters")) {
+ static float quadratic[3] = {1.0, 0.01, 0.0001};
+ glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, quadratic);
+ glPointParameterfEXT(GL_POINT_SIZE_MIN_EXT, 1.0);
+ glPointSize(4.0);
+ }
+#endif
+ return true;
+}
+
+static int fgLightsPostdraw( ssgEntity *e ) {
+#ifdef GL_EXT_point_parameters
+ if (glutExtensionSupported("GL_EXT_point_parameters")) {
+ static float default_attenuation[3] = {1.0, 0.0, 0.0};
+ glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT,
+ default_attenuation);
+ glPointSize(1.0);
+ }
+#endif
+ return true;
+}
+
+
ssgLeaf* FGTileEntry::gen_lights( ssgVertexArray *lights, int inc, float bright ) {
// generate a repeatable random seed
float *p1 = lights->get( 0 );
// assign state
FGNewMat *newmat = material_lib.find( "LIGHTS" );
leaf->setState( newmat->get_state() );
+ leaf->setCallback( SSG_CALLBACK_PREDRAW, fgLightsPredraw );
+ leaf->setCallback( SSG_CALLBACK_POSTDRAW, fgLightsPostdraw );
return leaf;
}