osgEarth的Rex引擎原理分析(四十四)如何控制父子TileNode节点的显隐

2023-10-30

目标:(三十七)中的105

rex渲染出的地球是靠一块块TileNode瓦片拼接起来的,瓦片之间存在父子关系,一般显示父TileNode就不应显示子TileNode,反之亦然。那么rex是如何做这种显隐控制呢?

1、每一个TileNode瓦片在遍历时,会根据是否有子节点及子节点的准备情况来决定是否遍历其_surface(负责具体的显示内容)。

osgEarthDrivers/engine_rex/TileNode.cpp
bool
TileNode::cull(TerrainCuller* culler)
{

    // determine whether we can and should subdivide to a higher resolution:
    bool childrenInRange = shouldSubDivide(culler, context->getSelectionInfo());

    // whether it is OK to create child TileNodes is necessary.
    bool canCreateChildren = childrenInRange;

    // whether it is OK to load data if necessary.
    bool canLoadData = true;

    // whether to accept the current surface node and not the children.
    bool canAcceptSurface = false;
    
    // Don't create children in progressive mode until content is in place
    if ( _dirty && context->getOptions().progressive() == true )
    {
        canCreateChildren = false;
    }
    
    // If this is an inherit-viewpoint camera, we don't need it to invoke subdivision
    // because we want only the tiles loaded by the true viewpoint.
    const osg::Camera* cam = culler->getCamera();
    if ( cam && cam->getReferenceFrame() == osg::Camera::ABSOLUTE_RF_INHERIT_VIEWPOINT )
    {
        canCreateChildren = false;
        canLoadData       = false;
    }

    if (childrenInRange)
    {
        // We are in range of the child nodes. Either draw them or load them.

        // If the children don't exist, create them and inherit the parent's data.
        if ( !_childrenReady && canCreateChildren )
        {
            _mutex.lock();

            if ( !_childrenReady )
            {
                OE_START_TIMER(createChildren);
                createChildren( context );
                REPORT("TileNode::createChildren", createChildren);
                _childrenReady = true;

                // This means that you cannot start loading data immediately; must wait a frame.
                canLoadData = false;
            }

            _mutex.unlock();
        }

        // If all are ready, traverse them now.
        if ( _childrenReady )
        {
            for(int i=0; i<4; ++i)
            {
                getSubTile(i)->accept(*culler);
            }
        }

        // If we don't traverse the children, traverse this node's payload.
        else
        {
            canAcceptSurface = true;
        }
    }

    // If children are outside camera range, draw the payload and expire the children.
    else
    {
        canAcceptSurface = true;
    }

    // accept this surface if necessary.
    if ( canAcceptSurface )
    {
        _surface->accept( *culler );
        _lastAcceptSurfaceFrame.exchange( culler->getFrameStamp()->getFrameNumber() );
    }
}

2、对于一个TileNode瓦片节点,如果经过1的判断,需要裁剪遍历其_surface的话,会在TerrainCuller下的_terrain(TerrainRenderData)下的_tile(DrawTileCommand)中形成一条记录。

osgEarthDrivers/engine_rex/TerrainCuller.cpp
void
TerrainCuller::apply(osg::Node& node)
{

            // 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)
            {
                //OE_INFO << LC << "Adding blank render for tile " << _currentTileNode->getKey().str() << std::endl;
                DrawTileCommand* cmd = addDrawCommand(-1, &renderModel, 0L, _currentTileNode);
                if (cmd)
                    cmd->_order = 0;
            }
}





DrawTileCommand*
TerrainCuller::addDrawCommand(UID uid, const TileRenderModel* model, const RenderingPass* pass, TileNode* tileNode)
{
    osg::ref_ptr<LayerDrawable> drawable = _terrain.layer(uid);
    if (drawable.valid())
    {
        // Cull based on the layer extent.
        if (drawable->_layer)
        {
            const LayerExtent& le = (*_layerExtents)[drawable->_layer->getUID()];
            if (le._computed && 
                le._extent.isValid() &&
                le._extent.intersects(tileNode->getKey().getExtent()) == false)
            {
                // culled out!
                //OE_DEBUG << LC << "Skippping " << drawable->_layer->getName() 
                //    << " key " << tileNode->getKey().str()
                //    << " because it was culled by extent." << std::endl;
                return 0L;
            }
        }

        drawable->_tiles.push_back(DrawTileCommand());
        DrawTileCommand* tile = &drawable->_tiles.back();

        // install everything we need in the Draw Command:
        tile->_colorSamplers = pass ? &(pass->samplers()) : 0L;
        tile->_sharedSamplers = &model->_sharedSamplers;
        tile->_modelViewMatrix = this->getModelViewMatrix();
        tile->_keyValue = tileNode->getTileKeyValue();
        tile->_geom = surface->getDrawable()->_geom.get();
        tile->_morphConstants = tileNode->getMorphConstants();
        tile->_key = &tileNode->getKey();
        //tile->_order = (int)orderInTile;
        tile->_order = drawable->_order; // layer order in map tile.

        osg::Vec3 c = surface->getBound().center() * surface->getInverseMatrix();
        tile->_range = getDistanceToViewPoint(c, true);

        const osg::Image* elevRaster = tileNode->getElevationRaster();
        if (elevRaster)
        {
            float bias = _context->getUseTextureBorder() ? 1.5 : 0.5;

            // Compute an elevation texture sampling scale/bias so we sample elevation data on center
            // instead of on edge (as we do with color, etc.)
            //
            // This starts out as:
            //   scale = (size-1)/size : this shrinks the sample area by one texel since we're sampling on center
            //   bias = 0.5/size : this shifts the sample area over 1/2 texel to the center.
            //
            // But, since we also have a 1-texel border, we need to further reduce the scale by 2 texels to
            // remove the border, and shift an extra texel over as well. Giving us this:
            float size = (float)elevRaster->s();
            tile->_elevTexelCoeff.set((size - (2.0*bias)) / size, bias / size);
        }

        return tile;
    }
}

3、加入的记录会在rex引擎遍历时生成渲染叶RenderLeaf,进而绘制出来


void
RexTerrainEngineNode::traverse(osg::NodeVisitor& nv)
{
        for(LayerDrawableList::iterator i = culler._terrain.layers().begin();
            i != culler._terrain.layers().end();
            ++i)
        {
            if (!i->get()->_tiles.empty())
            {
                lastLayer = i->get();
                lastLayer->_order = -1;

                cv->apply(*lastLayer);

            }
        }

待继续分析列表:

9、earth文件中都有哪些options((九)中问题)

10、如何根据earth文件options创建不同的地理信息引擎节点((九)中问题)

11、rex地理信息引擎的四梁八柱((九)中问题)

12、osgEarth::TerrainEngineNode中setMap方法作用((十二)中问题)

13、RexTerrainEngineNode中_mapFrame的作用((十二)中问题)

14、地形变形(Terrain morphing)((十二)中问题)

15、地球瓦片过期门限的含义((十二)中问题)

16、高分辨率优先的含义((十二)中问题)

17、OSGEARTH_DEBUG_NORMALS环境变量的作用((十二)中问题)

18、活跃瓦片寄存器的作用((十二)中问题)

19、资源释放器子节点的作用((十二)中问题)

20、共享几何图形池子节点的作用((十二)中问题)

21、分页瓦片加载器子节点的作用((十二)中问题)

22、分页瓦片卸载器子节点的作用((十二)中问题)

23、栅格化器子节点的作用((十二)中问题)

24、地形子节点的作用((十二)中问题)

25、绑定渲染器的作用((十二)中问题)

26、地图回调函数的作用((十二)中问题)

27、如何将地图图层添加到rex引擎中((十二)中问题)

28、选择信息的作用((十二)中问题)

29、瓦片包围盒修改回调函数的作用((十二)中问题)

30、刷新rex引擎((十二)中问题)

31、刷新边界作用((十二)中问题)

32、osgEarth::Metrics类的意义((十四)中问题)

33、请求合并队列_mergeQueue((十四)中问题)

34、分页瓦片加载器在更新遍历时对请求处理过程((十四)中问题)

35、分页瓦片加载器在更新遍历时对已处理请求裁剪过程((十四)中问题)

36、已处理的请求队列_requests((十四)中问题)

37、DatabasePager中的_fileRequestQueue和_httpRequestQueue((十六)中问题)

38、瓦片请求的生成到处理过程详解((十六)中问题)

39、瓦片节点TileNode的创建过程((十七)中问题)

40、request请求加载瓦片优先级的含义((十七)中问题)

41、request的_internalHandle的作用((十七)中问题)

42、DatabaseRequest中_objectCache含义((十七)中问题)

42、osgEarth的多线程分析((十七)中问题)

43、osgEarth的缓存及其结构((十七)中问题)

44、DatabaseThread从缓存加载数据过程((十七)中问题)

45、DatabaseThread从文件加载数据过程((十七)中问题)

46、决定创建TileNode的时机条件((十七)中问题)

47、TerrainEngineNode的createTileModel过程详解((十七)中问题)

48、DatabaseThread中CompileSet的含义((十七)中问题)

48、PagerLoader的traverse过程详解((十七)中问题)

49、DatabaseThread的run过程详解((十七)中问题)

50、LoadTileData的invoke过程详解((十七)中问题)

51、TileNode的cull过程详解((十七)中问题)

52、遮罩生成器osgEarth::Drivers::RexTerrainEngine::MaskGenerator((十八)中问题)

53、RexTerrainEngineNode::traverse过程详解((十八)中问题)

54、TileNode节点下的场景树分析((十八)中问题)

55、地形瓦片大小尺寸和LOD的关系((十八)中问题)

56、TileNode的_tileKeyValue作用((十八)中问题)

57、TileNode的_morphConstants作用((十八)中问题)

58、TileNode的_stitchNormalMap作用((十八)中问题)

59、TileNode的_renderModel作用((十八)中问题)

60、初始化高程栅格过程详解((十八)中问题)

61、LoadTileData中的CreateTileModelFilter作用((十八)中问题)

62、TileNode节点何时会从场景树中移除((十八)中问题)

63、osgEarth::Map的Profile创建过程((二十)中问题)

64、osgEarth::TerrainTileModelFactory添加颜色层和影像层的区别((二十一)中问题)

65、osgEarth::PatchLayer修补层的作用((二十一)中问题)

66、osgEarth::TerrainLayer中的_memCache(osgEarth::MemCache)详解((二十一)中问题)

67、osgEarth::Layer::RenderType图层渲染类型的作用((二十一)中问题)

68、osgEarth::TerrainLayer中TileSource的作用((二十一)中问题)

69、earth文件没有设置高程图层会不会有默认高程层(高程均为0)((二十一)中问题)

70、TerrainTileModelFactory::addColorLayers过程详解((二十一)中问题)

71、TerrainTileModelFactory::addElevation过程详解((二十一)中问题)

72、osgearth中可能用到的几个全局实例对象(osgDB::Registry osgEarth::Registry osg::Timer osg::DisplaySetting)((二十三)中问题)

73、osgEarth::Map::addLayer过程详解((二十三)中问题)

74、TileNode::setDirty过程详解((二十三)中问题)

75、请求四个状态的含义(IDLE RUNNING MERGING FINISHED)((二十三)中问题)

76、什么时候删除TileNode节点,不会一直增加吧((二十三)中问题)

77、寄存器中请求状态活动记录的含义Registry::instance()->endActivity( req->getName() )((二十三)中问题)

78、瓦片TileNode的生命周期流程详解((二十三)中问题)

79、rex引擎如何将瓦片构造成地球形状((二十五)中问题)

80、高程、影像文件格式详解((二十五)中问题)

81、TileNode的merge过程详解((二十六)中问题)

82、osgEarth支持的空间参考坐标系详解(osgEarth::SpatialReference、osgEarth::CubeSpatialReference、osgEarth::TangentPlaneSpatialReference)((二十九)中问题)

83、osgEarth地球椭球体ellipsoid 大地基准面datum 地图投影Projection详解((二十九)中问题)

84、空间参考坐标系和坐标系统类型的关系(geocentric projected)((二十九)中问题)

85、proj4是什么((二十九)中问题)

86、为什么要删除设置过的垂直水准面((二十九)中问题)

87、osgEarth如何对投影坐标系和大地坐标系进行显示处理的((二十九)中问题)

88、TileNode的节点构成,一个surface、tilenode((三十)中问题)

89、MapFram和MapInfo的关系((三十)中问题)

90、ModifyBoundingBoxCallback的使用时机和场合((三十)中问题)

91、MapFrame为什么要单独存放高程层_elevationLayers,而不是放在图层_layers中((三十)中问题)

92、MapFrame和Map中高程池的作用osg::ref_ptr<ElevationPool> _elevationPool((三十)中问题)

93、osgEarth::Drivers::RexTerrainEngine::TileDrawable分析((三十)中问题)

94、请求读取地理信息失败会如何处理((三十二)中问题)

95、RexTerrainEngineNode的遍历过程详解((三十三)中问题)

96、osgEarth::Drivers::RexTerrainEngine::TerrainCuller的apply过程详解((三十三)中问题)

97、RexTerrainEngineNode的updateState过程详解 设置了很多着色器变量((三十三)中问题)

98、什么时候分配opengl资源((三十三)中问题)

99、TileNode释放opengl资源过程releaseGLObjects详解((三十三)中问题)

100、最近一次遍历的帧号和时间是怎么设置呢(在渲染遍历里),怎么就不会再渲染遍历该瓦片节点了((三十三)中问题)

101、osg::State和osg::StateSet的关系((三十四)中问题)

102、osgEarth::SpatialReference和osgEarth::Profile的关系((三十六)中问题)

103、osgEarth的Geographic、Geodetic、Geocentric和Project的关系((三十六)中问题)

104、TileNode绘制过程详解((三十七)中问题)

105、如何控制父子TileNode节点的显隐((三十七)中问题)

106、GeometryPool的createGeometry过程详解((三十七)中问题)

107、TileNode如何从地图中提取与其分辨率相适应的图像数据((三十七)中问题)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

osgEarth的Rex引擎原理分析(四十四)如何控制父子TileNode节点的显隐 的相关文章

随机推荐

  • ubuntu下rime输入法的安装配置

    一 安装 ibus rime安装 1 1 安装ibus输入法框架 sudo apt get install ibus ibus clutter ibus gtk ibus gtk3 ibus qt4 1 2 安装rime sudo apt
  • 计算绕原点旋转某角度后的点的坐标

    问题 A点 x y 按顺时针旋转 theta 角度后点的坐标为A1点 x1 y1 求x1 y1坐标用 x y 和 theta 来表示 方法一 设 OA 向量和x轴的角度为 alpha 那么顺时针转过 theta后 OA1 向量和x轴的角度为
  • loadrunner压力fullgc

    loadrunner 打压力的时候 我们会根据jconsole来监控被压系统的内存 cpu fullgc等 当出现内存溢出或者fullgc 见下图 既内存溢出 又有fullgc 要先查看jvm的配置 好多技术都使用的默认配置 那么就要调试j
  • 编写软著的基本常识

    1 背景介绍 1 1 软著的概念 软著即软件著作权 市面上任何一个APP在编写完毕之后都会向国家版权中心去申请著作权对自己的软件进行知识产权保护 对于一个系统来说 可以对系统的功能模块进行拆分 分别进行软著的申请 也就相当于一个系统可以申请
  • 关于阿里云ECS服务器提示高危漏洞问题的处理

    购买阿里云服务器后 一段时间 会发钱提示高危漏洞 而且很多 有高危 中危 低危 严重等几个等级 当点击 一键修复或者生成修复命令时 开始让买买买了就 关于这个问题自己手动修复的话 采用软件升级一般都可以解决 除了提示带kernel的高危漏洞
  • 送书

    最好的挣钱方式是钱生钱 怎样钱生钱呢 钱生钱可以通过投资 例如买股票 基金等方式 有人可能说买股票基金发财 我没这样的命和运气 买股票基金靠的不只有命运和运气 更多靠的是长期的经验和对股票基金数据的分析 今天我们使用scrapy框架来js逆
  • C#和Java,究竟选哪个方向?我只说事实,你自己分析……

    优质资源分享 学习路线指引 点击解锁 知识定位 人群定位 Python实战微信订餐小程序 进阶级 本课程是python flask 微信小程序的完美结合 从项目搭建到腾讯云部署上线 打造一个全栈订餐系统 Python量化交易实战 入门级 手
  • netty源码分析(十四)Netty初始化流程总结及Channel与ChannelHandlerContext作用域分析

    我们回到ServerBootstrap的init方法 之前介绍过Attribute的设置 那么Attribute的具体设置是怎样的呢 void init Channel channel throws Exception final Map
  • MySQL深度探险(二)-- MySQL系统架构详解

    一 逻辑模块组成 总的来说 MySQL 可以看成是二层架构 第一层我们通常叫做SQL Layer 在 MySQL 数 据库系统处理底层数据之前的所有工作都是在这一层完成的 包括权限判断 sql 解析 执 行计划优化 query cache
  • 联想笔记本安装win10 ubuntu配置步骤

    一 准备ubuntu分区 在win10下用磁盘管理工具 磁盘管理工具可以右键我的电脑 gt 属性 gt 磁盘管理工具打开 选中安装ubuntu的目标硬盘 右键 gt 压缩卷 会自动计算出可以分出的空间大小 根据自己需求进行压缩 压缩后会生成
  • Python中让代码 BUG 变得酷炫的利器

    当我们写的一个脚本或程序发生各种不可预知的异常时 如果我们没有进行捕获处理的时候 通常都会致使程序崩溃退出 并且会在终端打印出一堆 密密麻麻 的 traceback 堆栈信息来告诉我们 是哪个地方出了问题 就像这样子 天呐 密集恐惧症要犯了
  • 剑指offer-16 链表反转

    法一 package Leetcode ListNode Author YCKJ3803 Date 2021 3 2 22 39 Description 反转链表 最经典的题 yyds public class ReverseListNod
  • API安全

    1 API的简介 API代表应用程序编程接口 它由一组允许软件组件进行通信的定义和协议组成 作为软件系统之间的中介 API使软件应用程序或服务能够共享数据和功能 但是API不仅仅提供连接基础 它还管理软件应用程序如何被允许进行通信和交互 A
  • 带分数 -- 蓝桥杯

    带分数 蓝桥杯 题目描述 100 可以表示为带分数的形式 100 3 69258714 还可以表示为 100 82 3546197 注意特征 带分数中 数字 1 9 分别出现且只出现一次 不包含 0 类似这样的带分数 100 有 11 种表
  • 虚拟机不能上网以及无法ping通百度的解决方案

    虚拟机无法上网 看了许多博客也没有解决问题 最后自己钻研文档解决了 此处分享一下 1 点击此处编辑 2 选择虚拟网络编辑器 3 点击更改设置 4 选择v8 并将使用本地DHCP选项勾选掉 注 此处为nat模式 5 手动输入子网IP 子网掩码
  • 微信公众号支付java前后端分离开发

    微信公众号支付java前后端分离开发 微信公众号支付java前后端分离开发 我们开发的是基于河北银行的支付 支付宝微信都做了 这里就介绍一下微信公众号支付 这个公众号支付需要配置的东西太多了 官方文档写的跟s一样 看不懂 一点一点自摸索的
  • C++ Array size()实例讲解

    描述 C 函数std array size 用于获取数组中存在的元素数 声明 以下是 std array size 函数形式 std array 标头的声明 constexpr size type size noexcept 参数 空 返回
  • jxl读取excel封装成List、Map

    一 封装成List 数据格式为List
  • Moving On 第 44 届 ACM/ICPC 亚洲区域赛(银川)网络赛

    Firdaws and Fatinah are living in a country with nnn cities numbered from 111 to nnn Each city has a risk of kidnapping
  • osgEarth的Rex引擎原理分析(四十四)如何控制父子TileNode节点的显隐

    目标 三十七 中的105 rex渲染出的地球是靠一块块TileNode瓦片拼接起来的 瓦片之间存在父子关系 一般显示父TileNode就不应显示子TileNode 反之亦然 那么rex是如何做这种显隐控制呢 1 每一个TileNode瓦片在