Improved the handling of command line parameters
This commit is contained in:
parent
bfe4877b9a
commit
2c2234d68b
@ -537,10 +537,10 @@ public:
|
|||||||
}
|
}
|
||||||
else if (ea.getKey()=='o')
|
else if (ea.getKey()=='o')
|
||||||
{
|
{
|
||||||
if (osgDB::writeNodeFile( _node, "saved_model.osg" ))
|
if (osgDB::writeNodeFile( _node, "saved_model.osgt" ))
|
||||||
osg::notify( osg::ALWAYS ) << "osgOQ: Wrote scene graph to \"saved_model.osg\"" << std::endl;
|
osg::notify( osg::ALWAYS ) << "osgOQ: Wrote scene graph to \"saved_model.osgt\"" << std::endl;
|
||||||
else
|
else
|
||||||
osg::notify( osg::ALWAYS ) << "osgOQ: Wrote failed for \"saved_model.osg\"" << std::endl;
|
osg::notify( osg::ALWAYS ) << "osgOQ: Wrote failed for \"saved_model.osgt\"" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -744,28 +744,35 @@ int main(int argc, char** argv)
|
|||||||
// add the help handler
|
// add the help handler
|
||||||
viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage()));
|
viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage()));
|
||||||
|
|
||||||
|
bool optimize = arguments.read( "--opt" );
|
||||||
|
|
||||||
// load the specified model
|
// load the specified model
|
||||||
osg::ref_ptr<osg::Node> root = osgDB::readNodeFiles( arguments );
|
osg::ref_ptr<osg::Node> root = 0;
|
||||||
if (!root)
|
|
||||||
|
if (arguments.argc()>1)
|
||||||
|
{
|
||||||
|
root = osgDB::readNodeFiles( arguments );
|
||||||
|
if (root.valid())
|
||||||
|
{
|
||||||
|
// Run a NodeVisitor to insert OcclusionQueryNodes in the scene graph.
|
||||||
|
OcclusionQueryVisitor oqv;
|
||||||
|
root->accept( oqv );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << arguments.getApplicationName() <<": unable to load specified data." << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
std::cout << arguments.getApplicationName() <<": No files specified, or can't load them." << std::endl;
|
|
||||||
root = createStockScene().get();
|
root = createStockScene().get();
|
||||||
if (!root)
|
if (!root)
|
||||||
{
|
{
|
||||||
std::cout << arguments.getApplicationName() <<": Failed to create stock scene." << std::endl;
|
std::cout << arguments.getApplicationName() <<": Failed to create stock scene." << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
std::cout << "Using stock scene instead." << std::endl;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Run a NodeVisitor to insert OcclusionQueryNodes in the scene graph.
|
|
||||||
OcclusionQueryVisitor oqv;
|
|
||||||
root->accept( oqv );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool optimize = arguments.read( "--opt" );
|
|
||||||
|
|
||||||
// any option left unread are converted into errors to write out later.
|
// any option left unread are converted into errors to write out later.
|
||||||
arguments.reportRemainingOptionsAsUnrecognized();
|
arguments.reportRemainingOptionsAsUnrecognized();
|
||||||
|
Loading…
Reference in New Issue
Block a user