移动立方体问题 [英] Marching Cube Question

查看:279
本文介绍了移动立方体问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在写一个程序使用C ++和OpenGL实现移动立方体。

i currently writing a program to implement Marching Cube using C++ and Opengl.

不过,我最好的参考就是从<一个href="http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/">http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/

However, my best reference is only from http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/

在网络,所提供的codeS是用​​C写的
在这里我的问题是,我不明白的triTable和edgeTable
以及它们之间的关系。

in the web, the provided codes are written in C.
my problem here is that i don't understand the triTable and edgeTable
and how they are related.

谁能帮助我的解释或指导我转换算法为codeS?

can anyone help me on the explanation or guide me on converting the algorithm into codes?

推荐答案

这些表用于找出如何tesselate面:

These Tables are used for finding out how to tesselate the surface:

第一个表为您提供了必要的边缘进行插值。 第二个表给你,你必须tesselate的方式,意, 你必须做出立方体里面哪些三角形。

The first table gives you the necessary edges to interpolate. The second table gives you the way you have to tesselate, meaning, which triangles you have to make inside the cube.

一个小例子:

让我们假设,顶点之一,2低于ISO级别, 该cubeindex应为3。

let's assume, vertex one and 2 are below the iso level, the cubeindex should be 3.

整个路口应该像 一个楔子。

The whole intersection should look like a wedge.

如果你仔细想想,你要插在边缘值: 0和9,以及2和10。 如果能进到一个位域,对应每一位来的边缘相交?你最终会是这样的:

If you think about it, you have to interpolate values on the edges: 0 and 9 , and 2 and 10. If you enter this into a bitfield, each bit corresponding to "is edge intersected?" you would end up with something like this:


10 9 8 7 6 5 4 3 2 1  edge
 1 1 0 0 0 0 1 0 1 0  intersected?

不是吗?

这也正是从edgeTable值[3]二进制)0x30A = 1100001010

Which is exactly the value from edgeTable[3] in binary ;) 0x30A = 1100001010

现在你可以写一个函数,线性插值对那些边缘点 以满足您的ISOLEVEL。这些要点将成为你的面这个单元格内。

Now you can write a function that linearly interpolates the points on those edges to fit your isolevel. These points will become your surface inside this cell.

但如何tesselate该小区/表面?

But how to tesselate this cell/surface?

如果你看看triTable [3]微笑应该爬在你脸上:)

if you look into triTable[3] a smile should creep over your face :)

ADDIT残留困惑的注释语句后:; - )

Addit after statement of residual puzzlement in comment: ;-)

什么移动立方体的作用: 想象一下,你有一个黑暗的房间里有一个点光源在里面。 它是标量强度值的一个容积光强度场的中心。 你可以去点(X,Y,Z)和测量的力度有,如3坎德拉。

What Marching Cubes does: Imagine you have a dark room with one point light source in it. It is the center of a volumetric light intensity field of scalar intensity values. You can go to point (x,y,z) and measure the intensity there, e.g. 3 candela.

您现在希望通过有一定的光强度的所有点呈现的表面。 你可以想像,这等值面看起来像周围的点光源的球体。这是我们希望,移动立方体将提供给我们。

You now want to render a surface through all points that have a certain light intensity. You can Imagine that this Isosurface would look like a sphere around the point light source. That is what we hope that Marching cubes will provide us with.

现在通过在房间里的所有点运行,并标记每个点为顶点大致有ISO值,将算法非常复杂,会导致顶点的休斯数。其中我们将不得不tesselate不知。

Now running through all points in the room and marking every point as a vertex that has roughly the iso value, will be algorithmically very complex and would result in a hughe number of vertices. Which we would then have to tesselate somehow.

所以:一是移动立方体disects全卷分为大小相等的立方体。 如果基础数据有某种潜在的离散性,那倍数被使用。我不会去到另一种情况,因为这是罕见的。 比如我们把1mm厚的密度网格成2mx5mx5m房

So: First Marching cubes disects the whole volume into cubes of equal size. If the underlying data has some kind of underlying discreteness, multiples of that are used. I will not go into the other case, since that is rare. For instance we put a grid with the density of 1mm into a 2mx5mx5m room

我们使用5mmx5mmx5mm的立方体。贯穿其中也要便宜很多。

We use cubes of 5mmx5mmx5mm. Running through them should be much cheaper.

您现在可以想像,那一些立方体的边相交的等值面。 这些都是有趣的。这code将其标明:

You can imagine now, that the edges of some of the cubes intersect the isosurface. These are the interesting ones. This code identifies them:

cubeindex = 0;
   if (grid.val[0] 

如果cubeindex保持为零,这个特定的立方体不是由等值面相交。 如果cubeindex> 0,你现在知道了等值面经过这个立方体 而要渲染的一块等值面就是里面的。 请在你的心中想象这一点。 看到 http://en.wikipedia.org/wiki/Marching_cubes 为立方体相交的例子。 你可以得到轻松的顶点是那些在立方体的边缘。 只需插线2角点之间,找到位置 在等值和把一个顶点那里。但其边缘相交??? 即在edgeTable [cubeindex]的信息。 这是很大的一块code与所有的如果,存储插值 点作为在xyz的点的数组顶点:vertlist []。 这件作品的内容如下:

if cubeindex stays zero, this particular cube is not intersected by the isosurface. If cubeindex is > 0 you now know that the isosurface goes through this cube and you want to render the piece of the isosurface that is inside it. Please picture this in your mind. See http://en.wikipedia.org/wiki/Marching_cubes for examples of intersected cubes. The vertices that you could get easily are those on the edges of the cube. Just interpolate linearly between 2 corner points to find the position of the isovalue and put a vertex there. But which edges are intersected??? That is the information in edgeTable[cubeindex]. That is the big piece of code with all the ifs, that stores the interpolated points as vertices in an array of xyz points: vertlist[]. This piece reads as follows:


get the bitfield = edgeTable[cubeindex]
 if edge 1 is marked in bitfield (bit 1 set to 1 in bitfield)
    vertlist[0] = interpolated point, somewhere on edge 1
... and so on.

您现在有一个数组满顶点,但如何将它们连接到三角形? 这是一个信息的tritable提供。

You now have an array full of vertices, but how to connect them to triangles? That's an info that tritable provides.

剩下的就是pretty的太多我上面的解释。

The rest is pretty much what I explained above.

那么应该仍然是问题,请具体谈谈这块code,给你添麻烦了。

Well should there still be problems, please be specific about the piece of code that gives you trouble.

这篇关于移动立方体问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆