Skip to content

Instantly share code, notes, and snippets.

@wmiller
Created February 3, 2014 04:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmiller/8779017 to your computer and use it in GitHub Desktop.
Save wmiller/8779017 to your computer and use it in GitHub Desktop.
XML Database Example1 InitHeights()
private void InitHeights()
{
HeightField = new int[Width * Height];
for (int y = 0; y < Height; ++y)
{
for (int x = 0; x < Width; ++x)
{
// Compute a position in noise space
float noiseX = (float)x / Width * NoiseFrequency;
float noiseY = (float)y / Height * NoiseFrequency;
// Get Perlin noise value
float noise = Mathf.PerlinNoise(noiseX, noiseY);
// Convert to height and store
HeightField[y * Width + x] = Mathf.RoundToInt(noise * 3.0f);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment