Marching Cubes (C++ to C#)
I am trying to implement marching cubes in C#, but I've come to a part where I don't understand the algorithm and I don't how to implement it.
int Polygonise(GRIDCELL grid, double isolevel, TRIANGLE *triangles)
The third argument I don't really understand. I know it's a pointer, but later on in the algo, when you set the triangles it appears as though the triangles
variable is an array of the TRIANGLE
struct:
int ntriang = 0;
for (int i=0; triTable[cubeindex,i]!=-1; i+=3) {
triangles[ntriang].p[i ] = vertlist[triTable[cubeindex,i ]];
triangles[ntriang].p[i+1] = vertlist[triTable[cubeindex,i+1]];
triangles[ntriang].p[i+2] = vertlist[triTable[cubeindex,i+2]];
ntriang++;
}
Notice the triangles[ntriang]
. That doesn't make sense because before we set triangles
to TRIANGLE *triangles
. I also don't understand why It's a pointer.
The caller of Polygonize
expects *triangles
point to an allocated array long enough to contain all the triangles. The equivalent in c# can be a TRIANGLE[]
or a List<TRIANGLE>()
It looks like this function takes the GRID of voxels/cells and outputs the triangles. It is a pointer since you will get a list of triangles.
链接地址: http://www.djcxy.com/p/37170.html上一篇: 使用ZBuffer和2D中的alpha混合在一个着色器中创建多个纹理
下一篇: 行进多维数据集(C ++到C#)