extern void guiErrorMessage(const char *txt, const sg_throwable &throwable);
extern void fgDumpSnapShot();
+extern void fgDumpSceneGraph();
extern puFont guiFnt;
extern fntTexFont *guiFntHandle;
}
}
+// 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);
+ }
+}
+
+
+
return true;
}
+static bool
+do_dump_scene_graph (const SGPropertyNode*)
+{
+ fgDumpSceneGraph();
+ return true;
+}
/**
* Built-in command: hires capture screen.
{ "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
};
return !pickList.empty();
}
+bool fgDumpSceneGraphToFile(const char* filename)
+{
+ return osgDB::writeNodeFile(*mRealRoot.get(), filename);
+}
+
// end of renderer.cxx
osg::ref_ptr<FGManipulator> manipulator;
};
+bool fgDumpSceneGraphToFile(const char* filename);
+
#endif