Jump to content

  • Log In with Google      Sign In   
  • Create Account


Generating a marching cubes terrain with perlin noise


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 CohoJET   Members   -  Reputation: 108

Like
0Likes
Like

Posted 27 October 2012 - 09:06 AM

Hellp there! I was making a marching cubes terrain, but i encounter a very annoying trouble, when generator was rising the "y" level is riging by 2 Screenshot, i spend almost 2 days, but no progress at all...here is the code of the the generator, perlin noise is from the Lib Noise .NET, maybe someone here can point me to the solution=(
[source lang="csharp"] private void Generate() { //Initializing the noise Random rnd = new Random(); Perlin perlin = new Perlin(); perlin.Frequency = 0.05; perlin.Lacunarity = 0.25; perlin.OctaveCount = 1; perlin.Persistence = 0.05; perlin.Seed = 5; perlin.NoiseQuality = NoiseQuality.High; //Generating the noise values for every vertex bool[, ,] vertexDensities = new bool[Size + 1, Height + 1, Size + 1]; for (float y = -0.5f; y < Height + 0.5f; y ++) for (float z = -0.5f; z < Size + 0.5f; z ++) for (float x = -0.5f; x < Size + 0.5f; x++) { float density = ((-y + 0.5f) + 0) + (float)(perlin.GetValue(x, y, z)); vertexDensities[(int)(x + 0.5f), (int)(y + 0.5f), (int)(z + 0.5f)] = density > 0; } //Writing values for each voxel for (int y = 0; y < Height; y++) for (int z = 0; z < Size; z++) for (int x = 0; x < Size; x++) { //Converting density values into binary form string density = ""; density += Convert.ToByte(vertexDensities[x + 1, y, z]); density += Convert.ToByte(vertexDensities[x + 1, y + 1, z]); density += Convert.ToByte(vertexDensities[x, y + 1, z]); density += Convert.ToByte(vertexDensities[x, y, z]); density += Convert.ToByte(vertexDensities[x + 1, y, z + 1]); density += Convert.ToByte(vertexDensities[x + 1, y + 1, z + 1]); density += Convert.ToByte(vertexDensities[x, y + 1, z + 1]); density += Convert.ToByte(vertexDensities[x, y, z + 1]); depthData[x, y, z] = Convert.ToByte(density, 2); } }[/source]

Edited by CohoJET, 27 October 2012 - 03:57 PM.


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS