本文整理汇总了C++中TileNode类的典型用法代码示例。如果您正苦于以下问题:C++ TileNode类的具体用法?C++ TileNode怎么用?C++ TileNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TileNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawAll
void TileStack::drawAll(GWindow& window) const {
TileNode* p = front;
while (p!= NULL) {
p->draw(window);
p = p->next;
}
}
示例2: exclusive
void
TilePagedLOD::traverse(osg::NodeVisitor& nv)
{
// Only traverse the TileNode if our neighbors (the other members of
// our group of four) are ready as well.
if ( _children.size() > 0 )
{
_children[0]->setNodeMask( _familyReady ? ~0 : 0 );
// find our tile node:
TileNode* tilenode = dynamic_cast<TileGroup*>(_children[0].get()) ?
static_cast<TileGroup*>(_children[0].get())->getTileNode() :
static_cast<TileNode*>(_children[0].get());
// Check whether the TileNode is marked dirty. If so, install a new pager request
// to reload and replace the TileNode.
if (nv.getVisitorType() == nv.CULL_VISITOR &&
this->getNumFileNames() < 2 &&
tilenode->isOutOfDate() )
{
// lock keeps multiple CullVisitors from doing the same thing
Threading::ScopedMutexLock exclusive( _updateMutex );
if ( this->getNumFileNames() < 2 ) // double-check pattern
{
//OE_WARN << LC << "Queuing request for replacement: " << _container->getTileNode()->getKey().str() << std::endl;
this->setFileName( 1, Stringify() << _prefix << ".osgearth_engine_mp_standalone_tile" );
this->setRange( 1, 0, FLT_MAX );
}
}
}
osg::PagedLOD::traverse( nv );
}
示例3: lowerLeft
osg::Node*
SingleKeyNodeFactory::createTile(TileModel* model, bool setupChildrenIfNecessary)
{
// compile the model into a node:
TileNode* tileNode = _modelCompiler->compile( model, _frame );
// see if this tile might have children.
bool prepareForChildren =
setupChildrenIfNecessary &&
model->_tileKey.getLOD() < *_options.maxLOD();
osg::Node* result = 0L;
if ( prepareForChildren )
{
//Compute the min range based on the 2D size of the tile
osg::BoundingSphere bs = tileNode->getBound();
GeoExtent extent = model->_tileKey.getExtent();
GeoPoint lowerLeft(extent.getSRS(), extent.xMin(), extent.yMin(), 0.0, ALTMODE_ABSOLUTE);
GeoPoint upperRight(extent.getSRS(), extent.xMax(), extent.yMax(), 0.0, ALTMODE_ABSOLUTE);
osg::Vec3d ll, ur;
lowerLeft.toWorld( ll );
upperRight.toWorld( ur );
double radius = (ur - ll).length() / 2.0;
float minRange = (float)(radius * _options.minTileRangeFactor().value());
TilePagedLOD* plod = new TilePagedLOD( _engineUID, _liveTiles, _deadTiles );
plod->setCenter ( bs.center() );
plod->addChild ( tileNode );
plod->setRange ( 0, minRange, FLT_MAX );
plod->setFileName( 1, Stringify() << tileNode->getKey().str() << "." << _engineUID << ".osgearth_engine_mp_tile" );
plod->setRange ( 1, 0, minRange );
#if USE_FILELOCATIONCALLBACK
osgDB::Options* options = Registry::instance()->cloneOrCreateOptions();
options->setFileLocationCallback( new FileLocationCallback() );
plod->setDatabaseOptions( options );
#endif
result = plod;
// this one rejects back-facing tiles:
if ( _frame.getMapInfo().isGeocentric() && _options.clusterCulling() == true )
{
osg::HeightField* hf =
model->_elevationData.getHeightField();
result->addCullCallback( HeightFieldUtils::createClusterCullingCallback(
hf,
tileNode->getKey().getProfile()->getSRS()->getEllipsoid(),
*_options.verticalScale() ) );
}
}
else
{
result = tileNode;
}
return result;
}
示例4: TileNode
void
TileNode::createChildren(EngineContext* context)
{
// NOTE: Ensure that _mutex is locked before calling this function!
//OE_WARN << "Creating children for " << _key.str() << std::endl;
// Create the four child nodes.
for(unsigned quadrant=0; quadrant<4; ++quadrant)
{
TileNode* node = new TileNode();
if (context->getOptions().minExpiryFrames().isSet())
{
node->setMinimumExpirationFrames( *context->getOptions().minExpiryFrames() );
}
if (context->getOptions().minExpiryTime().isSet())
{
node->setMinimumExpirationTime( *context->getOptions().minExpiryTime() );
}
// Build the surface geometry:
node->create( getKey().createChildKey(quadrant), this, context );
// Add to the scene graph.
addChild( node );
}
}
示例5: TileNode
void
TileNode::createChildren(EngineContext* context)
{
// NOTE: Ensure that _mutex is locked before calling this fucntion!
// Create the four child nodes.
for(unsigned quadrant=0; quadrant<4; ++quadrant)
{
TileNode* node = new TileNode();
if (context->getOptions().minExpiryFrames().isSet())
{
node->setMinimumExpiryFrames( *context->getOptions().minExpiryFrames() );
}
if (context->getOptions().minExpiryTime().isSet())
{
node->setMinimumExpiryTime( *context->getOptions().minExpiryTime() );
}
// Build the surface geometry:
node->create( getTileKey().createChildKey(quadrant), context );
// Add to the scene graph.
addChild( node );
// Inherit the samplers with new scale/bias information.
node->inheritState( context );
}
}
示例6: createChildren
void TileNode::loadChildren()
{
_mutex.lock();
if ( !_childrenReady )
{
// Create the children
createChildren( _context.get() );
_childrenReady = true;
int numChildren = getNumChildren();
if ( numChildren > 0 )
{
for(int i=0; i<numChildren; ++i)
{
TileNode* child = getSubTile(i);
if (child)
{
// Load the children's data.
child->loadSync();
}
}
}
}
_mutex.unlock();
}
示例7:
// The osgDB::DatabasePager will call this method when merging a new child
// into the scene graph.
bool
TilePagedLOD::addChild(osg::Node* node)
{
if ( node )
{
// if we see an invalid tile marker, disable the paged lod slot.
if ( dynamic_cast<InvalidTileNode*>(node) )
{
this->setFileName( 1, "" );
this->setRange( 1, 0, 0 );
this->setRange( 0, 0.0f, FLT_MAX );
return true;
}
// If it's a TileNode, this is the simple first addition of the
// static TileNode child (not from the pager).
TileNode* tilenode = dynamic_cast<TileNode*>( node );
if ( tilenode && _live.get() )
{
_live->add( tilenode );
// Listen for out east and south neighbors.
const TileKey& key = tilenode->getKey();
_live->listenFor( key.createNeighborKey(1, 0), tilenode );
_live->listenFor( key.createNeighborKey(0, 1), tilenode );
}
return osg::PagedLOD::addChild( node );
}
return false;
}
示例8: lowerLeft
osg::Node*
SerialKeyNodeFactory::createTile(TileModel* model,
bool tileHasRealData)
{
// compile the model into a node:
TileNode* tileNode = _modelCompiler->compile( model );
// see if this tile might have children.
bool prepareForChildren =
(tileHasRealData || (_options.minLOD().isSet() && model->_tileKey.getLOD() < *_options.minLOD())) &&
model->_tileKey.getLOD() < *_options.maxLOD();
osg::Node* result = 0L;
if ( prepareForChildren )
{
//Compute the min range based on the 2D size of the tile
osg::BoundingSphere bs = tileNode->getBound();
GeoExtent extent = model->_tileKey.getExtent();
GeoPoint lowerLeft(extent.getSRS(), extent.xMin(), extent.yMin(), 0.0, ALTMODE_ABSOLUTE);
GeoPoint upperRight(extent.getSRS(), extent.xMax(), extent.yMax(), 0.0, ALTMODE_ABSOLUTE);
osg::Vec3d ll, ur;
lowerLeft.toWorld( ll );
upperRight.toWorld( ur );
double radius = (ur - ll).length() / 2.0;
float minRange = (float)(radius * _options.minTileRangeFactor().value());
osgDB::Options* dbOptions = Registry::instance()->cloneOrCreateOptions();
TileGroup* plod = new TileGroup(tileNode, _engineUID, _liveTiles.get(), _deadTiles.get(), dbOptions);
plod->setSubtileRange( minRange );
#if USE_FILELOCATIONCALLBACK
dbOptions->setFileLocationCallback( new FileLocationCallback() );
#endif
result = plod;
}
else
{
result = tileNode;
}
// this one rejects back-facing tiles:
if ( _mapInfo.isGeocentric() && _options.clusterCulling() == true )
{
osg::HeightField* hf =
model->_elevationData.getHeightField();
result->addCullCallback( HeightFieldUtils::createClusterCullingCallback(
hf,
tileNode->getKey().getProfile()->getSRS()->getEllipsoid(),
*_options.verticalScale() ) );
}
return result;
}
示例9: addToOpenNode
void PathGenerator::addToOpenNode(int x, int y, adjType adjtype,
TileNode* parent) {
if (x < 0 || y < 0) {
return;
}
if (!canPass(x, y)) {
return;
}
TileNode* node = _nodes[x][y];
if (inPassedNodes(node)) {
return;
} else if (!inOpenNodes(node)) {
_opened_nodes.push_back(node);
int incf;
if (adjtype == Straight)
incf = 10;
else
incf = 14;
node->setG(parent->getG() + incf);
node->setH(descarteDistance(Point(node->getX(), node->getY()), _end) * 10);
node->setF(node->getG() + node->getH());
node->setParent(parent);
}
}
示例10: while
std::vector<Point>* PathGenerator::generatePath(Point start, Point end) {
this->resetTileNodes();
_start = start;
_end = end;
vector<Point>* path = new vector<Point>();
TileNode* startNode = _nodes[int(start.x)][int(start.y)];
startNode->setParent(NULL);
_opened_nodes.push_back(startNode);
TileNode* pathNode = NULL;
while (true) {
pathNode = getMinFNode();
addAdjacentOpenNodes(pathNode);
_passed_nodes.push_back(pathNode);
deletePassedNode(pathNode);
if (pathNode->getX() == int(end.x) && pathNode->getY() == int(end.y)) {
break;
}
}
while (pathNode) {
path->push_back(convertCoordinate2Pixel(pathNode->getX(), pathNode->getY(),
_map_height));
pathNode = pathNode->getParent();
}
std::reverse(path->begin(), path->end());
return path;
}
示例11: OSG_VERSION_GREATER_OR_EQUAL
// The osgDB::DatabasePager will call this automatically to purge expired
// tiles from the scene graph.
bool
TilePagedLOD::removeExpiredChildren(double expiryTime,
unsigned expiryFrame,
osg::NodeList& removedChildren)
{
if (_children.size()>_numChildrenThatCannotBeExpired)
{
unsigned cindex = _children.size() - 1;
double minExpiryTime = 0.0;
unsigned minExpiryFrames = 0;
// these were added in osg 3.1.0+
#if OSG_VERSION_GREATER_OR_EQUAL(3,1,0)
minExpiryTime = _perRangeDataList[cindex]._minExpiryTime;
minExpiryFrames = _perRangeDataList[cindex]._minExpiryFrames;
#endif
if (!_perRangeDataList[cindex]._filename.empty() &&
_perRangeDataList[cindex]._timeStamp + minExpiryTime < expiryTime &&
_perRangeDataList[cindex]._frameNumber + minExpiryFrames < expiryFrame)
{
osg::Node* nodeToRemove = _children[cindex].get();
removedChildren.push_back(nodeToRemove);
ExpirationCollector collector( _live.get() );
nodeToRemove->accept( collector );
_releaser->push( collector._toRelease );
if ( _debug )
{
TileNode* tileNode = getTileNode();
std::string key = tileNode ? tileNode->getKey().str() : "unk";
OE_NOTICE
<< LC << "Tile " << key << " : expiring " << collector._count << " children; "
<< "TS = " << _perRangeDataList[cindex]._timeStamp
<< ", MET = " << minExpiryTime
<< ", ET = " << expiryTime
<< "; FN = " << _perRangeDataList[cindex]._frameNumber
<< ", MEF = " << minExpiryFrames
<< ", EF = " << expiryFrame
<< "\n";
}
return Group::removeChildren(cindex,1);
}
}
return false;
}
示例12: TileNode
void Level::FillInTiles(Vector2 a_levelSize, std::vector<int>* a_idMap)
{
m_levelSize = a_levelSize;
m_tiles.reserve(a_levelSize.x / TILE_WIDTH * a_levelSize.y / TILE_HEIGHT);
for(int tileY = 0; tileY < a_levelSize.y / TILE_HEIGHT; tileY++)
{
for(int tileX = 0; tileX < a_levelSize.x / TILE_WIDTH; tileX++)
{
int index = tileX + tileY * (a_levelSize.x / TILE_WIDTH);
TileNode* t = new TileNode(tileY, tileX, (*a_idMap)[index]);
m_tiles.push_back(t);
t->SetSurface(t->m_iTileId);
}
}
}
示例13: TileNode
void
TileNode::createChildren(EngineContext* context)
{
// Create the four child nodes.
for(unsigned quadrant=0; quadrant<4; ++quadrant)
{
TileNode* node = new TileNode();
// Build the surface geometry:
node->create( getTileKey().createChildKey(quadrant), context );
// Add to the scene graph.
addChild( node );
// Inherit the samplers with new scale/bias information.
node->inheritState( context );
}
OE_DEBUG << LC << "Creating children of: " << getTileKey().str() << "; count = " << (++_count) << "\n";
}
示例14: resetTileNodes
void PathGenerator::resetTileNodes() {
for (int i = 0; i < _map_width; i++) {
for (int j = 0; j < _map_height; j++) {
TileNode* node = _nodes[i][j];
node->setF(0);
node->setG(0);
node->setH(0);
node->setX(i);
node->setY(j);
node->setParent(NULL);
}
}
_opened_nodes.clear();
_passed_nodes.clear();
}
示例15: TileNode
void
SerialKeyNodeFactory::addTile(TileModel* model, bool tileHasRealData, bool tileHasLodBlending, osg::Group* parent )
{
// create a node:
TileNode* tileNode = new TileNode( model->_tileKey, model->_tileLocator );
// install the tile model and compile it:
tileNode->setTileModel( model );
tileNode->compile( _modelCompiler.get() );
// assemble a URI for this tile's child group:
std::string uri = Stringify() << model->_tileKey.str() << "." << _engineUID << ".osgearth_engine_mp_tile";
osg::Node* result = 0L;
// Only add the next tile if all the following are true:
// 1. Either there's real tile data, or a minLOD is explicity set in the options;
// 2. The tile isn't blacklisted; and
// 3. We are still below the maximim LOD.
bool wrapInPagedLOD =
(tileHasRealData || (_options.minLOD().isSet() && model->_tileKey.getLOD() < *_options.minLOD())) &&
!osgEarth::Registry::instance()->isBlacklisted( uri ) &&
model->_tileKey.getLOD() < *_options.maxLOD();
if ( wrapInPagedLOD )
{
osg::BoundingSphere bs = tileNode->getBound();
float maxRange = FLT_MAX;
//Compute the min range based on the 2D size of the tile
GeoExtent extent = model->_tileKey.getExtent();
GeoPoint lowerLeft(extent.getSRS(), extent.xMin(), extent.yMin(), 0.0, ALTMODE_ABSOLUTE);
GeoPoint upperRight(extent.getSRS(), extent.xMax(), extent.yMax(), 0.0, ALTMODE_ABSOLUTE);
osg::Vec3d ll, ur;
lowerLeft.toWorld( ll );
upperRight.toWorld( ur );
double radius = (ur - ll).length() / 2.0;
float minRange = (float)(radius * _options.minTileRangeFactor().value());
// create a PLOD so we can keep subdividing:
osg::PagedLOD* plod = new CustomPagedLOD( _liveTiles.get(), _deadTiles.get() );
plod->setCenter( bs.center() );
plod->addChild( tileNode );
plod->setRangeMode( *_options.rangeMode() );
plod->setFileName( 1, uri );
if (plod->getRangeMode() == osg::LOD::PIXEL_SIZE_ON_SCREEN)
{
static const float sqrt2 = sqrt(2.0f);
minRange = 0;
maxRange = (*_options.tilePixelSize()) * sqrt2;
plod->setRange( 0, minRange, maxRange );
plod->setRange( 1, maxRange, FLT_MAX );
}
else
{
plod->setRange( 0, minRange, maxRange );
plod->setRange( 1, 0, minRange );
}
plod->setUserData( new MapNode::TileRangeData(minRange, maxRange) );
#if USE_FILELOCATIONCALLBACK
osgDB::Options* options = Registry::instance()->cloneOrCreateOptions();
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 LODFactorCallback);
}
}
else
{
result = tileNode;
}
// 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() && _options.clusterCulling() == true )
{
osg::HeightField* hf =
model->_elevationData.getHFLayer()->getHeightField();
result->addCullCallback( HeightFieldUtils::createClusterCullingCallback(
//.........这里部分代码省略.........