]> git.mxchange.org Git - flightgear.git/commitdiff
Modified Files:
authorfrohlich <frohlich>
Sat, 26 May 2007 11:39:13 +0000 (11:39 +0000)
committerfrohlich <frohlich>
Sat, 26 May 2007 11:39:13 +0000 (11:39 +0000)
src/GUI/gui.h src/GUI/gui_funcs.cxx src/Main/fg_commands.cxx
src/Main/renderer.cxx src/Main/renderer.hxx: Tim Moore:
These patches implement a command to dump the entire OSG scene graph as
        a .osg text file. While large, this allows debuggers to really see
        what's happening in the scene graph.

src/GUI/gui.h
src/GUI/gui_funcs.cxx
src/Main/fg_commands.cxx
src/Main/renderer.cxx
src/Main/renderer.hxx

index 6f3dcb8751769d5ddd9498ee610e53c811fe43a3..31e65bb10f3c2197d41282a198ab71da1463827c 100644 (file)
@@ -47,6 +47,7 @@ extern void guiErrorMessage(const char *txt);
 extern void guiErrorMessage(const char *txt, const sg_throwable &throwable);
 
 extern void fgDumpSnapShot();
+extern void fgDumpSceneGraph();
 
 extern puFont guiFnt;
 extern fntTexFont *guiFntHandle;
index b87c5c0fe7d084ff30c54ac656aa5d0d37d5445d..d8bb9b280597d9b2becbe0f1f21ee634bcbd25c7 100644 (file)
@@ -571,3 +571,49 @@ void fgDumpSnapShot () {
     }
 }
 
+// do a screen snap shot
+void fgDumpSceneGraph()
+{
+    char *filename = new char [24];
+    string message;
+    static int count = 1;
+
+    FGRenderer *renderer = globals->get_renderer();
+
+    static const SGPropertyNode *master_freeze
+       = fgGetNode("/sim/freeze/master");
+
+    bool freeze = master_freeze->getBoolValue();
+    if ( !freeze ) {
+        fgSetBool("/sim/freeze/master", true);
+    }
+
+    while (count < 1000) {
+        FILE *fp;
+        snprintf(filename, 24, "fgfs-graph-%03d.osg", count++);
+        if ( (fp = fopen(filename, "r")) == NULL )
+            break;
+        fclose(fp);
+    }
+
+    if ( fgDumpSceneGraphToFile(filename)) {
+       message = "Scene graphe saved to \"";
+       message += filename;
+       message += "\".";
+    } else {
+        message = "Failed to save to \"";
+       message += filename;
+       message += "\".";
+    }
+
+    mkDialog (message.c_str());
+
+    delete [] filename;
+
+    if ( !freeze ) {
+        fgSetBool("/sim/freeze/master", false);
+    }
+}
+
+    
+
index 78f4119cc80168738b8b630e4ea9b5c66eacacd7..2c0f7c23dabdec17843594a277ad759811352915 100644 (file)
@@ -487,6 +487,12 @@ do_screen_capture (const SGPropertyNode * arg)
   return true;
 }
 
+static bool
+do_dump_scene_graph (const SGPropertyNode*)
+{
+    fgDumpSceneGraph();
+    return true;
+}
 
 /**
  * Built-in command: hires capture screen.
@@ -1481,6 +1487,7 @@ static struct {
     { "savexml", do_save_xml_from_proptree },    
     { "press-cockpit-button", do_press_cockpit_button },
     { "release-cockpit-button", do_release_cockpit_button },
+    { "dump-scenegraph", do_dump_scene_graph },
     { 0, 0 }                   // zero-terminated
 };
 
index 913a2372a769d881149814c6315451752897f5f7..a6ab199bb39f38eee8b74b0f46ee536e89edab9c 100644 (file)
@@ -1109,5 +1109,10 @@ FGRenderer::pick( unsigned x, unsigned y,
   return !pickList.empty();
 }
 
+bool fgDumpSceneGraphToFile(const char* filename)
+{
+    return osgDB::writeNodeFile(*mRealRoot.get(), filename);
+}
+
 // end of renderer.cxx
     
index 7bc54bfe94caa1f984847dc8e46ef19ac9bfc3f7..1ac1af354b869c9f0587b753132b19417cb37ee5 100644 (file)
@@ -74,4 +74,6 @@ protected:
     osg::ref_ptr<FGManipulator> manipulator;
 };
 
+bool fgDumpSceneGraphToFile(const char* filename);
+
 #endif