void OSGTerrainEngineNode::addElevationLayer( ElevationLayer* layer ) { if ( !layer ) return; layer->addCallback( _elevationCallback.get() ); if (!_isStreaming) { refresh(); } else { TileVector tiles; _terrain->getTiles( tiles ); OE_DEBUG << LC << "Found " << tiles.size() << std::endl; for (TileVector::iterator itr = tiles.begin(); itr != tiles.end(); ++itr) { updateElevation( itr->get() ); } } }
void OSGTerrainEngineNode::removeElevationLayer( ElevationLayer* layerRemoved ) { TileVector tiles; _terrain->getTiles( tiles ); for (TileVector::iterator itr = tiles.begin(); itr != tiles.end(); ++itr) { updateElevation( itr->get() ); } }
void OSGTerrainEngineNode::moveElevationLayer( unsigned int oldIndex, unsigned int newIndex ) { TileVector tiles; _terrain->getTiles( tiles ); OE_DEBUG << "Found " << tiles.size() << std::endl; for (TileVector::iterator itr = tiles.begin(); itr != tiles.end(); ++itr) { updateElevation( itr->get() ); } }
void OSGTerrainEngineNode::moveImageLayer( unsigned int oldIndex, unsigned int newIndex ) { // take a thread-safe copy of the tile table TileVector tiles; _terrain->getTiles( tiles ); for (TileVector::iterator itr = tiles.begin(); itr != tiles.end(); ++itr) { Tile* tile = itr->get(); tile->applyImmediateTileUpdate( TileUpdate::MOVE_IMAGE_LAYER ); } updateTextureCombining(); }
void OSGTerrainEngineNode::addElevationLayer( ElevationLayer* layer ) { if ( !layer || !layer->getTileSource() ) return; TileVector tiles; _terrain->getTiles( tiles ); OE_DEBUG << LC << "Found " << tiles.size() << std::endl; for (TileVector::iterator itr = tiles.begin(); itr != tiles.end(); ++itr) { updateElevation( itr->get() ); } }
void OSGTerrainEngineNode::removeImageLayer( ImageLayer* layerRemoved ) { // make a thread-safe copy of the tile table TileVector tiles; _terrain->getTiles( tiles ); for (TileVector::iterator itr = tiles.begin(); itr != tiles.end(); ++itr) { Tile* tile = itr->get(); // critical section tile->removeCustomColorLayer( layerRemoved->getUID() ); } updateTextureCombining(); }
// immediately release GL memory for any expired tiles. // called from the DRAW thread (QuickReleaseGLCallback). void TerrainNode::releaseGLObjectsForTiles(osg::State* state) { OpenThreads::ScopedLock<Mutex> lock( _tilesToReleaseMutex ); for( TileVector::iterator i = _tilesToRelease.begin(); i != _tilesToRelease.end(); ++i ) { i->get()->releaseGLObjects( state ); } _tilesToRelease.clear(); //while( _tilesToRelease.size() > 0 ) //{ // _tilesToRelease.front()->releaseGLObjects( state ); // _tilesToRelease.pop(); //} }
void OSGTerrainEngineNode::removeElevationLayer( ElevationLayer* layerRemoved ) { layerRemoved->removeCallback( _elevationCallback.get() ); if (!_isStreaming) { refresh(); } else { TileVector tiles; _terrain->getTiles( tiles ); for (TileVector::iterator itr = tiles.begin(); itr != tiles.end(); ++itr) { updateElevation( itr->get() ); } } }
void QuadTreeTerrainEngineNode::moveElevationLayer( unsigned int oldIndex, unsigned int newIndex ) { if (!_isStreaming) { refresh(); } else { TileVector tiles; _terrain->getTiles( tiles ); OE_DEBUG << "Found " << tiles.size() << std::endl; for (TileVector::iterator itr = tiles.begin(); itr != tiles.end(); ++itr) { updateElevation( itr->get() ); } } }
void OSGTerrainEngineNode::addImageLayer( ImageLayer* layerAdded ) { if ( !layerAdded ) return; if (!_isStreaming) { refresh(); } else { // visit all existing terrain tiles and inform each one of the new image layer: TileVector tiles; _terrain->getTiles( tiles ); for( TileVector::iterator itr = tiles.begin(); itr != tiles.end(); ++itr ) { Tile* tile = itr->get(); StreamingTile* streamingTile = 0L; GeoImage geoImage; bool needToUpdateImagery = false; int imageLOD = -1; if ( !_isStreaming || tile->getKey().getLevelOfDetail() == 1 ) { // in standard mode, or at the first LOD in seq/pre mode, fetch the image immediately. TileKey geoImageKey = tile->getKey(); _tileFactory->createValidGeoImage( layerAdded, tile->getKey(), geoImage, geoImageKey ); imageLOD = tile->getKey().getLevelOfDetail(); } else { // in seq/pre mode, set up a placeholder and mark the tile as dirty. geoImage = GeoImage(ImageUtils::createEmptyImage(), tile->getKey().getExtent() ); needToUpdateImagery = true; streamingTile = static_cast<StreamingTile*>(tile); } if (geoImage.valid()) { const MapInfo& mapInfo = _update_mapf->getMapInfo(); double img_min_lon, img_min_lat, img_max_lon, img_max_lat; geoImage.getExtent().getBounds(img_min_lon, img_min_lat, img_max_lon, img_max_lat); //Specify a new locator for the color with the coordinates of the TileKey that was actually used to create the image osg::ref_ptr<GeoLocator> img_locator = tile->getKey().getProfile()->getSRS()->createLocator( img_min_lon, img_min_lat, img_max_lon, img_max_lat, !mapInfo.isGeocentric() ); //Set the CS to geocentric if we are dealing with a geocentric map if ( mapInfo.isGeocentric() ) { img_locator->setCoordinateSystemType( osgTerrain::Locator::GEOCENTRIC ); } tile->setCustomColorLayer( CustomColorLayer( layerAdded, geoImage.getImage(), img_locator.get(), imageLOD, tile->getKey() ) ); // if necessary, tell the tile to queue up a new imagery request (since we // just installed a placeholder) if ( needToUpdateImagery ) { streamingTile->updateImagery( layerAdded, *_update_mapf, _tileFactory.get() ); } } else { // this can happen if there's no data in the new layer for the given tile. // we will rely on the driver to dump out a warning if this is an error. } tile->applyImmediateTileUpdate( TileUpdate::ADD_IMAGE_LAYER, layerAdded->getUID() ); } updateTextureCombining(); } }