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:
parent
c9c90f17fe
commit
0b44409fca
5 changed files with 61 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -74,4 +74,6 @@ protected:
|
|||
osg::ref_ptr<FGManipulator> manipulator;
|
||||
};
|
||||
|
||||
bool fgDumpSceneGraphToFile(const char* filename);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue