#include <simgear/misc/interpolator.hxx>
#include <simgear/io/HTTPRequest.hxx>
-#include <Cockpit/panel.hxx>
-#include <Cockpit/panel_io.hxx>
#include <FDM/flight.hxx>
#include <GUI/gui.h>
#include <GUI/new_gui.hxx>
#include <Sound/sample_queue.hxx>
#include <Airports/xmlloader.hxx>
#include <Network/HTTPClient.hxx>
+#include <Viewer/viewmgr.hxx>
+#include <Viewer/viewer.hxx>
+#include <Environment/presets.hxx>
#include "fg_init.hxx"
#include "fg_io.hxx"
#include "globals.hxx"
#include "logger.hxx"
#include "util.hxx"
-#include "viewmgr.hxx"
#include "main.hxx"
-#include <Main/viewer.hxx>
-#include <Environment/presets.hxx>
+#include "positioninit.hxx"
#include <boost/scoped_array.hpp>
static bool
do_panel_load (const SGPropertyNode * arg)
{
- string panel_path =
- arg->getStringValue("path", fgGetString("/sim/panel/path"));
- if (panel_path.empty()) {
- return false;
+ string panel_path = arg->getStringValue("path");
+ if (!panel_path.empty()) {
+ // write to the standard property, which will force a load
+ fgSetString("/sim/panel/path", panel_path.c_str());
}
- FGPanel * new_panel = fgReadPanel(panel_path);
- if (new_panel == 0) {
- SG_LOG(SG_INPUT, SG_ALERT,
- "Error reading new panel from " << panel_path);
- return false;
- }
- SG_LOG(SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path);
- globals->get_current_panel()->unbind();
- globals->set_current_panel( new_panel );
- globals->get_current_panel()->bind();
return true;
}
-
-/**
- * Built-in command: pass a mouse click to the panel.
- *
- * button: the mouse button number, zero-based.
- * is-down: true if the button is down, false if it is up.
- * x-pos: the x position of the mouse click.
- * y-pos: the y position of the mouse click.
- */
-static bool
-do_panel_mouse_click (const SGPropertyNode * arg)
-{
- if (globals->get_current_panel() != 0)
- return globals->get_current_panel()
- ->doMouseAction(arg->getIntValue("button"),
- arg->getBoolValue("is-down") ? PU_DOWN : PU_UP,
- arg->getIntValue("x-pos"),
- arg->getIntValue("y-pos"));
- else
- return false;
-}
-
-
/**
* Built-in command: (re)load preferences.
*
return true;
}
+/**
+ * Reload the materials definition
+ */
+ static bool
+ do_materials_reload (const SGPropertyNode * arg)
+ {
+ SG_LOG(SG_INPUT, SG_INFO, "Reloading Materials");
+ SGMaterialLib* new_matlib = new SGMaterialLib;
+ SGPath mpath( globals->get_fg_root() );
+ mpath.append( fgGetString("/sim/rendering/materials-file") );
+ bool loaded = new_matlib->load(globals->get_fg_root(),
+ mpath.str(),
+ globals->get_props());
+
+ if ( ! loaded ) {
+ SG_LOG( SG_GENERAL, SG_ALERT,
+ "Error loading materials file " << mpath.str() );
+ return false;
+ }
+
+ globals->set_matlib(new_matlib);
+ return true;
+ }
+
#if 0
These do_set_(some-environment-parameters) are deprecated and no longer
/**
* Built-in command: interpolate a property value over time
*
- * property: the name of the property value to interpolate.
- * value[0..n] any number of constant values to interpolate
- * time[0..n] time between each value, number of time elements must
- * match those of value elements
+ * property: the name of the property value to interpolate.
+ * value[0..n] any number of constant values to interpolate
+ * time/rate[0..n] time between each value, number of time elements must
+ * match those of value elements. Instead of time also rate can
+ * be used which automatically calculates the time to change
+ * the property value at the given speed.
* -or-
- * property[1..n] any number of target values taken from named properties
- * time[0..n] time between each value, number of time elements must
- * match those of property elements minus one
+ * property[1..n] any number of target values taken from named properties
+ * time/rate[0..n] time between each value, number of time elements must
+ * match those of value elements. Instead of time also rate can
+ * be used which automatically calculates the time to change
+ * the property value at the given speed.
*/
static bool
do_property_interpolate (const SGPropertyNode * arg)
simgear::PropertyList valueNodes = arg->getChildren( "value" );
simgear::PropertyList timeNodes = arg->getChildren( "time" );
+ simgear::PropertyList rateNodes = arg->getChildren( "rate" );
+
+ if( !timeNodes.empty() && !rateNodes.empty() )
+ // mustn't specify time and rate
+ return false;
+
+ simgear::PropertyList::size_type num_times = timeNodes.empty()
+ ? rateNodes.size()
+ : timeNodes.size();
boost::scoped_array<double> value;
boost::scoped_array<double> time;
if( valueNodes.size() > 0 ) {
// must match
- if( timeNodes.size() != valueNodes.size() )
+ if( num_times != valueNodes.size() )
return false;
value.reset( new double[valueNodes.size()] );
} else {
valueNodes = arg->getChildren("property");
// must have one more property node
- if( valueNodes.size() - 1 != timeNodes.size() )
+ if( valueNodes.size() - 1 != num_times )
return false;
value.reset( new double[valueNodes.size()-1] );
}
- time.reset( new double[timeNodes.size()] );
- for( simgear::PropertyList::size_type n = 0; n < timeNodes.size(); n++ ) {
- time[n] = timeNodes[n]->getDoubleValue();
+ time.reset( new double[num_times] );
+ if( !timeNodes.empty() ) {
+ for( simgear::PropertyList::size_type n = 0; n < num_times; n++ ) {
+ time[n] = timeNodes[n]->getDoubleValue();
+ }
+ } else {
+ for( simgear::PropertyList::size_type n = 0; n < num_times; n++ ) {
+ double delta = value[n]
+ - (n > 0 ? value[n - 1] : prop->getDoubleValue());
+ time[n] = fabs(delta / rateNodes[n]->getDoubleValue());
+ }
}
((SGInterpolator*)globals->get_subsystem_mgr()
->get_group(SGSubsystemMgr::INIT)->get_subsystem("interpolator"))
- ->interpolate(prop, timeNodes.size(), value.get(), time.get() );
+ ->interpolate(prop, num_times, value.get(), time.get() );
return true;
}
// Nasal can trigger this during initial init, which confuses
// the logic in ReInitSubsystems, since initial state has not been
// saved at that time. Short-circuit everything here.
- fgInitPosition();
+ flightgear::initPosition();
}
return true;
{ "load", do_load },
{ "save", do_save },
{ "panel-load", do_panel_load },
- { "panel-mouse-click", do_panel_mouse_click },
{ "preferences-load", do_preferences_load },
{ "view-cycle", do_view_cycle },
{ "screen-capture", do_screen_capture },
{ "dump-terrainbranch", do_dump_terrain_branch },
{ "print-visible-scene", do_print_visible_scene_info },
{ "reload-shaders", do_reload_shaders },
+ { "reload-materials", do_materials_reload },
{ 0, 0 } // zero-terminated
};