1
0
Fork 0

Add a command to dump just the terrain portion of the scene graph to a .osg

file.  Possible uses of this functionality could include converting the
model to some other format or coordinate system for use in some other
visualization or simulation.
This commit is contained in:
curt 2007-11-21 20:51:49 +00:00
parent 12f233d875
commit 8f64d4820c
5 changed files with 74 additions and 2 deletions

View file

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

View file

@ -591,7 +591,7 @@ void fgDumpSnapShot () {
}
}
// do a screen snap shot
// do an entire scenegraph dump
void fgDumpSceneGraph()
{
char *filename = new char [24];
@ -617,7 +617,52 @@ void fgDumpSceneGraph()
}
if ( fgDumpSceneGraphToFile(filename)) {
message = "Scene graphe saved to \"";
message = "Entire scene graph 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);
}
}
// do an terrain branch dump
void fgDumpTerrainBranch()
{
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 ( fgDumpTerrainBranchToFile(filename)) {
message = "Terrain graph saved to \"";
message += filename;
message += "\".";
} else {

View file

@ -494,6 +494,23 @@ do_dump_scene_graph (const SGPropertyNode*)
return true;
}
static bool
do_dump_terrain_branch (const SGPropertyNode*)
{
fgDumpTerrainBranch();
double lon_deg = fgGetDouble("/position/longitude-deg");
double lat_deg = fgGetDouble("/position/latitude-deg");
SGGeod geodPos = SGGeod::fromDegFt(lon_deg, lat_deg, 0.0);
SGVec3d zero = SGVec3d::fromGeod(geodPos);
SG_LOG(SG_INPUT, SG_INFO, "Model parameters:");
SG_LOG(SG_INPUT, SG_INFO, "Center: " << zero.x() << ", " << zero.y() << ", " << zero.z() );
SG_LOG(SG_INPUT, SG_INFO, "Rotation: " << lat_deg << ", " << lon_deg );
return true;
}
/**
* Built-in command: hires capture screen.
*/
@ -1471,6 +1488,7 @@ static struct {
{ "press-cockpit-button", do_press_cockpit_button },
{ "release-cockpit-button", do_release_cockpit_button },
{ "dump-scenegraph", do_dump_scene_graph },
{ "dump-terrainbranch", do_dump_terrain_branch },
{ 0, 0 } // zero-terminated
};

View file

@ -1071,5 +1071,12 @@ fgDumpSceneGraphToFile(const char* filename)
return osgDB::writeNodeFile(*mRealRoot.get(), filename);
}
bool
fgDumpTerrainBranchToFile(const char* filename)
{
return osgDB::writeNodeFile( *globals->get_scenery()->get_terrain_branch(),
filename );
}
// end of renderer.cxx

View file

@ -81,5 +81,6 @@ protected:
};
bool fgDumpSceneGraphToFile(const char* filename);
bool fgDumpTerrainBranchToFile(const char* filename);
#endif