1
0
Fork 0

Modified Files:

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.
This commit is contained in:
frohlich 2007-05-26 11:39:13 +00:00
parent c9c90f17fe
commit 0b44409fca
5 changed files with 61 additions and 0 deletions

View file

@ -47,6 +47,7 @@ extern void guiErrorMessage(const char *txt);
extern void guiErrorMessage(const char *txt, const sg_throwable &throwable); extern void guiErrorMessage(const char *txt, const sg_throwable &throwable);
extern void fgDumpSnapShot(); extern void fgDumpSnapShot();
extern void fgDumpSceneGraph();
extern puFont guiFnt; extern puFont guiFnt;
extern fntTexFont *guiFntHandle; extern fntTexFont *guiFntHandle;

View 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);
}
}

View file

@ -487,6 +487,12 @@ do_screen_capture (const SGPropertyNode * arg)
return true; return true;
} }
static bool
do_dump_scene_graph (const SGPropertyNode*)
{
fgDumpSceneGraph();
return true;
}
/** /**
* Built-in command: hires capture screen. * Built-in command: hires capture screen.
@ -1481,6 +1487,7 @@ static struct {
{ "savexml", do_save_xml_from_proptree }, { "savexml", do_save_xml_from_proptree },
{ "press-cockpit-button", do_press_cockpit_button }, { "press-cockpit-button", do_press_cockpit_button },
{ "release-cockpit-button", do_release_cockpit_button }, { "release-cockpit-button", do_release_cockpit_button },
{ "dump-scenegraph", do_dump_scene_graph },
{ 0, 0 } // zero-terminated { 0, 0 } // zero-terminated
}; };

View file

@ -1109,5 +1109,10 @@ FGRenderer::pick( unsigned x, unsigned y,
return !pickList.empty(); return !pickList.empty();
} }
bool fgDumpSceneGraphToFile(const char* filename)
{
return osgDB::writeNodeFile(*mRealRoot.get(), filename);
}
// end of renderer.cxx // end of renderer.cxx

View file

@ -74,4 +74,6 @@ protected:
osg::ref_ptr<FGManipulator> manipulator; osg::ref_ptr<FGManipulator> manipulator;
}; };
bool fgDumpSceneGraphToFile(const char* filename);
#endif #endif