Fixed handling of Terrain/CoordinateSystem node so that the code now handles the fact that Terrain now subclasses from CoordinateSystemNode.
This commit is contained in:
parent
a4718ef88b
commit
4012841053
@ -350,9 +350,17 @@ int main( int argc, char **argv )
|
|||||||
if (!terrain)
|
if (!terrain)
|
||||||
{
|
{
|
||||||
terrain = new osgTerrain::Terrain;
|
terrain = new osgTerrain::Terrain;
|
||||||
|
|
||||||
|
osg::CoordinateSystemNode* csn = findTopMostNodeOfType<osg::CoordinateSystemNode>(rootnode);
|
||||||
|
if (csn)
|
||||||
|
{
|
||||||
|
terrain->set(*csn);
|
||||||
|
}
|
||||||
|
|
||||||
terrain->addChild(rootnode);
|
terrain->addChild(rootnode);
|
||||||
|
|
||||||
rootnode = terrain;
|
rootnode = terrain;
|
||||||
|
csn = terrain;
|
||||||
}
|
}
|
||||||
|
|
||||||
terrain->setSampleRatio(sampleRatio);
|
terrain->setSampleRatio(sampleRatio);
|
||||||
@ -361,12 +369,12 @@ int main( int argc, char **argv )
|
|||||||
// register our custom handler for adjust Terrain settings
|
// register our custom handler for adjust Terrain settings
|
||||||
viewer.addEventHandler(new TerrainHandler(terrain));
|
viewer.addEventHandler(new TerrainHandler(terrain));
|
||||||
|
|
||||||
osg::CoordinateSystemNode* csn = findTopMostNodeOfType<osg::CoordinateSystemNode>(rootnode);
|
|
||||||
|
|
||||||
unsigned int numLayers = 1;
|
unsigned int numLayers = 1;
|
||||||
osgFX::MultiTextureControl* mtc = findTopMostNodeOfType<osgFX::MultiTextureControl>(rootnode);
|
osgFX::MultiTextureControl* mtc = findTopMostNodeOfType<osgFX::MultiTextureControl>(rootnode);
|
||||||
if (mtc)
|
if (mtc)
|
||||||
{
|
{
|
||||||
|
|
||||||
numLayers = mtc->getNumTextureWeights();
|
numLayers = mtc->getNumTextureWeights();
|
||||||
|
|
||||||
// switch on just the first texture layer.
|
// switch on just the first texture layer.
|
||||||
@ -391,15 +399,13 @@ int main( int argc, char **argv )
|
|||||||
maxElevationTransition /= 2.0;
|
maxElevationTransition /= 2.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElevationLayerBlendingCallback* elbc = new ElevationLayerBlendingCallback(mtc, elevations);
|
|
||||||
|
|
||||||
// assign to the most appropriate node (the CoordinateSystemNode is best as it provides the elevation on the globe.)
|
// we must assign callback as both an update and cull callback, as update callback to do the update of
|
||||||
// note we must assign callback as both an update and cull callback, as update callback to do the update of
|
|
||||||
// the the osgFX::MultiTextureControl node a thread safe way, and as a cull callback to gather the camera
|
// the the osgFX::MultiTextureControl node a thread safe way, and as a cull callback to gather the camera
|
||||||
// position information.
|
// position information.
|
||||||
osg::Node* nodeToAssignCallbackTo = csn ? csn : (mtc ? mtc : rootnode);
|
ElevationLayerBlendingCallback* elbc = new ElevationLayerBlendingCallback(mtc, elevations);
|
||||||
nodeToAssignCallbackTo->setUpdateCallback(elbc);
|
terrain->setUpdateCallback(elbc);
|
||||||
nodeToAssignCallbackTo->setCullCallback(elbc);
|
terrain->setCullCallback(elbc);
|
||||||
|
|
||||||
// add a viewport to the viewer and attach the scene graph.
|
// add a viewport to the viewer and attach the scene graph.
|
||||||
viewer.setSceneData( rootnode );
|
viewer.setSceneData( rootnode );
|
||||||
|
Loading…
Reference in New Issue
Block a user