基本双轮廓理论
我一直在谷歌上搜索,但找不到任何基本的东西。在最基本的形式中,双轮廓(对于体素地形)是如何实现的?我知道它的作用以及原因,但不明白如何做到这一点。 JS 或 C#(最好)都不错。以前有人使用过 Dual轮廓并能简单解释一下吗?
I've been searching on google, but cannot find anything basic. In it's most basic form, how is dual contouring (for a voxel terrain) implememted? I know what it does, and why, but cannot understand how to do it. JS or C# (preferably) is good.Has anyone used Dual contouring before and can explain it briefly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的。所以今晚我很无聊,决定自己尝试一下双重轮廓。正如我在评论中所说,所有相关材料均位于以下论文的第 2 节中:
原始版本:http://www.frankpetterson.com/publications/dualcontour/dualcontour.pdf特别是,部分描述了网格的拓扑2.2 在下面的部分中,引用:
这就是全部了!您解决线性最小二乘问题以获得每个立方体的顶点,然后用四边形连接相邻顶点。因此,利用这个基本思想,我使用 numpy 在 python 中编写了一个双轮廓等值面提取器(部分只是为了满足我自己对其工作原理的病态好奇心)。代码如下:
它不是很快,因为它使用 SciPy 的通用非线性求根方法来查找等值面上的边缘点。然而,它似乎确实工作得相当好并且以相当通用的方式。为了测试它,我使用以下测试用例(在 Mayavi2 可视化工具包中)运行它:
这将球体定义为隐式方程,并通过双轮廓求解 0-等值面。当我在工具包中运行它时,结果如下:
总之,它似乎有效。
Ok. So I got bored tonight and decided to give implementing dual contouring myself a shot. Like I said in the comments, all the relevant material is in section 2 of the following paper:
Original Version: http://www.frankpetterson.com/publications/dualcontour/dualcontour.pdfIn particular, the topology of the mesh is described in part 2.2 in the following section, quote:
That's all there is to it! You solve a linear least squares problem to get a vertex for each cube, then you connect adjacent vertices with quads. So using this basic idea, I wrote a dual contouring isosurface extractor in python using numpy (partly just to satisfy my own morbid curiosity on how it worked). Here is the code:
It is not very fast because it uses the SciPy's generic non-linear root finding methods to find the edge points on the isosurface. However, it does seem to work reasonably well and in a fairly generic way. To test it, I ran it using the following test case (in the Mayavi2 visualization toolkit):
This defines a sphere as an implicit equation, and solves for the 0-isosurface by dual contouring. When I ran it in the toolkit, this was the result:
In conclusion, it appears to be working.