Created
February 3, 2014 04:56
-
-
Save wmiller/8779017 to your computer and use it in GitHub Desktop.
XML Database Example1 InitHeights()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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