Show
Ignore:
Timestamp:
04/29/10 11:46:14 (4 years ago)
Author:
robert
Message:

Fixed handling of Terrain/CoordinateSystem node so that the code now handles the fact that Terrain now subclasses from CoordinateSystemNode?.

Files:
1 modified

Legend:

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

    r9395 r11391  
    351351        { 
    352352            terrain = new osgTerrain::Terrain; 
     353 
     354            osg::CoordinateSystemNode* csn = findTopMostNodeOfType<osg::CoordinateSystemNode>(rootnode); 
     355            if (csn) 
     356            { 
     357                terrain->set(*csn); 
     358            } 
     359 
    353360            terrain->addChild(rootnode); 
    354361 
    355362            rootnode = terrain; 
    356         }     
     363            csn = terrain; 
     364        } 
    357365 
    358366        terrain->setSampleRatio(sampleRatio); 
    359367        terrain->setVerticalScale(verticalScale); 
    360368 
    361         // register our custom handler for adjust Terrain settings         
     369        // register our custom handler for adjust Terrain settings 
    362370        viewer.addEventHandler(new TerrainHandler(terrain)); 
    363371 
    364         osg::CoordinateSystemNode* csn = findTopMostNodeOfType<osg::CoordinateSystemNode>(rootnode); 
    365372 
    366373        unsigned int numLayers = 1; 
     
    368375        if (mtc) 
    369376        { 
     377 
    370378            numLayers = mtc->getNumTextureWeights(); 
    371379 
     
    392400        } 
    393401 
    394         ElevationLayerBlendingCallback* elbc = new ElevationLayerBlendingCallback(mtc, elevations); 
    395  
    396         // assign to the most appropriate node (the CoordinateSystemNode is best as it provides the elevation on the globe.) 
    397         // note we must assign callback as both an update and cull callback, as update callback to do the update of 
     402 
     403        // we must assign callback as both an update and cull callback, as update callback to do the update of 
    398404        // the the osgFX::MultiTextureControl node a thread safe way, and as a cull callback to gather the camera 
    399405        // position information. 
    400         osg::Node* nodeToAssignCallbackTo = csn ? csn : (mtc ? mtc : rootnode); 
    401         nodeToAssignCallbackTo->setUpdateCallback(elbc);     
    402         nodeToAssignCallbackTo->setCullCallback(elbc);     
     406        ElevationLayerBlendingCallback* elbc = new ElevationLayerBlendingCallback(mtc, elevations); 
     407        terrain->setUpdateCallback(elbc); 
     408        terrain->setCullCallback(elbc); 
    403409 
    404410        // add a viewport to the viewer and attach the scene graph.