• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TileNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TileNode的典型用法代码示例。如果您正苦于以下问题:C++ TileNode类的具体用法?C++ TileNode怎么用?C++ TileNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TileNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: drawAll

void TileStack::drawAll(GWindow& window) const {
    TileNode* p = front;
    while (p!= NULL) {
        p->draw(window);
        p = p->next;
    }
}
开发者ID:cathyliu0308,项目名称:cs106b,代码行数:7,代码来源:TileStack.cpp


示例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 );
}
开发者ID:flybpc,项目名称:osgearth,代码行数:34,代码来源:TilePagedLOD.cpp


示例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;
}
开发者ID:APerennec,项目名称:osgearth,代码行数:60,代码来源:SingleKeyNodeFactory.cpp


示例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 );
    }
}
开发者ID:mathieu,项目名称:osgearth,代码行数:26,代码来源:TileNode.cpp


示例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 );
    }
}
开发者ID:rhabacker,项目名称:osgearth,代码行数:28,代码来源:TileNode.cpp


示例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();    
}
开发者ID:mathieu,项目名称:osgearth,代码行数:25,代码来源:TileNode.cpp


示例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;
}
开发者ID:makemefriendanshu,项目名称:osgearth,代码行数:34,代码来源:TilePagedLOD.cpp


示例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;
}
开发者ID:InterAtlas-ML,项目名称:osgearth,代码行数:58,代码来源:SerialKeyNodeFactory.cpp


示例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);
    }
}
开发者ID:VincentPeng,项目名称:SaveHostage,代码行数:25,代码来源:PathGenerator.cpp


示例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;
}
开发者ID:VincentPeng,项目名称:SaveHostage,代码行数:26,代码来源:PathGenerator.cpp


示例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;
}
开发者ID:XenonofArcticus,项目名称:osgearth,代码行数:51,代码来源:TilePagedLOD.cpp


示例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);
		}
	}
}
开发者ID:EricPolman,项目名称:Mario,代码行数:16,代码来源:Level.cpp


示例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";
}
开发者ID:caomw,项目名称:osgearth,代码行数:20,代码来源:TileNode.cpp


示例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();
}
开发者ID:VincentPeng,项目名称:SaveHostage,代码行数:15,代码来源:PathGenerator.cpp


示例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(
//.........这里部分代码省略.........
开发者ID:WojtekLewandowski,项目名称:osgearth,代码行数:101,代码来源:SerialKeyNodeFactory.cpp


示例16: TileNode

void TileManager::ProcessTileMap(std::string a_sFileName)
{
	m_sCurrentLevel = a_sFileName;
	int rows = m_pBaseSprite[a_sFileName]->GetHeight() / TILE_HEIGHT;
	int columns = m_pBaseSprite[a_sFileName]->GetWidth() / TILE_WIDTH;
	int idCounter = 0;
	
	int id = 0;

	int counter = 0;
	
	for(int row = 0; row < rows; row++)
	{
		for(int col = 0; col < columns; col++)
		{
			Tmpl8::Surface* surface = new Tmpl8::Surface(TILE_WIDTH, TILE_HEIGHT);
			m_pBaseSprite[a_sFileName]->CopyPartTo(surface, 0, 0, col * TILE_WIDTH, row * TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT);

			if(row == 0 && col == 0)
			{
				TileNode* tileNode = new TileNode(row, col, 0);
				m_pTiles[a_sFileName].push_back(tileNode);
				m_pTileSurfaces[a_sFileName].push_back(new TileSurface(idCounter,surface));
				tileNode->SetSurface(tileNode->m_iTileId);
				counter++;
				idCounter++;
				continue;
			}
			bool isUnique = true;
			for(std::vector<TileSurface*>::iterator iter = m_pTileSurfaces[a_sFileName].begin(); iter != m_pTileSurfaces[a_sFileName].end();)
			{
				if(!(*iter)->CompareSurfaces(surface))
				{
					isUnique = false;
					id = (*iter)->m_iTileId;
					iter = m_pTileSurfaces[a_sFileName].end();
				}
				else
				{
					iter++;
				}
			}

			if(isUnique)
			{
				m_pTileSurfaces[a_sFileName].push_back(new TileSurface(idCounter,surface));
				id = idCounter;
				idCounter++;
			}
			else
			{
				delete surface;
			}
			TileNode* tileNode = new TileNode(row, col, id);
			m_pTiles[a_sFileName].push_back(tileNode);
			tileNode->SetSurface(tileNode->m_iTileId);
			counter++;
		}
	}
	FIBITMAP* bitmap = FreeImage_Allocate(512, 1024, 24);
	int tilesInRow = 512 / TILE_WIDTH;
	int rowCounter = 0;
	int colCounter = 0;
	for(std::vector<TileSurface*>::iterator iter = m_pTileSurfaces[a_sFileName].begin(); iter != m_pTileSurfaces[a_sFileName].end(); iter++)
	{
		Tmpl8::Pixel* buffer = (*iter)->m_pTileSurface->GetBuffer();
		int pitch = (*iter)->m_pTileSurface->GetPitch();

		for(int x = 0; x < TILE_WIDTH; x++)
		{
			for(int y = 0; y < TILE_HEIGHT; y++)
			{
				RGBQUAD color;
				color.rgbRed = (buffer[x + y*pitch] & 0xFF0000) >> 16;
				color.rgbGreen = (buffer[x + y*pitch] & 0x00FF00) >> 8;
				color.rgbBlue = buffer[x + y*pitch] & 0x0000FF;
				FreeImage_SetPixelColor(bitmap, colCounter*TILE_WIDTH + x, 1023 - rowCounter*TILE_HEIGHT - y, &color);
			}
		}
		colCounter++;
		if(colCounter >= tilesInRow)
		{
			colCounter = 0;
			rowCounter++;
		}
	}
	FreeImage_Save(FIF_PNG, bitmap, std::string("assets/tilesets/"+a_sFileName+"_tilemap.png").c_str(), 0);

	std::string tileMap;
	std::stringstream ss;
			
	counter = 0;
	for(int row = 0; row < rows; row++)
	{
		for(int col = 0; col < columns; col++)
		{
			TileNode* currentNode = m_pTiles[a_sFileName][counter];
			counter++;

			ss.str("");
//.........这里部分代码省略.........
开发者ID:EricPolman,项目名称:Mario,代码行数:101,代码来源:TileManager.cpp


示例17: TileNode

TileNode*
TileGroupFactory::createTileNode(TerrainTileModel* model,
                                 ProgressCallback* progress)
{
    TileNode* tileNode = new TileNode(model);
    
    for(TerrainTileImageLayerModelVector::const_iterator i = model->colorLayers().begin();
        i != model->colorLayers().end();
        ++i)
    {
        const TerrainTileLayerModel* layer = i->get();

        if ( layer->getTexture() )
        {
            osg::StateSet* stateSet = tileNode->getOrCreateStateSet();

            stateSet->setTextureAttribute(
                _renderBindings.color().unit(),
                layer->getTexture() );

            // (note: sampler uniform is set at the top level by the engine)
        }

        if ( layer->getMatrix() )
        {
            osg::StateSet* stateSet = tileNode->getOrCreateStateSet();

            stateSet->addUniform( new osg::Uniform(
                _renderBindings.color().matrixName().c_str(),
                *(layer->getMatrix())) );
        }
    }

    if ( model->elevationModel() )
    {
        const TerrainTileElevationModel* em = model->elevationModel();
        
        if ( em->getTexture() )
        {
            osg::StateSet* stateSet = tileNode->getOrCreateStateSet();

            stateSet->setTextureAttribute(
                _renderBindings.elevation().unit(),
                em->getTexture() );

            osg::Matrixf elevMatrix;
            if ( em->getMatrix() )
                elevMatrix = *(em->getMatrix());

            stateSet->addUniform( new osg::Uniform(
                _renderBindings.elevation().matrixName().c_str(),
                elevMatrix ));

            // (note: sampler uniform is set at the top level by the engine)
        }
    }
    
    for(TerrainTileImageLayerModelVector::const_iterator i = model->sharedLayers().begin();
        i != model->sharedLayers().end();
        ++i)
    {
        const TerrainTileImageLayerModel* layerModel = i->get();
        
        const ImageLayer* imageLayer = layerModel->getImageLayer();
        if ( imageLayer )
        {
            if ( layerModel->getTexture() )
            {
                osg::StateSet* stateSet = tileNode->getOrCreateStateSet();

                stateSet->setTextureAttribute(
                    imageLayer->shareImageUnit().get(),
                    layerModel->getTexture() );
                
                //TODO: don't really need this if we set it up in the Engine 
                //  once at the top level when adding the layer.
                stateSet->addUniform( new osg::Uniform(
                    imageLayer->shareSamplerName()->c_str(),
                    imageLayer->shareImageUnit().get() ));
            }

            if ( layerModel->getMatrix() )
            {
                osg::StateSet* stateSet = tileNode->getOrCreateStateSet();

                stateSet->addUniform( new osg::Uniform(
                    imageLayer->shareMatrixName()->c_str(),
                    *(layerModel->getMatrix())) );
            }
        }
    }

    return tileNode;
}
开发者ID:2php,项目名称:osgearth,代码行数:94,代码来源:TileGroupFactory.cpp


示例18: pushModelViewMatrix

void
TerrainCuller::apply(osg::Node& node)
{
    // push the node's state.
    osg::StateSet* node_state = node.getStateSet();

    TileNode* tileNode = dynamic_cast<TileNode*>(&node);
    if (tileNode)
    {
        _currentTileNode = tileNode;

        // reset the pointer to the first DrawTileCommand. We keep track of this so
        // we can set it's "order" member to zero at the end, so the rendering engine
        // knows to blend it with the terrain geometry color.
        _firstTileDrawCommandForTile = 0L;

        //_currentTileDrawCommands = 0u;
        
        if (!_terrain.patchLayers().empty())
        {
            // todo: check for patch/virtual
            const RenderBindings& bindings = _context->getRenderBindings();
            TileRenderModel& renderModel = _currentTileNode->renderModel();

            bool pushedMatrix = false;
            
            for (PatchLayerVector::const_iterator i = _terrain.patchLayers().begin(); i != _terrain.patchLayers().end(); ++i)
            {
                PatchLayer* layer = i->get();
                if (layer->getAcceptCallback() == 0L ||
                    layer->getAcceptCallback()->acceptKey(_currentTileNode->getKey()))
                {
                    // Push this tile's matrix if we haven't already done so:
                    if (!pushedMatrix)
                    {
                        SurfaceNode* surface = tileNode->getSurfaceNode();

                        // push the surface matrix:
                        osg::Matrix mvm = *getModelViewMatrix();
                        surface->computeLocalToWorldMatrix(mvm, this);
                        pushModelViewMatrix(createOrReuseMatrix(mvm), surface->getReferenceFrame());
                        pushedMatrix = true;
                    }

                    // Add the draw command:
                    DrawTileCommand* cmd = addDrawCommand(layer->getUID(), &renderModel, 0L, tileNode);
                    if (cmd)
                    {
                        cmd->_drawPatch = true;
                        cmd->_drawCallback = layer->getDrawCallback();
                    }
                }
            }

            if (pushedMatrix)
            {
                popModelViewMatrix();
            }
        }
    }

    else
    {
        SurfaceNode* surface = dynamic_cast<SurfaceNode*>(&node);
        if (surface)
        {
            TileRenderModel& renderModel = _currentTileNode->renderModel();

            // push the surface matrix:
            osg::Matrix mvm = *getModelViewMatrix();
            surface->computeLocalToWorldMatrix(mvm, this);
            pushModelViewMatrix(createOrReuseMatrix(mvm), surface->getReferenceFrame());

            int order = 0;

            // First go through any legit rendering pass data in the Tile and
            // and add a DrawCommand for each.
            for (unsigned p = 0; p < renderModel._passes.size(); ++p)
            {
                const RenderingPass& pass = renderModel._passes[p];
                DrawTileCommand* cmd = addDrawCommand(pass.sourceUID(), &renderModel, &pass, _currentTileNode);
                if (cmd)
                {
                    if (_firstTileDrawCommandForTile == 0L)
                    {
                        _firstTileDrawCommandForTile = cmd;
                    }
                    else if (cmd->_order < _firstTileDrawCommandForTile->_order)
                    {
                        //_firstTileDrawCommandForTile->_order = 1;
                        _firstTileDrawCommandForTile = cmd;
                    }
                }
            }

            // If the culler added no draw commands for this tile... we still need
            // to draw something or else there will be a hole! So draw a blank tile.
            // UID = -1 is the special UID code for a blank.
            if (_firstTileDrawCommandForTile == 0L)
            {
//.........这里部分代码省略.........
开发者ID:JD31,项目名称:osgearth,代码行数:101,代码来源:TerrainCuller.cpp


示例19: setupRenderBindings

void
RexTerrainEngineNode::dirtyTerrain()
{
    //TODO: scrub the geometry pool?

    // clear the loader:
    _loader->clear();

    if ( _terrain )
    {
        this->removeChild( _terrain );
    }

    // New terrain
    _terrain = new osg::Group();
    this->addChild( _terrain );

    // are we LOD blending?
    bool setupParentData = 
        _terrainOptions.morphImagery() == true || // gw: redundant?
        this->parentTexturesRequired();
    
    // reserve GPU unit for the main color texture:
    if ( _renderBindings.empty() )
    {
        setupRenderBindings();
    }

    // recalculate the LOD morphing parameters:
    destroySelectionInfo();
    buildSelectionInfo();

    // clear out the tile registry:
    if ( _liveTiles.valid() )
    {
        _liveTiles->moveAll( _deadTiles.get() );
    }

    // Factory to create the root keys:
    EngineContext* context = getEngineContext();

    // Build the first level of the terrain.
    // Collect the tile keys comprising the root tiles of the terrain.
    std::vector<TileKey> keys;
    _update_mapf->getProfile()->getAllKeysAtLOD( *_terrainOptions.firstLOD(), keys );

    // create a root node for each root tile key.
    OE_INFO << LC << "Creating " << keys.size() << " root keys.." << std::endl;

    unsigned child = 0;
    for( unsigned i=0; i<keys.size(); ++i )
    {
        TileNode* tileNode = new TileNode();
                
        // Next, build the surface geometry for the node.
        tileNode->create( keys[i], context );

        _terrain->addChild( tileNode );
    }

    updateState();

    // Call the base class
    TerrainEngineNode::dirtyTerrain();
}
开发者ID:rmk177,项目名称:osgearth,代码行数:65,代码来源:RexTerrainEngineNode.cpp


示例20: TileNode

std::vector<Vec2> TMXPathFinding::getPath(Vec2 startPos, Vec2 endPos, std::vector<int> walkableGIDs, std::vector<int> obstacleGIDs) {
	open.clear();
	close.clear();

	// inizialize a goal node
	goalNode = new TileNode();
	goalNode->setLocX(endPos.x);
	goalNode->setLocY(endPos.y);

	// inizialize a start node
	startNode = new TileNode();
	startNode->setLocX(startPos.x);
	startNode->setLocY(startPos.y);
	startNode->setCostFromStart(0);
	startNode->setParent(nullptr);

	int cost = getDistance(startNode, goalNode);

	startNode->setCostToGoal(cost);
	startNode->setTotalCost();

	open.emplace(startNode, startNode->getTotalCost());

	while (open.size() != 0) {
		// Fix a Cost to check the values
		min = 32767; // std::numeric_limits<int>::max()
		TileNode *minNode;

		// Find minNode from open QUEUE
		for (auto kv : open) {
			extractNode = kv.first;
			iCost = kv.second;
			if (iCost < min) {
				min = iCost;    // Change min to the New Cost got from the open QUEUE
				minNode = extractNode;
			}
		}
		extractNode = minNode;
		open.erase(minNode); // pop node from open

		// if it's a goal, we're done
		if (extractNode->getLocation() == goalNode->getLocation()) {
			// 1- retrieve all extractNode's parents
			// 2- save into Vec2 vector
			// 3- reverse Vec2 vector
			// 4- return Vec2 vector
			std::vector<Vec2> points;
			points.push_back(extractNode->getLocation());

			int size = extractNode->getCostFromStart();
			for (int i = 0; i < size; i++) {
				points.push_back(Vec2(extractNode->getParent()->getLocation().x, extractNode->getParent()->getLocation().y));
				extractNode = extractNode->getParent();
			}
			std::reverse(points.begin(), points.end());

			return points;
		}
		else {
			for (int i = 0; i < dir; i++) {
				costToOpen = 0;
				costToClose = 0;
				inOpen = false;
				inClose = false;
				newNode = new TileNode();
				newNode->setLocX(extractNode->getLocation().x);
				newNode->setLocY(extractNode->getLocation().y);

				switch (i) {
					case 0: // left
						newNode->setLocX(-1);
						newNode->setLocY(0);
						break;
					case 1: // right
						newNode->setLocX(1);
						newNode->setLocY(0);
						break;
					case 2: // up
						newNode->setLocX(0);
						newNode->setLocY(1);
						break;
					case 3: // down
						newNode->setLocX(0);
						newNode->setLocY(-1);
						break;
					case 4: // top-left
						newNode->setLocX(-1);
						newNode->setLocY(1);
						break;
					case 5: // bottom-left
						newNode->setLocX(-1);
						newNode->setLocY(-1);
						break;
					case 6: // bottom-right
						newNode->setLocX(1);
						newNode->setLocY(-1);
						break;
					case 7: // top-right
						newNode->setLocX(1);
						newNode->setLocY(1);
//.........这里部分代码省略.........
开发者ID:smitpatel88,项目名称:TMXPathFinding,代码行数:101,代码来源:TMXPathFinding.cpp



注:本文中的TileNode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TilePagedLOD类代码示例发布时间:2022-05-31
下一篇:
C++ TileMap类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap