From b3cec3d986183ef41d2a40c2554ed1d1260e7a4f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 8 Jun 2007 12:13:33 +0000 Subject: [PATCH] Added default file load to avoid the need for command line option. --- .../osgblendequation/osgblendequation.cpp | 6 +++++- examples/osgcallback/osgcallback.cpp | 4 ++++ examples/osgclip/osgclip.cpp | 6 ++++++ examples/osgcubemap/osgcubemap.cpp | 7 ++++++- examples/osgdistortion/osgdistortion.cpp | 20 ++++++++++++++++--- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/examples/osgblendequation/osgblendequation.cpp b/examples/osgblendequation/osgblendequation.cpp index 26acb8398..f3871df80 100644 --- a/examples/osgblendequation/osgblendequation.cpp +++ b/examples/osgblendequation/osgblendequation.cpp @@ -122,12 +122,16 @@ int main( int argc, char **argv ) // load the nodes from the commandline arguments. osg::Node* loadedModel = osgDB::readNodeFiles(arguments); + + // if not loaded assume no arguments passed in, try use default mode instead. + if (!loadedModel) loadedModel = osgDB::readNodeFile("cessnafire.osg"); + if (!loadedModel) { std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl; return 1; } - + osg::Group* root = new osg::Group; root->addChild(loadedModel); diff --git a/examples/osgcallback/osgcallback.cpp b/examples/osgcallback/osgcallback.cpp index 11eda6ed0..71b690586 100644 --- a/examples/osgcallback/osgcallback.cpp +++ b/examples/osgcallback/osgcallback.cpp @@ -152,6 +152,10 @@ int main( int argc, char **argv ) // load the nodes from the commandline arguments. osg::Node* rootnode = osgDB::readNodeFiles(arguments); + + // if not loaded assume no arguments passed in, try use default mode instead. + if (!rootnode) rootnode = osgDB::readNodeFile("cow.osg"); + if (!rootnode) { osg::notify(osg::NOTICE)<<"Please specify a file on the command line"< #include +#include + using namespace osg; osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearColour) @@ -644,6 +646,18 @@ int main(int argc, char** argv) // construct the viewer. osgViewer::Viewer viewer; + + // load the nodes from the commandline arguments. + osg::Node* loadedModel = osgDB::readNodeFiles(arguments); + + // if not loaded assume no arguments passed in, try use default mode instead. + if (!loadedModel) loadedModel = osgDB::readNodeFile("cessnafire.osg"); + + if (!loadedModel) + { + std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl; + return 1; + } if (arguments.read("--dome") || arguments.read("--puffer") ) @@ -651,18 +665,18 @@ int main(int argc, char** argv) setDomeCorrection(viewer, arguments); - viewer.setSceneData( osgDB::readNodeFiles(arguments) ); + viewer.setSceneData( loadedModel ); } else if (arguments.read("--faces")) { setDomeFaces(viewer, arguments); - viewer.setSceneData( osgDB::readNodeFiles(arguments) ); + viewer.setSceneData( loadedModel ); } else { - osg::Node* distortionNode = createDistortionSubgraph( osgDB::readNodeFiles(arguments), viewer.getCamera()->getClearColor()); + osg::Node* distortionNode = createDistortionSubgraph( loadedModel, viewer.getCamera()->getClearColor()); viewer.setSceneData( distortionNode ); }