0

So I saw a blog about parsing OBJ files, but what really caught my eye was the object they were parsing (this question isn't about parsing OBJ files).

enter image description here

I know the mesh was created using a 3D noise algorithm, probably simplex noise, but what I want to know is how I could make a similar line effect to that in LWJGL.

I already have a 3D simplex noise algorithm, and some code that I thought would work but really doesn't do quite the same thing.

The pattern I notice about the mesh is there are rows of lines that start on the outside where the noise density is highest. Those lines then evolve based on the noise density in specific spots, so what I tried to do was make an algorithm to produce those lines and evolve them as well, but that didn't quite so work.

SimplexNoise noise = new SimplexNoise(23453) //Variable is the seed
worldList = glGenLists(1);
glNewList(worldList, GL_COMPILE); //Inefficient but gets the job done
    float prevx = 0.0f;
    float prevy = 0.0f;
    float prevz = 0.0f;
    for(int x=0;x<256;x++){
        for(int y=0;y<256;y++){
            for(int z=0;z<256;z++){
                float xf = x/100;
                float yf = y/100;
                float zf = z/100;
                density = noise.simplex(3,xf,yf,zf); //octaves,x,y,z
                if(density>3){ //filter out some results
                    drawLine(prevx,prevy,prevz,x+1,y*density,z*density);
                    drawLine(prevx,prevy,prevz,x*density,y+1,z*density);
                    drawLine(prevx,prevy,prevz,x*density,y*density,z+1);
                }
            }
        }
    }
glEndList();

It shouldn't be hard to realize that this doesn't produce anything near the same results. I do not know how to approach or exactly produce the same mesh shape or something similar, so can anyone help me?

4

1 回答 1

0

我对 LWJGL 不熟悉,但我认为就算法本身而言,我可能能够为您指明正确的方向。您可以将 Perlin/Simplex 噪声插入行进立方体算法并从中生成三角形网格。我使用这种技术来创建这个网格:

Perlin Noise 和 Marching Cubes

相信你可以通过绘制输出网格的线框得到你想要的结果。毕竟,如果你仔细观察,所有这些线都会形成三角形。您可以在此处找到有关行进立方体的更多信息。

于 2013-12-01T06:39:20.697 回答