|
osgEarth 2.1.1
|
Inheritance diagram for SerialKeyNodeFactory:
Collaboration diagram for SerialKeyNodeFactory:Public Member Functions | |
| SerialKeyNodeFactory (TileBuilder *builder, const OSGTerrainOptions &options, const MapInfo &mapInfo, Terrain *terrain, UID engineUID) | |
| osg::Node * | createNode (const TileKey &key) |
Protected Member Functions | |
| void | addTile (Tile *tile, bool tileHasRealData, bool tileHasLodBlending, osg::Group *parent) |
Protected Attributes | |
| TileBuilder * | _builder |
| const OSGTerrainOptions & | _options |
| const MapInfo | _mapInfo |
| Terrain * | _terrain |
| UID | _engineUID |
Definition at line 29 of file SerialKeyNodeFactory.
| SerialKeyNodeFactory::SerialKeyNodeFactory | ( | TileBuilder * | builder, |
| const OSGTerrainOptions & | options, | ||
| const MapInfo & | mapInfo, | ||
| Terrain * | terrain, | ||
| UID | engineUID | ||
| ) |
Definition at line 35 of file SerialKeyNodeFactory.cpp.
: _builder( builder ), _options( options ), _mapInfo( mapInfo ), _terrain( terrain ), _engineUID( engineUID ) { //NOP }
| void SerialKeyNodeFactory::addTile | ( | Tile * | tile, |
| bool | tileHasRealData, | ||
| bool | tileHasLodBlending, | ||
| osg::Group * | parent | ||
| ) | [protected] |
Definition at line 50 of file SerialKeyNodeFactory.cpp.
{
// associate this tile with the terrain:
tile->setTerrainTechnique( _terrain->cloneTechnique() );
tile->attachToTerrain( _terrain );
// assemble a URI for this tile's child group:
std::stringstream buf;
buf << tile->getKey().str() << "." << _engineUID << ".osgearth_osgterrain_tile";
std::string uri; uri = buf.str();
osg::Node* result = 0L;
// Only add the next tile if it hasn't been blacklisted
bool wrapInPagedLOD =
tileHasRealData &&
!osgEarth::Registry::instance()->isBlacklisted( uri ) &&
tile->getKey().getLevelOfDetail() < (unsigned)*_options.maxLOD();
if ( wrapInPagedLOD )
{
osg::BoundingSphere bs = tile->getBound();
double maxRange = 1e10;
double minRange = bs.radius() * _options.minTileRangeFactor().value();
// create a PLOD so we can keep subdividing:
osg::PagedLOD* plod = new osg::PagedLOD();
plod->setCenter( bs.center() );
plod->addChild( tile, minRange, maxRange );
plod->setFileName( 1, uri );
plod->setRange ( 1, 0, minRange );
plod->setUserData( new MapNode::TileRangeData(minRange, maxRange) );
#if USE_FILELOCATIONCALLBACK
osgDB::Options* options = new osgDB::Options;
options->setFileLocationCallback( new FileLocationCallback() );
plod->setDatabaseOptions( options );
#endif
result = plod;
if ( tileHasLodBlending )
{
// Make the LOD transition distance, and a measure of how
// close the tile is to an LOD change, to shaders.
result->addCullCallback(new Drivers::LODFactorCallback);
}
}
else
{
result = tile;
}
// this cull callback dynamically adjusts the LOD scale based on distance-to-camera:
if ( _options.lodFallOff().isSet() && *_options.lodFallOff() > 0.0 )
{
result->addCullCallback( new DynamicLODScaleCallback(*_options.lodFallOff()) );
}
// this one rejects back-facing tiles:
if ( _mapInfo.isGeocentric() )
{
result->addCullCallback( HeightFieldUtils::createClusterCullingCallback(
static_cast<osgTerrain::HeightFieldLayer*>(tile->getElevationLayer())->getHeightField(),
tile->getLocator()->getEllipsoidModel(),
tile->getVerticalScale() ) );
}
parent->addChild( result );
}
Here is the call graph for this function:
Here is the caller graph for this function:| osg::Node * SerialKeyNodeFactory::createNode | ( | const TileKey & | key | ) | [virtual] |
Implements KeyNodeFactory.
Reimplemented in ParallelKeyNodeFactory.
Definition at line 124 of file SerialKeyNodeFactory.cpp.
{
osg::ref_ptr<Tile> tiles[4];
bool realData[4];
bool lodBlending[4];
bool tileHasAnyRealData = false;
for( unsigned i = 0; i < 4; ++i )
{
TileKey child = key.createChildKey( i );
_builder->createTile( child, false, tiles[i], realData[i], lodBlending[i] );
if ( tiles[i].valid() && realData[i] )
tileHasAnyRealData = true;
}
osg::Group* root = 0L;
if ( tileHasAnyRealData )
{
// Now postprocess them and assemble into a tile group.
root = new osg::Group();
for( unsigned i = 0; i < 4; ++i )
{
if ( tiles[i].valid() )
{
addTile( tiles[i].get(), realData[i], lodBlending[i], root );
}
}
}
return root;
}
Here is the call graph for this function:TileBuilder* SerialKeyNodeFactory::_builder [protected] |
Definition at line 44 of file SerialKeyNodeFactory.
UID SerialKeyNodeFactory::_engineUID [protected] |
Definition at line 48 of file SerialKeyNodeFactory.
const MapInfo SerialKeyNodeFactory::_mapInfo [protected] |
Definition at line 46 of file SerialKeyNodeFactory.
const OSGTerrainOptions& SerialKeyNodeFactory::_options [protected] |
Definition at line 45 of file SerialKeyNodeFactory.
Terrain* SerialKeyNodeFactory::_terrain [protected] |
Definition at line 47 of file SerialKeyNodeFactory.
1.7.3