本文整理汇总了C++中elevationlayervector::const_iterator::get方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::get方法的具体用法?C++ const_iterator::get怎么用?C++ const_iterator::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elevationlayervector::const_iterator
的用法示例。
在下文中一共展示了const_iterator::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ElevationLayer*
Map::getElevationLayerByName( const std::string& name ) const
{
Threading::ScopedReadLock( const_cast<Map*>(this)->_mapDataMutex );
for( ElevationLayerVector::const_iterator i = _elevationLayers.begin(); i != _elevationLayers.end(); ++i )
if ( i->get()->getName() == name )
return i->get();
return 0L;
}
示例2: lock
int
Map::getElevationLayers( ElevationLayerVector& out_list, bool validLayersOnly ) const
{
out_list.reserve( _elevationLayers.size() );
Threading::ScopedReadLock lock( const_cast<Map*>(this)->_mapDataMutex );
for( ElevationLayerVector::const_iterator i = _elevationLayers.begin(); i != _elevationLayers.end(); ++i )
if ( !validLayersOnly || i->get()->getProfile() )
out_list.push_back( i->get() );
return _dataModelRevision;
}
示例3: mapConf
Config
EarthFileSerializer2::serialize( MapNode* input ) const
{
Config mapConf("map");
mapConf.set("version", "2");
if ( !input || !input->getMap() )
return mapConf;
Map* map = input->getMap();
MapFrame mapf( map, Map::ENTIRE_MODEL );
// the map and node options:
Config optionsConf = map->getInitialMapOptions().getConfig();
optionsConf.merge( input->getMapNodeOptions().getConfig() );
mapConf.add( "options", optionsConf );
// the layers
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
//Config layerConf = layer->getInitialOptions().getConfig();
Config layerConf = layer->getImageLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getInitialOptions().driver()->getDriver());
mapConf.add( "image", layerConf );
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); ++i )
{
ElevationLayer* layer = i->get();
//Config layerConf = layer->getInitialOptions().getConfig();
Config layerConf = layer->getElevationLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getInitialOptions().driver()->getDriver());
mapConf.add( "elevation", layerConf );
}
for( ModelLayerVector::const_iterator i = mapf.modelLayers().begin(); i != mapf.modelLayers().end(); ++i )
{
ModelLayer* layer = i->get();
Config layerConf = layer->getModelLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getModelLayerOptions().driver()->getDriver());
mapConf.add( "model", layerConf );
}
Config ext = input->externalConfig();
if ( !ext.empty() )
{
ext.key() = "external";
mapConf.add( ext );
}
return mapConf;
}
示例4:
bool
MapFrame::isCached( const TileKey& key ) const
{
//Check to see if the tile will load fast
// Check the imagery layers
for( ImageLayerVector::const_iterator i = imageLayers().begin(); i != imageLayers().end(); i++ )
{
//If we're cache only we should be fast
if (i->get()->isCacheOnly()) continue;
osg::ref_ptr< TileSource > source = i->get()->getTileSource();
if (!source.valid()) continue;
//If the tile is blacklisted, it should also be fast.
if ( source->getBlacklist()->contains( key.getTileId() ) ) continue;
//If no data is available on this tile, we'll be fast
if ( !source->hasData( key ) ) continue;
if ( !i->get()->isCached( key ) ) return false;
}
for( ElevationLayerVector::const_iterator i = elevationLayers().begin(); i != elevationLayers().end(); ++i )
{
//If we're cache only we should be fast
if (i->get()->isCacheOnly()) continue;
osg::ref_ptr< TileSource > source = i->get()->getTileSource();
if (!source.valid()) continue;
//If the tile is blacklisted, it should also be fast.
if ( source->getBlacklist()->contains( key.getTileId() ) ) continue;
if ( !source->hasData( key ) ) continue;
if ( !i->get()->isCached( key ) )
{
return false;
}
}
return true;
}
示例5: MapFrame
void
OSGTerrainEngineNode::postInitialize( const Map* map, const TerrainOptions& options )
{
TerrainEngineNode::postInitialize( map, options );
// Initialize the map frames. We need one for the update thread and one for the
// cull thread. Someday we can detect whether these are actually the same thread
// (depends on the viewer's threading mode).
_update_mapf = new MapFrame( map, Map::MASKED_TERRAIN_LAYERS, "osgterrain-update" );
_cull_mapf = new MapFrame( map, Map::TERRAIN_LAYERS, "osgterrain-cull" );
// merge in the custom options:
_terrainOptions.merge( options );
// handle an already-established map profile:
if ( _update_mapf->getProfile() )
{
// NOTE: this will initialize the map with the startup layers
onMapInfoEstablished( MapInfo(map) );
}
// populate the terrain with whatever data is in the map to begin with:
if ( _terrain )
{
// update the terrain revision in threaded mode
if ( _isStreaming )
{
static_cast<StreamingTerrainNode*>(_terrain)->updateTaskServiceThreads( *_update_mapf );
}
updateTextureCombining();
}
// install a layer callback for processing further map actions:
map->addMapCallback( new OSGTerrainEngineNodeMapCallbackProxy(this) );
//Attach to all of the existing elevation layers
ElevationLayerVector elevationLayers;
map->getElevationLayers( elevationLayers );
for( ElevationLayerVector::const_iterator i = elevationLayers.begin(); i != elevationLayers.end(); ++i )
{
i->get()->addCallback( _elevationCallback.get() );
}
//Attach a callback to all of the
// register me.
registerEngine( this );
// now that we have a map, set up to recompute the bounds
dirtyBound();
}
示例6:
void
ElevationManager::sync()
{
if ( _mapf.sync() || _tileSize == 0 || _maxDataLevel == 0 )
{
_tileSize = 0;
_maxDataLevel = 0;
for( ElevationLayerVector::const_iterator i = _mapf.elevationLayers().begin(); i != _mapf.elevationLayers().end(); ++i )
{
// we need the maximum tile size
int layerTileSize = i->get()->getTileSize();
if ( layerTileSize > _tileSize )
_tileSize = layerTileSize;
// we also need the maximum available data level.
unsigned int layerMaxDataLevel = i->get()->getMaxDataLevel();
if ( layerMaxDataLevel > _maxDataLevel )
_maxDataLevel = layerMaxDataLevel;
}
}
}
示例7:
bool
OSGTileFactory::hasMoreLevels( Map* map, const TileKey& key )
{
//Threading::ScopedReadLock lock( map->getMapDataMutex() );
bool more_levels = false;
ImageLayerVector imageLayers;
map->getImageLayers( imageLayers );
for ( ImageLayerVector::const_iterator i = imageLayers.begin(); i != imageLayers.end(); i++ )
{
const ImageLayerOptions& opt = i->get()->getImageLayerOptions();
if ( !opt.maxLevel().isSet() || key.getLevelOfDetail() < (unsigned int)*opt.maxLevel() )
{
more_levels = true;
break;
}
}
if ( !more_levels )
{
ElevationLayerVector elevLayers;
map->getElevationLayers( elevLayers );
for( ElevationLayerVector::const_iterator j = elevLayers.begin(); j != elevLayers.end(); j++ )
{
const ElevationLayerOptions& opt = j->get()->getElevationLayerOptions();
if ( !opt.maxLevel().isSet() || key.getLevelOfDetail() < (unsigned int)*opt.maxLevel() )
//if ( !j->get()->maxLevel().isSet() || key.getLevelOfDetail() < j->get()->maxLevel().get() )
{
more_levels = true;
break;
}
}
}
return more_levels;
}
示例8: getElevationTaskService
void
StreamingTerrainNode::updateTaskServiceThreads( const MapFrame& mapf )
{
//Get the maximum elevation weight
float elevationWeight = 0.0f;
for (ElevationLayerVector::const_iterator itr = mapf.elevationLayers().begin(); itr != mapf.elevationLayers().end(); ++itr)
{
ElevationLayer* layer = itr->get();
float w = layer->getElevationLayerOptions().loadingWeight().value();
if (w > elevationWeight) elevationWeight = w;
}
float totalImageWeight = 0.0f;
for (ImageLayerVector::const_iterator itr = mapf.imageLayers().begin(); itr != mapf.imageLayers().end(); ++itr)
{
totalImageWeight += itr->get()->getImageLayerOptions().loadingWeight().value();
}
float totalWeight = elevationWeight + totalImageWeight;
if (elevationWeight > 0.0f)
{
//Determine how many threads each layer gets
int numElevationThreads = (int)osg::round((float)_numLoadingThreads * (elevationWeight / totalWeight ));
OE_INFO << LC << "Elevation Threads = " << numElevationThreads << std::endl;
getElevationTaskService()->setNumThreads( numElevationThreads );
}
for (ImageLayerVector::const_iterator itr = mapf.imageLayers().begin(); itr != mapf.imageLayers().end(); ++itr)
{
const TerrainLayerOptions& opt = itr->get()->getImageLayerOptions();
int imageThreads = (int)osg::round((float)_numLoadingThreads * (opt.loadingWeight().value() / totalWeight ));
OE_INFO << LC << "Image Threads for " << itr->get()->getName() << " = " << imageThreads << std::endl;
getImageryTaskService( itr->get()->getUID() )->setNumThreads( imageThreads );
}
}
示例9: usage
int
purge( osg::ArgumentParser& args )
{
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles( args );
if ( !node.valid() )
return usage( "Failed to read .earth file." );
MapNode* mapNode = MapNode::findMapNode( node.get() );
if ( !mapNode )
return usage( "Input file was not a .earth file" );
Map* map = mapNode->getMap();
if ( !map->getCache() )
return message( "Earth file does not contain a cache." );
std::vector<Entry> entries;
ImageLayerVector imageLayers;
map->getLayers( imageLayers );
for( ImageLayerVector::const_iterator i = imageLayers.begin(); i != imageLayers.end(); ++i )
{
ImageLayer* layer = i->get();
bool useMFP =
layer->getProfile() &&
layer->getProfile()->getSRS()->isSphericalMercator() &&
mapNode->getMapNodeOptions().getTerrainOptions().enableMercatorFastPath() == true;
const Profile* cacheProfile = useMFP ? layer->getProfile() : map->getProfile();
CacheSettings* cacheSettings = layer->getCacheSettings();
if (cacheSettings)
{
CacheBin* bin = cacheSettings->getCacheBin();
if ( bin )
{
entries.push_back(Entry());
entries.back()._isImage = true;
entries.back()._name = i->get()->getName();
entries.back()._bin = bin;
}
}
}
ElevationLayerVector elevationLayers;
map->getLayers( elevationLayers );
for( ElevationLayerVector::const_iterator i = elevationLayers.begin(); i != elevationLayers.end(); ++i )
{
ElevationLayer* layer = i->get();
bool useMFP =
layer->getProfile() &&
layer->getProfile()->getSRS()->isSphericalMercator() &&
mapNode->getMapNodeOptions().getTerrainOptions().enableMercatorFastPath() == true;
const Profile* cacheProfile = useMFP ? layer->getProfile() : map->getProfile();
CacheSettings* cacheSettings = layer->getCacheSettings();
if (cacheSettings)
{
CacheBin* bin = cacheSettings->getCacheBin();
if (bin)
{
entries.push_back(Entry());
entries.back()._isImage = false;
entries.back()._name = i->get()->getName();
entries.back()._bin = bin;
}
}
}
if ( entries.size() > 0 )
{
std::cout << std::endl;
for( unsigned i=0; i<entries.size(); ++i )
{
std::cout << (i+1) << ") " << entries[i]._name << " (" << (entries[i]._isImage? "image" : "elevation" ) << ")" << std::endl;
}
std::cout
<< std::endl
<< "Enter number of cache to purge, or <enter> to quit: "
<< std::flush;
std::string input;
std::getline( std::cin, input );
if ( !input.empty() )
{
unsigned k = as<unsigned>(input, 0L);
if ( k > 0 && k <= entries.size() )
{
Config meta = entries[k-1]._bin->readMetadata();
if ( !meta.empty() )
{
std::cout
<< std::endl
//.........这里部分代码省略.........
示例10:
bool
MapFrame::isCached( const TileKey& key ) const
{
// is there a map cache at all?
if ( _map->getCache() == 0L )
return false;
//Check to see if the tile will load fast
// Check the imagery layers
for( ImageLayerVector::const_iterator i = imageLayers().begin(); i != imageLayers().end(); i++ )
{
const ImageLayer* layer = i->get();
if (!layer->getEnabled())
continue;
// If we're cache only we should be fast
if (layer->isCacheOnly())
continue;
// no-cache mode? always slow
if (layer->isNoCache())
return false;
// No tile source? skip it
osg::ref_ptr< TileSource > source = layer->getTileSource();
if (!source.valid())
continue;
//If the tile is blacklisted, it should also be fast.
if ( source->getBlacklist()->contains( key ) )
continue;
//If no data is available on this tile, we'll be fast
if ( !source->hasData( key ) )
continue;
if ( !layer->isCached(key) )
return false;
}
for( ElevationLayerVector::const_iterator i = elevationLayers().begin(); i != elevationLayers().end(); ++i )
{
const ElevationLayer* layer = i->get();
if (!layer->getEnabled())
continue;
//If we're cache only we should be fast
if (layer->isCacheOnly())
continue;
// no-cache mode? always high-latency.
if (layer->isNoCache())
return false;
osg::ref_ptr< TileSource > source = layer->getTileSource();
if (!source.valid())
continue;
//If the tile is blacklisted, it should also be fast.
if ( source->getBlacklist()->contains( key ) )
continue;
if ( !source->hasData( key ) )
continue;
if ( !i->get()->isCached( key ) )
return false;
}
return true;
}
示例11: MapFrame
void
MPTerrainEngineNode::postInitialize( const Map* map, const TerrainOptions& options )
{
TerrainEngineNode::postInitialize( map, options );
// Initialize the map frames. We need one for the update thread and one for the
// cull thread. Someday we can detect whether these are actually the same thread
// (depends on the viewer's threading mode).
_update_mapf = new MapFrame( map, Map::MASKED_TERRAIN_LAYERS, "mp-update" );
// merge in the custom options:
_terrainOptions.merge( options );
// A shared registry for tile nodes in the scene graph. Enable revision tracking
// if requested in the options. Revision tracking lets the registry notify all
// live tiles of the current map revision so they can inrementally update
// themselves if necessary.
_liveTiles = new TileNodeRegistry("live");
_liveTiles->setRevisioningEnabled( _terrainOptions.incrementalUpdate() == true );
_liveTiles->setMapRevision( _update_mapf->getRevision() );
// set up a registry for quick release:
if ( _terrainOptions.quickReleaseGLObjects() == true )
{
_deadTiles = new TileNodeRegistry("dead");
}
// initialize the model factory:
_tileModelFactory = new TileModelFactory(_liveTiles.get(), _terrainOptions );
// handle an already-established map profile:
if ( _update_mapf->getProfile() )
{
// NOTE: this will initialize the map with the startup layers
onMapInfoEstablished( MapInfo(map) );
}
// install a layer callback for processing further map actions:
map->addMapCallback( new MPTerrainEngineNodeMapCallbackProxy(this) );
// Prime with existing layers:
_batchUpdateInProgress = true;
ElevationLayerVector elevationLayers;
map->getElevationLayers( elevationLayers );
for( ElevationLayerVector::const_iterator i = elevationLayers.begin(); i != elevationLayers.end(); ++i )
addElevationLayer( i->get() );
ImageLayerVector imageLayers;
map->getImageLayers( imageLayers );
for( ImageLayerVector::iterator i = imageLayers.begin(); i != imageLayers.end(); ++i )
addImageLayer( i->get() );
_batchUpdateInProgress = false;
// install some terrain-wide uniforms
this->getOrCreateStateSet()->getOrCreateUniform(
"oe_min_tile_range_factor",
osg::Uniform::FLOAT)->set( *_terrainOptions.minTileRangeFactor() );
// set up the initial shaders
updateState();
// register this instance to the osgDB plugin can find it.
registerEngine( this );
// now that we have a map, set up to recompute the bounds
dirtyBound();
OE_INFO << LC << "Edge normalization is " << (_terrainOptions.normalizeEdges() == true? "ON" : "OFF") << std::endl;
}
示例12: getProfile
bool
MapFrame::isCached( const osgEarth::TileKey& key ) const
{
const Profile* mapProfile = getProfile();
//Check the imagery layers
for( ImageLayerVector::const_iterator i = imageLayers().begin(); i != imageLayers().end(); i++ )
{
ImageLayer* layer = i->get();
osg::ref_ptr< Cache > cache = layer->getCache();
if ( !cache.valid() || !layer->getProfile() )
return false;
std::vector< TileKey > keys;
if ( mapProfile->isEquivalentTo( layer->getProfile() ) )
{
keys.push_back( key );
}
else
{
layer->getProfile()->getIntersectingTiles( key, keys );
}
for (unsigned int j = 0; j < keys.size(); ++j)
{
if ( layer->isKeyValid( keys[j] ) )
{
if ( !cache->isCached( keys[j], layer->getCacheSpec() ) )
{
return false;
}
}
}
}
for( ElevationLayerVector::const_iterator i = elevationLayers().begin(); i != elevationLayers().end(); ++i )
{
ElevationLayer* layer = i->get();
osg::ref_ptr< Cache > cache = layer->getCache();
if ( !cache.valid() || !layer->getProfile() )
return false;
std::vector<TileKey> keys;
if ( mapProfile->isEquivalentTo( layer->getProfile() ) )
{
keys.push_back( key );
}
else
{
layer->getProfile()->getIntersectingTiles( key, keys );
}
for (unsigned int j = 0; j < keys.size(); ++j)
{
if ( layer->isKeyValid( keys[j] ) )
{
if ( !cache->isCached( keys[j], layer->getCacheSpec() ) )
{
return false;
}
}
}
}
return true;
}
示例13: mapConf
Config
EarthFileSerializer2::serialize(const MapNode* input, const std::string& referrer) const
{
Config mapConf("map");
mapConf.set("version", "2");
if ( !input || !input->getMap() )
return mapConf;
const Map* map = input->getMap();
MapFrame mapf( map, Map::ENTIRE_MODEL );
// the map and node options:
Config optionsConf = map->getInitialMapOptions().getConfig();
optionsConf.merge( input->getMapNodeOptions().getConfig() );
mapConf.add( "options", optionsConf );
// the layers
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); ++i )
{
ImageLayer* layer = i->get();
//Config layerConf = layer->getInitialOptions().getConfig();
Config layerConf = layer->getImageLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getInitialOptions().driver()->getDriver());
mapConf.add( "image", layerConf );
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); ++i )
{
ElevationLayer* layer = i->get();
//Config layerConf = layer->getInitialOptions().getConfig();
Config layerConf = layer->getElevationLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getInitialOptions().driver()->getDriver());
mapConf.add( "elevation", layerConf );
}
for( ModelLayerVector::const_iterator i = mapf.modelLayers().begin(); i != mapf.modelLayers().end(); ++i )
{
ModelLayer* layer = i->get();
Config layerConf = layer->getModelLayerOptions().getConfig();
layerConf.set("name", layer->getName());
layerConf.set("driver", layer->getModelLayerOptions().driver()->getDriver());
mapConf.add( "model", layerConf );
}
Config ext = input->externalConfig();
if ( !ext.empty() )
{
ext.key() = "extensions";
mapConf.add( ext );
}
#if 1 // removed until it can be debugged.
// Re-write pathnames in the Config so they are relative to the new referrer.
if ( _rewritePaths && !referrer.empty() )
{
RewritePaths rewritePaths( referrer );
rewritePaths.setRewriteAbsolutePaths( _rewriteAbsolutePaths );
rewritePaths.apply( mapConf );
}
#endif
return mapConf;
}
示例14: seed
void CacheSeed::seed( Map* map )
{
if ( !map->getCache() )
{
OE_WARN << LC << "Warning: No cache defined; aborting." << std::endl;
return;
}
std::vector<TileKey> keys;
map->getProfile()->getRootKeys(keys);
//Add the map's entire extent if we don't have one specified.
if (_extents.empty())
{
addExtent( map->getProfile()->getExtent() );
}
bool hasCaches = false;
int src_min_level = INT_MAX;
unsigned int src_max_level = 0;
MapFrame mapf( map, Map::TERRAIN_LAYERS, "CacheSeed::seed" );
//Assumes the the TileSource will perform the caching for us when we call createImage
for( ImageLayerVector::const_iterator i = mapf.imageLayers().begin(); i != mapf.imageLayers().end(); i++ )
{
ImageLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ImageLayerOptions& opt = layer->getImageLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if ( !src )
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
for( ElevationLayerVector::const_iterator i = mapf.elevationLayers().begin(); i != mapf.elevationLayers().end(); i++ )
{
ElevationLayer* layer = i->get();
TileSource* src = layer->getTileSource();
const ElevationLayerOptions& opt = layer->getElevationLayerOptions();
if ( layer->isCacheOnly() )
{
OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" is set to cache-only; skipping." << std::endl;
}
else if (!src)
{
OE_WARN << "Warning: Layer \"" << layer->getName() << "\" could not create TileSource; skipping." << std::endl;
}
//else if ( src->getCachePolicyHint(0L) == CachePolicy::NO_CACHE )
//{
// OE_WARN << LC << "Warning: Layer \"" << layer->getName() << "\" does not support seeding; skipping." << std::endl;
//}
else if ( !layer->getCache() )
{
OE_WARN << LC << "Notice: Layer \"" << layer->getName() << "\" has no cache defined; skipping." << std::endl;
}
else
{
hasCaches = true;
if (opt.minLevel().isSet() && (int)opt.minLevel().get() < src_min_level)
src_min_level = opt.minLevel().get();
if (opt.maxLevel().isSet() && opt.maxLevel().get() > src_max_level)
src_max_level = opt.maxLevel().get();
}
}
if ( !hasCaches )
{
OE_WARN << LC << "There are either no caches defined in the map, or no sources to cache; aborting." << std::endl;
return;
}
if ( src_max_level > 0 && src_max_level < _maxLevel )
{
_maxLevel = src_max_level;
//.........这里部分代码省略.........
示例15: MapFrame
void
MPTerrainEngineNode::postInitialize( const Map* map, const TerrainOptions& options )
{
TerrainEngineNode::postInitialize( map, options );
// Initialize the map frames. We need one for the update thread and one for the
// cull thread. Someday we can detect whether these are actually the same thread
// (depends on the viewer's threading mode).
_update_mapf = new MapFrame( map, Map::MASKED_TERRAIN_LAYERS, "mp-update" );
// merge in the custom options:
_terrainOptions.merge( options );
// a shared registry for tile nodes in the scene graph.
_liveTiles = new TileNodeRegistry("live");
// set up a registry for quick release:
if ( _terrainOptions.quickReleaseGLObjects() == true )
{
_deadTiles = new TileNodeRegistry("dead");
}
// initialize the model factory:
_tileModelFactory = new TileModelFactory(getMap(), _liveTiles.get(), _terrainOptions );
// handle an already-established map profile:
if ( _update_mapf->getProfile() )
{
// NOTE: this will initialize the map with the startup layers
onMapInfoEstablished( MapInfo(map) );
}
// populate the terrain with whatever data is in the map to begin with:
if ( _terrain )
{
// reserve a GPU image unit and two attribute indexes.
this->getTextureCompositor()->reserveTextureImageUnit( _primaryUnit );
this->getTextureCompositor()->reserveTextureImageUnit( _secondaryUnit );
//this->getTextureCompositor()->reserveAttribIndex( _attribIndex1 );
//this->getTextureCompositor()->reserveAttribIndex( _attribIndex2 );
}
// install a layer callback for processing further map actions:
map->addMapCallback( new MPTerrainEngineNodeMapCallbackProxy(this) );
// Prime with existing layers:
_batchUpdateInProgress = true;
ElevationLayerVector elevationLayers;
map->getElevationLayers( elevationLayers );
for( ElevationLayerVector::const_iterator i = elevationLayers.begin(); i != elevationLayers.end(); ++i )
addElevationLayer( i->get() );
ImageLayerVector imageLayers;
map->getImageLayers( imageLayers );
for( ImageLayerVector::iterator i = imageLayers.begin(); i != imageLayers.end(); ++i )
addImageLayer( i->get() );
_batchUpdateInProgress = false;
//{
// i->get()->addCallback( _elevationCallback.get() );
//}
// install some terrain-wide uniforms
this->getOrCreateStateSet()->getOrCreateUniform(
"oe_min_tile_range_factor",
osg::Uniform::FLOAT)->set( *_terrainOptions.minTileRangeFactor() );
// set up the initial shaders
updateShaders();
// register this instance to the osgDB plugin can find it.
registerEngine( this );
// now that we have a map, set up to recompute the bounds
dirtyBound();
}