Show
Ignore:
Timestamp:
06/14/11 18:50:40 (2 years ago)
Author:
robert
Message:

Improved the handling of command line parameters

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgocclusionquery/osgocclusionquery.cpp

    r12292 r12528  
    538538                else if (ea.getKey()=='o') 
    539539                { 
    540                     if (osgDB::writeNodeFile( _node, "saved_model.osg" )) 
    541                         osg::notify( osg::ALWAYS ) << "osgOQ: Wrote scene graph to \"saved_model.osg\"" << std::endl; 
     540                    if (osgDB::writeNodeFile( _node, "saved_model.osgt" )) 
     541                        osg::notify( osg::ALWAYS ) << "osgOQ: Wrote scene graph to \"saved_model.osgt\"" << std::endl; 
    542542                    else 
    543                         osg::notify( osg::ALWAYS ) << "osgOQ: Wrote failed for \"saved_model.osg\"" << std::endl; 
     543                        osg::notify( osg::ALWAYS ) << "osgOQ: Wrote failed for \"saved_model.osgt\"" << std::endl; 
    544544                    return true; 
    545545                } 
     
    745745    viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage())); 
    746746 
     747    bool optimize = arguments.read( "--opt" ); 
    747748 
    748749    // load the specified model 
    749     osg::ref_ptr<osg::Node> root = osgDB::readNodeFiles( arguments ); 
    750     if (!root) 
    751     { 
    752         std::cout << arguments.getApplicationName() <<": No files specified, or can't load them." << std::endl; 
     750    osg::ref_ptr<osg::Node> root = 0; 
     751 
     752    if (arguments.argc()>1) 
     753    { 
     754        root = osgDB::readNodeFiles( arguments ); 
     755        if (root.valid()) 
     756        { 
     757            // Run a NodeVisitor to insert OcclusionQueryNodes in the scene graph. 
     758            OcclusionQueryVisitor oqv; 
     759            root->accept( oqv ); 
     760        } 
     761        else 
     762        { 
     763            std::cout << arguments.getApplicationName() <<": unable to load specified data." << std::endl; 
     764            return 1; 
     765        } 
     766    } 
     767    else 
     768    { 
    753769        root = createStockScene().get(); 
    754770        if (!root) 
     
    757773            return 1; 
    758774        } 
    759         std::cout << "Using stock scene instead." << std::endl; 
    760     } 
    761     else 
    762     { 
    763         // Run a NodeVisitor to insert OcclusionQueryNodes in the scene graph. 
    764         OcclusionQueryVisitor oqv; 
    765         root->accept( oqv ); 
    766     } 
    767  
    768     bool optimize = arguments.read( "--opt" ); 
     775    } 
    769776 
    770777    // any option left unread are converted into errors to write out later.