当前位置: 首页>>代码示例>>C++>>正文


C++ PagedLOD::getRangeMode方法代码示例

本文整理汇总了C++中osg::PagedLOD::getRangeMode方法的典型用法代码示例。如果您正苦于以下问题:C++ PagedLOD::getRangeMode方法的具体用法?C++ PagedLOD::getRangeMode怎么用?C++ PagedLOD::getRangeMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osg::PagedLOD的用法示例。


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

示例1: apply

 virtual void apply(osg::PagedLOD& node)
 {        
     //The PagedLOD node will contain two filenames, the first is empty and is the actual geometry of the          
     //tile and the second is the filename of the next tile.
     if (node.getNumFileNames() > 1)
     {
         //Get the child filename
         const std::string &filename = node.getFileName(1);              
         if (osgEarth::Registry::instance()->isBlacklisted(filename))
         {
             //If the tile is blacklisted, we set the actual geometry, child 0, to always display
             //and the second child to never display
             node.setRange(0, 0, FLT_MAX);
             node.setRange(1, FLT_MAX, FLT_MAX);
         }
         else
         {
             //If the child is not blacklisted, it is possible that it could have been blacklisted previously so reset the
             //ranges of both the first and second children.  This gives the second child another
             //chance to be traversed in case a layer was added that might have data.
             osg::ref_ptr< MapNode::TileRangeData > ranges = static_cast< MapNode::TileRangeData* >(node.getUserData());
             if (ranges)
             {
                 if (node.getRangeMode() == osg::LOD::PIXEL_SIZE_ON_SCREEN)
                 {
                     node.setRange( 0, ranges->_minRange, ranges->_maxRange );
                     node.setRange( 1, ranges->_maxRange, FLT_MAX );                          
                 }
                 else
                 {                          
                     node.setRange(0, ranges->_minRange, ranges->_maxRange);
                     node.setRange(1, 0, ranges->_minRange);
                 }
             }                  
         }
         
     }
     traverse(node);
 }
开发者ID:jy4618272,项目名称:osgearth,代码行数:39,代码来源:MapNode.cpp

示例2: apply

void IntersectionVisitor::apply(osg::PagedLOD& plod)
{
    if (!enter(plod)) return;

    if (plod.getNumFileNames()>0)
    {
#if 1
        // Identify the range value for the highest res child
        float targetRangeValue;
        if( plod.getRangeMode() == osg::LOD::DISTANCE_FROM_EYE_POINT )
            targetRangeValue = 1e6; // Init high to find min value
        else
            targetRangeValue = 0; // Init low to find max value
            
        const osg::LOD::RangeList rl = plod.getRangeList();
        osg::LOD::RangeList::const_iterator rit;
        for( rit = rl.begin();
             rit != rl.end();
             rit++ )
        {
            if( plod.getRangeMode() == osg::LOD::DISTANCE_FROM_EYE_POINT )
            {
                if( rit->first < targetRangeValue )
                    targetRangeValue = rit->first;
            }
            else
            {
                if( rit->first > targetRangeValue )
                    targetRangeValue = rit->first;
            }
        }

        // Perform an intersection test only on children that display
        // at the maximum resolution.
        unsigned int childIndex;
        for( rit = rl.begin(), childIndex = 0;
             rit != rl.end();
             rit++, childIndex++ )
        {
            if( rit->first != targetRangeValue )
                // This is not one of the highest res children
                continue;

            osg::ref_ptr<osg::Node> child( NULL );
            if( plod.getNumChildren() > childIndex )
                child = plod.getChild( childIndex );

            if( (!child.valid()) && (_readCallback.valid()) )
            {
                // Child is NULL; attempt to load it, if we have a readCallback...
                unsigned int validIndex( childIndex );
                if (plod.getNumFileNames() <= childIndex)
                    validIndex = plod.getNumFileNames()-1;

                child = _readCallback->readNodeFile( plod.getDatabasePath() + plod.getFileName( validIndex ) );
            }

            if ( !child.valid() && plod.getNumChildren()>0)
            {
                // Child is still NULL, so just use the one at the end of the list.
                child = plod.getChild( plod.getNumChildren()-1 );
            }

            if (child.valid())
            {
                child->accept(*this);
            }
        }
#else    
        // older code than above block, that assumes that the PagedLOD is ordered correctly
        // i.e. low res children first, no duplicate ranges.
        
        osg::ref_ptr<osg::Node> highestResChild;

        if (plod.getNumFileNames() != plod.getNumChildren() && _readCallback.valid())
        {
            highestResChild = _readCallback->readNodeFile( plod.getDatabasePath() + plod.getFileName(plod.getNumFileNames()-1) );
        }
        
        if ( !highestResChild.valid() && plod.getNumChildren()>0)
        {
            highestResChild = plod.getChild( plod.getNumChildren()-1 );
        }

        if (highestResChild.valid())
        {
            highestResChild->accept(*this);
        }
#endif
    }

    leave();
}
开发者ID:joevandyk,项目名称:osg,代码行数:93,代码来源:IntersectionVisitor.cpp


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