Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void PopulateTerrainMap() { //Tells what height each corner should be
- //Corners are shared, but still need to be one larger so we can hold all of the corner data
- for (int z = 0; z < TerrainData.Width + 1; z++)
- {
- for (int y = 0; y < TerrainData.Height + 1; y++)
- {
- for (int x = 0; x < TerrainData.Width + 1; x++)
- {
- // Get a terrain height using regular old Perlin noise.
- float thisHeight = TerrainData.GetTerrainHeight(x + chunkPos.x, z + chunkPos.z); //We use + chunkPosition because we dont want every chun to look the same
- float diggedHeight = (float)y - thisHeight;
- ChangeVoxel();
- if(y < thisHeight - 1) {
- World.Instance.blockID = 3; //Dirt
- }
- blockID = World.Instance.blocks.blockTypes[World.Instance.blockID].blockID;
- blockName = World.Instance.blocks.blockTypes[World.Instance.blockID].Name;
- // Set the value of this point in the terrainMap array and stores the data so we dont regenerate the data everyytime we modify the terrain.
- terrainMap[x, y, z] = new TerrainPoint(diggedHeight, blockID, blockName); //Get the dst to surfac value and returns a random texture ID
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment