首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从Esri网格(osg)中高效地绘制地形模型?

问如何从Esri网格(osg)中高效地绘制地形模型?
EN

Stack Overflow用户
提问于 2020-07-07 09:41:13
回答 1查看 133关注 0票数 0

我有许多Esri文件(https://en.wikipedia.org/wiki/Esri_grid#ASCII),我想在3D中呈现它们,而不会失去精度,我正在使用OpenSceneGraph。

问题是这个网格大约有1000x1000点(或更多)点,所以当我提取顶点,然后计算三角形来创建几何学时,我最终得到了数百万点,并且与场景的交互是不可能的(帧速率降到0)。

我试过几种方法:

  1. Triangle列表

基本上,当我读取文件时,我用每个三角形填充一个包含3个顶点的数组(这将导致复制);

代码语言:javascript
复制
osg::ref_ptr<osg::Geode> l_pGeodeSurface = new osg::Geode;
osg::ref_ptr<osg::Geometry> l_pGeometrySurface = new osg::Geometry;
osg::ref_ptr<osg::Vec3Array> l_pvTrianglePoints = osg::Vec3Array;
osg::ref_ptr<osg::Vec3Array> l_pvOriginalPoints = osg::Vec3Array;

... // Read the file and fill l_pvOriginalPoints 

for(*triangle inside the file*)
{
   ... // Compute correct triangle indices (l_iP1, l_iP2, l_iP3)

    // Push triangle vertices inside the array
    l_pvTrianglePoints->push_back(l_pvOriginalPoints->at(l_iP1));
    l_pvTrianglePoints->push_back(l_pvOriginalPoints->at(l_iP2));
    l_pvTrianglePoints->push_back(l_pvOriginalPoints->at(l_iP3));
}

l_pGeometrySurface->setVertexArray(l_pvTrianglePoints);
l_pGeometrySurface->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLES, 0, 3, l_pvTrianglePoints->size()));

  1. Indexed三角形列表

和以前一样,但是数组只包含每个顶点一次,我创建了第二个索引数组(基本上我告诉osg如何构建三角形,而不是duplication) )。

代码语言:javascript
复制
osg::ref_ptr<osg::Geode> l_pGeodeSurface = new osg::Geode;
osg::ref_ptr<osg::Geometry> l_pGeometrySurface = new osg::Geometry;
osg::ref_ptr<osg::DrawElementsUInt> l_pIndices = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, *number of indices*);
osg::ref_ptr<osg::Vec3Array> l_pvOriginalPoints = osg::Vec3Array;

... // Read the file and fill l_pvOriginalPoints 

for(i = 0; i < *number of indices*; i++)
{
   ... // Compute correct triangle indices (l_iP1, l_iP2, l_iP3)

    // Push vertices indices inside the array
    l_pIndices->at(i) = l_iP1;
    l_pIndices->at(i+1) = l_iP2;
    l_pIndices->at(i+2) = l_iP3;
}

l_pGeometrySurface->setVertexArray(l_pvOriginalPoints );
l_pGeometrySurface->addPrimitiveSet(l_pIndices.get());

​

​

  1. Instancing

这是一个实验,因为我从来没有使用过着色器,我可以用一个三角形作为实例,然后用变换矩阵(把矩阵作为一个均匀的数组,一个三角形)在我的场景中的每个三角形的顶点着色器中操作它的坐标。最后,我得到了太多的制服,只有一个网格20x20。

我使用这些链接作为参考:

https://learnopengl.com/Advanced-OpenGL/Instancing,

https://books.google.it/books?id=x_RkEBIJeFQC&pg=PT265&lpg=PT265&dq=osg+instanced+geometry&source=bl&ots=M8ii8zn8w7&sig=ACfU3U0_92Z5EGCyOgbfGweny4KIUfqU8w&hl=en&sa=X&ved=2ahUKEwj-7JD0nq7qAhUXxMQBHcLaAiUQ6AEwAnoECAkQAQ#v=onepage&q=osg%20instanced%20geometry&f=false

没有一个解决了我的问题,我还能尝试什么呢?在渲染技术方面,我遗漏了什么吗?我以为这任务很简单,但我被困住了。

EN

回答 1

Stack Overflow用户

发布于 2020-07-08 16:38:37

我觉得你应该考虑退一步。如果您正在可视化基于地理信息系统的地形数据,那么osgEarth确实是为实现这一目的而设计的,并且具有相当高效的用于大型地形的LOD工具。您是否需要始终表示为最大全LOD的数据,还是您正在寻找动态LOD来提高帧速率?

根据您的目标和要求,您可能需要考虑一些更先进的地形绘制技术,如右字段跟踪等。如果地形总是静态的,您可以预先计算四叉树和有符号距离函数,并跟踪到高度场。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62772372

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档