|
osgEarth 2.1.1
|
Inheritance diagram for osgEarth::TerrainEngineNode:
Collaboration diagram for osgEarth::TerrainEngineNode:TerrainEngineNode is the base class and interface for map engine implementations.
A map engine lives under a MapNode and is responsible for generating the actual geometry representing the Earth.
Definition at line 38 of file TerrainEngineNode.
enum osgEarth::TerrainEngineNode::InitStage [private] |
Definition at line 142 of file TerrainEngineNode.
| TerrainEngineNode::TerrainEngineNode | ( | ) | [protected] |
Definition at line 112 of file TerrainEngineNode.cpp.
: _verticalScale( 1.0f ), _elevationSamplingRatio( 1.0f ), _initStage( INIT_NONE ) { //nop }
| TerrainEngineNode::TerrainEngineNode | ( | const TerrainEngineNode & | rhs, |
| const osg::CopyOp & | op = osg::CopyOp::DEEP_COPY_ALL |
||
| ) | [protected] |
Definition at line 120 of file TerrainEngineNode.cpp.
: osg::CoordinateSystemNode( rhs, op ), _verticalScale( rhs._verticalScale ), _elevationSamplingRatio( rhs._elevationSamplingRatio ), _map( rhs._map.get() ), _initStage( rhs._initStage ) { //nop }
| TerrainEngineNode::~TerrainEngineNode | ( | ) | [protected, virtual] |
Definition at line 80 of file TerrainEngineNode.cpp.
{
//Remove any callbacks added to the image layers
if (_map.valid())
{
MapFrame mapf( _map.get(), Map::IMAGE_LAYERS, "TerrainEngineNode::~TerrainEngineNode" );
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
i->get()->removeCallback( _imageLayerController.get() );
}
}
}
| osg::BoundingSphere TerrainEngineNode::computeBound | ( | ) | const [virtual] |
Reimplemented in OSGTerrainEngineNode.
Definition at line 204 of file TerrainEngineNode.cpp.
{
if ( getEllipsoidModel() )
{
return osg::BoundingSphere( osg::Vec3(0,0,0), getEllipsoidModel()->getRadiusEquator()+25000 );
}
else
{
return osg::CoordinateSystemNode::computeBound();
}
}
| float osgEarth::TerrainEngineNode::getElevationSamplingRatio | ( | ) | const [inline] |
Gets the sampling ratio for elevation grid data.
Definition at line 62 of file TerrainEngineNode.
{ return _elevationSamplingRatio; }
| const Map* osgEarth::TerrainEngineNode::getMap | ( | ) | const [inline] |
Gets the map that this engine is rendering.
Definition at line 42 of file TerrainEngineNode.
{ return _map.get(); }
Here is the caller graph for this function:| virtual const TerrainOptions& osgEarth::TerrainEngineNode::getTerrainOptions | ( | ) | const [pure virtual] |
Gets the property set in use by this map engine.
Implemented in OSGTerrainEngineNode, and seamless::SeamlessEngineNode.
| TextureCompositor* osgEarth::TerrainEngineNode::getTextureCompositor | ( | ) | const [inline] |
Accesses the compositor that controls the rendering of image layers
Definition at line 48 of file TerrainEngineNode.
{ return _texCompositor.get(); }
Here is the caller graph for this function:| float osgEarth::TerrainEngineNode::getVerticalScale | ( | ) | const [inline] |
Gets the scale factor to apply to elevation height values.
Definition at line 56 of file TerrainEngineNode.
{ return _verticalScale; }
| virtual void osgEarth::TerrainEngineNode::onElevationSamplingRatioChanged | ( | ) | [inline, protected, virtual] |
| void TerrainEngineNode::onMapInfoEstablished | ( | const MapInfo & | mapInfo | ) | [private] |
Reimplemented in OSGTerrainEngineNode.
Definition at line 231 of file TerrainEngineNode.cpp.
{
// set up the CSN values
mapInfo.getProfile()->getSRS()->populateCoordinateSystemNode( this );
// OSG's CSN likes a NULL ellipsoid to represent projected mode.
if ( !mapInfo.isGeocentric() )
this->setEllipsoidModel( NULL );
}
Here is the call graph for this function:
Here is the caller graph for this function:| void TerrainEngineNode::onMapModelChanged | ( | const MapModelChange & | change | ) | [private] |
Reimplemented in OSGTerrainEngineNode.
Definition at line 242 of file TerrainEngineNode.cpp.
{
if ( _initStage == INIT_POSTINIT_COMPLETE )
{
if ( change.getAction() == MapModelChange::ADD_IMAGE_LAYER )
{
change.getImageLayer()->addCallback( _imageLayerController.get() );
}
else if ( change.getAction() == MapModelChange::REMOVE_IMAGE_LAYER )
{
change.getImageLayer()->removeCallback( _imageLayerController.get() );
}
if (change.getAction() == MapModelChange::ADD_IMAGE_LAYER ||
change.getAction() == MapModelChange::REMOVE_IMAGE_LAYER ||
change.getAction() == MapModelChange::MOVE_IMAGE_LAYER )
{
updateImageUniforms();
}
}
// if post-initialization has not yet happened, we need to make sure the
// compositor is up to date with the map model. (After post-initialization,
// this happens in the subclass...something that probably needs to change
// since this is unclear)
else if ( _texCompositor.valid() )
{
_texCompositor->applyMapModelChange( change );
}
}
Here is the call graph for this function:| virtual void osgEarth::TerrainEngineNode::onVerticalScaleChanged | ( | ) | [inline, protected, virtual] |
| void TerrainEngineNode::postInitialize | ( | const Map * | map, |
| const TerrainOptions & | options | ||
| ) | [protected, virtual] |
Reimplemented in OSGTerrainEngineNode.
Definition at line 175 of file TerrainEngineNode.cpp.
{
if ( _map.valid() ) // i think this is always true [gw]
{
// manually trigger the map callbacks the first time:
if ( _map->getProfile() )
onMapInfoEstablished( MapInfo(_map.get()) );
// create a layer controller. This object affects the uniforms that control layer appearance properties
_imageLayerController = new ImageLayerController( _map.get() );
// register the layer Controller it with all pre-existing image layers:
MapFrame mapf( _map.get(), Map::IMAGE_LAYERS, "TerrainEngineNode::initialize" );
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
i->get()->addCallback( _imageLayerController.get() );
}
updateImageUniforms();
// then register the callback
// NOTE: moved this into preInitialize
//_map->addMapCallback( new TerrainEngineNodeCallbackProxy( this ) );
}
_initStage = INIT_POSTINIT_COMPLETE;
}
Here is the call graph for this function:| void TerrainEngineNode::preInitialize | ( | const Map * | map, |
| const TerrainOptions & | options | ||
| ) | [protected, virtual] |
Attaches a map to the terrain engine and initialized it.
Reimplemented in OSGTerrainEngineNode, and seamless::SeamlessEngineNode.
Definition at line 131 of file TerrainEngineNode.cpp.
{
_map = map;
// set up the CSN values
_map->getProfile()->getSRS()->populateCoordinateSystemNode( this );
// OSG's CSN likes a NULL ellipsoid to represent projected mode.
if ( !_map->isGeocentric() )
this->setEllipsoidModel( NULL );
// install the proper layer composition technique:
_texCompositor = new TextureCompositor( options );
// prime the compositor with pre-existing image layers:
MapFrame mapf(map, Map::IMAGE_LAYERS);
for( unsigned i=0; i<mapf.imageLayers().size(); ++i )
{
_texCompositor->applyMapModelChange( MapModelChange(
MapModelChange::ADD_IMAGE_LAYER,
mapf.getRevision(),
mapf.getImageLayerAt(i),
i ) );
}
// then register the callback so we can process further map model changes
_map->addMapCallback( new TerrainEngineNodeCallbackProxy( this ) );
// enable backface culling
osg::StateSet* set = getOrCreateStateSet();
set->setAttributeAndModes( new osg::CullFace( osg::CullFace::BACK ), osg::StateAttribute::ON );
// elevation uniform
_cameraElevationUniform = new osg::Uniform( osg::Uniform::FLOAT, "osgearth_CameraElevation" );
_cameraElevationUniform->set( 0.0f );
set->addUniform( _cameraElevationUniform.get() );
set->getOrCreateUniform( "osgearth_ImageLayerAttenuation", osg::Uniform::FLOAT )->set(
*options.attentuationDistance() );
_initStage = INIT_PREINIT_COMPLETE;
}
Here is the call graph for this function:| void TerrainEngineNode::setElevationSamplingRatio | ( | float | value | ) |
Sets the sampling ratio for elevation grid data. Default is 1.0.
Definition at line 224 of file TerrainEngineNode.cpp.
{
_elevationSamplingRatio = value;
onElevationSamplingRatioChanged();
}
Here is the call graph for this function:| void TerrainEngineNode::setVerticalScale | ( | float | value | ) |
Sets the scale factor to apply to elevation height values. Default is 1.0
Definition at line 217 of file TerrainEngineNode.cpp.
{
_verticalScale = value;
onVerticalScaleChanged();
}
Here is the call graph for this function:| void TerrainEngineNode::traverse | ( | osg::NodeVisitor & | nv | ) | [virtual] |
Reimplemented in OSGTerrainEngineNode.
Definition at line 355 of file TerrainEngineNode.cpp.
{
if ( nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR )
{
if ( Registry::instance()->getCapabilities().supportsGLSL() )
{
_updateLightingUniformsHelper.cullTraverse( this, &nv );
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>( &nv );
if ( cv )
{
osg::Vec3d eye = cv->getEyePoint();
float elevation;
if ( _map->isGeocentric() )
elevation = eye.length() - osg::WGS_84_RADIUS_EQUATOR;
else
elevation = eye.z();
_cameraElevationUniform->set( elevation );
}
}
}
//else if ( nv.getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR )
//{
// if ( Registry::instance()->getCapabilities().supportsGLSL() )
// _updateLightingUniformsHelper.updateTraverse( this );
//}
osg::CoordinateSystemNode::traverse( nv );
}
Here is the call graph for this function:| void TerrainEngineNode::updateImageUniforms | ( | ) | [private, virtual] |
Definition at line 274 of file TerrainEngineNode.cpp.
{
// don't bother if this is a hurting old card
if ( !Registry::instance()->getCapabilities().supportsGLSL() )
return;
// update the layer uniform arrays:
osg::StateSet* stateSet = this->getOrCreateStateSet();
// get a copy of the image layer stack:
MapFrame mapf( _map.get(), Map::IMAGE_LAYERS );
_imageLayerController->_layerEnabledUniform.detach();
_imageLayerController->_layerOpacityUniform.detach();
_imageLayerController->_layerRangeUniform.detach();
#if 0
if ( _imageLayerController->_layerEnabledUniform.valid() )
_imageLayerController->_layerEnabledUniform->removeFrom( stateSet );
if ( _imageLayerController->_layerOpacityUniform.valid() )
_imageLayerController->_layerOpacityUniform->removeFrom( stateSet );
if ( _imageLayerController->_layerRangeUniform.valid() )
_imageLayerController->_layerRangeUniform->removeFrom( stateSet );
#endif
//stateSet->removeUniform( "osgearth_ImageLayerAttenuation" );
if ( mapf.imageLayers().size() > 0 )
{
// the "enabled" uniform is fixed size. this is handy to account for layers that are in flux...i.e., their source
// layer count has changed, but the shader has not yet caught up. In the future we might use this to disable
// "ghost" layers that used to exist at a given index, but no longer do.
_imageLayerController->_layerEnabledUniform.attach( "osgearth_ImageLayerEnabled", osg::Uniform::BOOL, stateSet, 16 );
_imageLayerController->_layerOpacityUniform.attach( "osgearth_ImageLayerOpacity", osg::Uniform::FLOAT, stateSet, mapf.imageLayers().size() );
_imageLayerController->_layerRangeUniform.attach ( "osgearth_ImageLayerRange", osg::Uniform::FLOAT, stateSet, 2 * mapf.imageLayers().size() );
//_imageLayerController->_layerEnabledUniform = new ArrayUniform( osg::Uniform::BOOL, "osgearth_ImageLayerEnabled", 64 ); //mapf.imageLayers().size() );
//_imageLayerController->_layerOpacityUniform = new ArrayUniform( osg::Uniform::FLOAT, "osgearth_ImageLayerOpacity", mapf.imageLayers().size() );
//_imageLayerController->_layerRangeUniform = new ArrayUniform( osg::Uniform::FLOAT, "osgearth_ImageLayerRange", 2 * mapf.imageLayers().size() );
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
int index = (int)(i - mapf.imageLayers().begin());
_imageLayerController->_layerOpacityUniform.setElement( index, layer->getOpacity() );
_imageLayerController->_layerEnabledUniform.setElement( index, layer->getEnabled() );
_imageLayerController->_layerRangeUniform.setElement( (2*index), layer->getImageLayerOptions().minVisibleRange().value() );
_imageLayerController->_layerRangeUniform.setElement( (2*index)+1, layer->getImageLayerOptions().maxVisibleRange().value() );
}
// set the remainder of the layers to disabled
for( int j=mapf.imageLayers().size(); j<64; ++j )
_imageLayerController->_layerEnabledUniform.setElement( j, false );
//_imageLayerController->_layerOpacityUniform->addTo( stateSet );
//_imageLayerController->_layerEnabledUniform->addTo( stateSet );
//_imageLayerController->_layerRangeUniform->addTo( stateSet );
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| void TerrainEngineNode::validateTerrainOptions | ( | TerrainOptions & | options | ) | [protected, virtual] |
Reimplemented in OSGTerrainEngineNode, and seamless::SeamlessEngineNode.
Definition at line 339 of file TerrainEngineNode.cpp.
{
// make sure all the requested properties are compatible, and fall back as necessary.
//const Capabilities& caps = Registry::instance()->getCapabilities();
// warn against mixing multipass technique with preemptive/sequential mode:
if (options.compositingTechnique() == TerrainOptions::COMPOSITING_MULTIPASS &&
options.loadingPolicy()->mode() != LoadingPolicy::MODE_STANDARD )
{
OE_WARN << LC << "MULTIPASS compositor is incompatible with preemptive/sequential loading policy; "
<< "falling back on STANDARD mode" << std::endl;
options.loadingPolicy()->mode() = LoadingPolicy::MODE_STANDARD;
}
}
Here is the call graph for this function:
Here is the caller graph for this function:friend class MapNode [friend] |
Definition at line 95 of file TerrainEngineNode.
friend struct MapNodeMapLayerController [friend] |
Definition at line 101 of file TerrainEngineNode.
friend struct TerrainEngineNodeCallbackProxy [friend] |
Definition at line 85 of file TerrainEngineNode.
friend class TerrainEngineNodeFactory [friend] |
Definition at line 80 of file TerrainEngineNode.
osg::ref_ptr<osg::Uniform> osgEarth::TerrainEngineNode::_cameraElevationUniform [private] |
Definition at line 140 of file TerrainEngineNode.
float osgEarth::TerrainEngineNode::_elevationSamplingRatio [private] |
Definition at line 108 of file TerrainEngineNode.
osg::ref_ptr<ImageLayerController> osgEarth::TerrainEngineNode::_imageLayerController [private] |
Definition at line 137 of file TerrainEngineNode.
Definition at line 147 of file TerrainEngineNode.
osg::ref_ptr<const Map> osgEarth::TerrainEngineNode::_map [private] |
Definition at line 138 of file TerrainEngineNode.
osg::ref_ptr<osg::Uniform> osgEarth::TerrainEngineNode::_startFrameTimeUniform [private] |
Definition at line 139 of file TerrainEngineNode.
osg::ref_ptr<TextureCompositor> osgEarth::TerrainEngineNode::_texCompositor [protected] |
Definition at line 98 of file TerrainEngineNode.
Definition at line 106 of file TerrainEngineNode.
float osgEarth::TerrainEngineNode::_verticalScale [private] |
Definition at line 107 of file TerrainEngineNode.
1.7.3