]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/fgviewer.cxx
NavDisplay: fix update lag when switching range or centre.
[flightgear.git] / src / Main / fgviewer.cxx
index 3ab9570b5536e2abddf714d777f9dca31a743092..99bdd8e65319fac1a692fdd6c8437a0d530b2e00 100644 (file)
@@ -1,3 +1,7 @@
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include <iostream>
 #include <cstdlib>
 
@@ -21,7 +25,7 @@
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/scene/material/EffectCullVisitor.hxx>
 #include <simgear/scene/material/matlib.hxx>
-#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/scene/tgdb/userdata.hxx>
 #include <simgear/scene/tgdb/TileEntry.hxx>
 #include <simgear/scene/model/ModelRegistry.hxx>
@@ -68,8 +72,6 @@ static void dumpOut(osg::Node* node)
     char filename[24];
     static int count = 1;
 
-    FGRenderer *renderer = globals->get_renderer();
-
     while (count < 1000) {
         FILE *fp;
         snprintf(filename, 24, "fgviewer-%03d.osg", count++);
@@ -102,6 +104,7 @@ bool GraphDumpHandler::handle(const osgGA::GUIEventAdapter& ea,
     default:
         return false;
     }
+    return false;
 }
 
 void GraphDumpHandler::getUsage(osg::ApplicationUsage& usage) const
@@ -146,15 +149,14 @@ fgviewerMain(int argc, char** argv)
     osgGA::KeySwitchMatrixManipulator* keyswitchManipulator;
     keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
 
-    osgGA::MatrixManipulator* mm = new osgGA::TrackballManipulator;
-    keyswitchManipulator->addMatrixManipulator('1', "Trackball", mm);
-    mm = new osgGA::FlightManipulator;
-    keyswitchManipulator->addMatrixManipulator('2', "Flight", mm);
-    mm = new osgGA::DriveManipulator;
-    keyswitchManipulator->addMatrixManipulator('3', "Drive", mm);
-    mm = new osgGA::TerrainManipulator;
-    keyswitchManipulator->addMatrixManipulator('4', "Terrain", mm);
-
+    keyswitchManipulator->addMatrixManipulator('1', "Trackball",
+                                               new osgGA::TrackballManipulator);
+    keyswitchManipulator->addMatrixManipulator('2', "Flight",
+                                               new osgGA::FlightManipulator);
+    keyswitchManipulator->addMatrixManipulator('3', "Drive",
+                                               new osgGA::DriveManipulator);
+    keyswitchManipulator->addMatrixManipulator('4', "Terrain",
+                                               new osgGA::TerrainManipulator);
     viewer.setCameraManipulator(keyswitchManipulator);
 
     // Usefull stats
@@ -186,7 +188,6 @@ fgviewerMain(int argc, char** argv)
 
     globals = new FGGlobals;
 
-    fgInitFGRoot(arguments.argc(), arguments.argv());
     if ( !fgInitConfig(arguments.argc(), arguments.argv()) ) {
         SG_LOG( SG_GENERAL, SG_ALERT, "Config option parsing failed ..." );
         exit(-1);
@@ -202,15 +203,16 @@ fgviewerMain(int argc, char** argv)
     }
 
     globals->set_matlib( new SGMaterialLib );
-    simgear::SGModelLib::init(globals->get_fg_root());
+    simgear::SGModelLib::init(globals->get_fg_root(), globals->get_props());
 
     // 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);
     }
 
@@ -221,15 +223,14 @@ fgviewerMain(int argc, char** argv)
     // The file path list must be set in the registry.
     osgDB::Registry::instance()->getDataFilePathList() = filePathList;
 
-    SGReaderWriterBTGOptions* btgOptions = new SGReaderWriterBTGOptions;
-    btgOptions->getDatabasePathList() = filePathList;
-    btgOptions->setMatlib(globals->get_matlib());
-    btgOptions->setUseRandomObjects(fgGetBool("/sim/rendering/random-objects", false));
-    btgOptions->setUseRandomVegetation(fgGetBool("/sim/rendering/random-vegetation", false));
+    simgear::SGReaderWriterOptions* options = new simgear::SGReaderWriterOptions;
+    options->getDatabasePathList() = filePathList;
+    options->setMaterialLib(globals->get_matlib());
+    options->setPropertyNode(globals->get_props());
 
     // read the scene from the list of file specified command line args.
     osg::ref_ptr<osg::Node> loadedModel;
-    loadedModel = osgDB::readNodeFiles(dataFiles, btgOptions);
+    loadedModel = osgDB::readNodeFiles(dataFiles, options);
 
     // if no model has been successfully loaded report failure.
     if (!loadedModel.valid()) {