From a2972051a9cf8347249b989e96270506d5f921ea Mon Sep 17 00:00:00 2001 From: Anders Gidenstam Date: Fri, 2 Sep 2011 20:26:55 +0200 Subject: [PATCH] Added an --materials-file option to select the materials file to use at startup. The property /sim/rendering/materials-file can also be used for this purpose. --- src/Main/fg_init.cxx | 5 +++-- src/Main/fgviewer.cxx | 5 +++-- src/Main/options.cxx | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index c28c9d98e..25fe5a6f7 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -1362,10 +1362,11 @@ bool fgInitSubsystems() { //////////////////////////////////////////////////////////////////// SGPath mpath( globals->get_fg_root() ); - mpath.append( "materials.xml" ); + mpath.append( fgGetString("/sim/rendering/materials-file") ); if ( ! globals->get_matlib()->load(globals->get_fg_root(), mpath.str(), globals->get_props()) ) { - SG_LOG( SG_GENERAL, SG_ALERT, "Error loading material lib!" ); + SG_LOG( SG_GENERAL, SG_ALERT, + "Error loading materials file " << mpath.str() ); exit(-1); } diff --git a/src/Main/fgviewer.cxx b/src/Main/fgviewer.cxx index 656836805..2f11aa66b 100644 --- a/src/Main/fgviewer.cxx +++ b/src/Main/fgviewer.cxx @@ -209,10 +209,11 @@ fgviewerMain(int argc, char** argv) // Initialize the material property subsystem. SGPath mpath( globals->get_fg_root() ); - mpath.append( "materials.xml" ); + mpath.append( fgGetString("/sim/rendering/materials-file") ); if ( ! globals->get_matlib()->load(globals->get_fg_root(), mpath.str(), globals->get_props()) ) { - SG_LOG( SG_GENERAL, SG_ALERT, "Error loading material lib!" ); + SG_LOG( SG_GENERAL, SG_ALERT, + "Error loading materials file " << mpath.str() ); exit(-1); } diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 472a4b742..172d133ea 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -215,6 +215,7 @@ fgSetDefaults () fgSetBool("/sim/rendering/enhanced-lighting", false); fgSetBool("/sim/rendering/distance-attenuation", false); fgSetBool("/sim/rendering/specular-highlight", true); + fgSetString("/sim/rendering/materials-file", "materials.xml"); fgSetInt("/sim/startup/xsize", 800); fgSetInt("/sim/startup/ysize", 600); fgSetInt("/sim/rendering/bits-per-pixel", 16); @@ -1407,6 +1408,7 @@ struct OptionDesc { {"texture-filtering", false, OPTION_INT, "/sim/rendering/filtering", 1, "", 0 }, {"disable-wireframe", false, OPTION_BOOL, "/sim/rendering/wireframe", false, "", 0 }, {"enable-wireframe", false, OPTION_BOOL, "/sim/rendering/wireframe", true, "", 0 }, + {"materials-file", true, OPTION_STRING, "/sim/rendering/materials-file", false, "", 0 }, {"disable-terrasync", false, OPTION_BOOL, "/sim/terrasync/enabled", false, "", 0 }, {"enable-terrasync", false, OPTION_BOOL, "/sim/terrasync/enabled", true, "", 0 }, {"terrasync-dir", true, OPTION_STRING, "/sim/terrasync/scenery-dir", false, "", 0 },