From 49accb16350f3a741f2dee2f03e4e98c13713f40 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 28 Mar 2008 15:28:03 +0000 Subject: [PATCH] Reordered set up of scene and event handlers to prevent warning --- .../osgmultitexturecontrol.cpp | 103 +++++++++--------- 1 file changed, 54 insertions(+), 49 deletions(-) diff --git a/examples/osgmultitexturecontrol/osgmultitexturecontrol.cpp b/examples/osgmultitexturecontrol/osgmultitexturecontrol.cpp index 28f704063..5ed8e720d 100644 --- a/examples/osgmultitexturecontrol/osgmultitexturecontrol.cpp +++ b/examples/osgmultitexturecontrol/osgmultitexturecontrol.cpp @@ -189,53 +189,6 @@ int main( int argc, char **argv ) // construct the viewer. osgViewer::Viewer viewer(arguments); - // load the nodes from the commandline arguments. - osg::Node* rootnode = osgDB::readNodeFiles(arguments); - - if (!rootnode) - { - osg::notify(osg::NOTICE)<<"Warning: no valid data loaded, please specify a database on the command line."<(rootnode); - if (!terrain) - { - terrain = new osgTerrain::Terrain; - terrain->addChild(rootnode); - - rootnode = terrain; - } - - osg::CoordinateSystemNode* csn = findTopMostNodeOfType(rootnode); - - unsigned int numLayers = 1; - osgFX::MultiTextureControl* mtc = findTopMostNodeOfType(rootnode); - if (mtc) - { - numLayers = mtc->getNumTextureWeights(); - } - - if (numLayers<2) - { - osg::notify(osg::NOTICE)<<"Warning: scene must have MultiTextureControl node with at least 2 texture units defined."<setCullCallback(elbc); - else if (mtc) mtc->setCullCallback(elbc); - else rootnode->setCullCallback(elbc); // add all the event handlers to the viewer { @@ -261,6 +214,7 @@ int main( int argc, char **argv ) viewer.addEventHandler(new osgViewer::LODScaleHandler); } + // add all the camera manipulators { osg::ref_ptr keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; @@ -289,8 +243,59 @@ int main( int argc, char **argv ) viewer.setCameraManipulator( keyswitchManipulator.get() ); } - // add a viewport to the viewer and attach the scene graph. - viewer.setSceneData( rootnode ); + // set up the scene graph + { + // load the nodes from the commandline arguments. + osg::Node* rootnode = osgDB::readNodeFiles(arguments); + + if (!rootnode) + { + osg::notify(osg::NOTICE)<<"Warning: no valid data loaded, please specify a database on the command line."<(rootnode); + if (!terrain) + { + terrain = new osgTerrain::Terrain; + terrain->addChild(rootnode); + + rootnode = terrain; + } + + osg::CoordinateSystemNode* csn = findTopMostNodeOfType(rootnode); + + unsigned int numLayers = 1; + osgFX::MultiTextureControl* mtc = findTopMostNodeOfType(rootnode); + if (mtc) + { + numLayers = mtc->getNumTextureWeights(); + } + + if (numLayers<2) + { + osg::notify(osg::NOTICE)<<"Warning: scene must have MultiTextureControl node with at least 2 texture units defined."<setCullCallback(elbc); + else if (mtc) mtc->setCullCallback(elbc); + else rootnode->setCullCallback(elbc); + + // add a viewport to the viewer and attach the scene graph. + viewer.setSceneData( rootnode ); + } // create the windows and run the threads. viewer.realize();