-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
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.
Tim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFGV+4PeDhWHdXrDRURAjsyAJ43j2FxyonHypcWzehgDFrvvXR/ywCg24jI
5y2nbs0MY1fGYYYJRbU2vpE=
=iDW+
-----END PGP SIGNATURE-----
Index: src/GUI/gui.h
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/GUI/gui.h,v
retrieving revision 1.17
diff -d -u -r1.17 gui.h
--- src/GUI/gui.h 7 Jan 2007 15:51:29 -0000 1.17
+++ src/GUI/gui.h 26 May 2007 08:17:05 -0000
@@ -47,6 +47,7 @@
extern void guiErrorMessage(const char *txt, const sg_throwable &throwable);
extern void fgDumpSnapShot();
+extern void fgDumpSceneGraph();
extern puFont guiFnt;
extern fntTexFont *guiFntHandle;
Index: src/GUI/gui_funcs.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/GUI/gui_funcs.cxx,v
retrieving revision 1.51
diff -d -u -r1.51 gui_funcs.cxx
--- src/GUI/gui_funcs.cxx 7 Jan 2007 15:51:29 -0000 1.51
+++ src/GUI/gui_funcs.cxx 26 May 2007 08:17:06 -0000
@@ -571,3 +571,49 @@
}
}
+// 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: src/Main/fg_commands.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/fg_commands.cxx,v
retrieving revision 1.87
diff -d -u -r1.87 fg_commands.cxx
--- src/Main/fg_commands.cxx 15 May 2007 14:39:56 -0000 1.87
+++ src/Main/fg_commands.cxx 26 May 2007 08:17:06 -0000
@@ -487,6 +487,12 @@
return true;
}
+static bool
+do_dump_scene_graph (const SGPropertyNode*)
+{
+ fgDumpSceneGraph();
+ return true;
+}
/**
* Built-in command: hires capture screen.
@@ -1481,6 +1487,7 @@
{ "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: src/Main/renderer.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/renderer.cxx,v
retrieving revision 1.85
diff -d -u -r1.85 renderer.cxx
--- src/Main/renderer.cxx 21 May 2007 17:50:03 -0000 1.85
+++ src/Main/renderer.cxx 26 May 2007 08:17:07 -0000
@@ -1109,5 +1109,10 @@
return !pickList.empty();
}
+bool fgDumpSceneGraphToFile(const char* filename)
+{
+ return osgDB::writeNodeFile(*mRealRoot.get(), filename);
+}
+
// end of renderer.cxx
Index: src/Main/renderer.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/renderer.hxx,v
retrieving revision 1.13
diff -d -u -r1.13 renderer.hxx
--- src/Main/renderer.hxx 21 May 2007 17:50:03 -0000 1.13
+++ src/Main/renderer.hxx 26 May 2007 08:17:07 -0000
@@ -74,4 +74,6 @@
osg::ref_ptr<FGManipulator> manipulator;
};
+bool fgDumpSceneGraphToFile(const char* filename);
+
#endif
Index: gui/menubar.xml
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/gui/menubar.xml,v
retrieving revision 1.62
diff -d -u -r1.62 menubar.xml
--- gui/menubar.xml 24 Mar 2007 20:56:40 -0000 1.62
+++ gui/menubar.xml 26 May 2007 08:18:43 -0000
@@ -445,6 +445,12 @@
</binding>
</item>
+<item>
+ <label>Dump Scene Graph</label>
+ <binding>
+ <command>dump-scenegraph</command>
+ </binding>
+ </item>
</menu>
<menu>
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel