public void Generate(Chunk chunk) { for (int x = 0; x < Chunk.XDimension; x++) { for (int y = 0; y < Chunk.YDimension; y++) { for (int z = 0; z < Chunk.ZDimension; z++) { chunk.SetBlockPrototype(new RelativeBlockPosition(x, y, z), BlockPrototype.AirBlock); } } } }
public void Generate(Chunk chunk) { for (int x = 0; x < Chunk.XDimension; x++) { for (int y = 0; y < Chunk.YDimension; y++) { for (int z = 0; z < Chunk.ZDimension; z++) { var blockType = y <= GroundLevel ? BlockPrototype.StoneBlock : BlockPrototype.AirBlock; chunk.SetBlockPrototype(new RelativeBlockPosition(x, y, z), blockType); } } } }
void InitializeChunk(Chunk chunk, double[,,] densityMap) { for (int x = 0; x < Chunk.XDimension; x++) { for (int y = 0; y < Chunk.YDimension; y++) { for (int z = 0; z < Chunk.ZDimension; z++) { var prototype = densityMap[x, y, z] > 0 ? BlockPrototype.StoneBlock : BlockPrototype.AirBlock; chunk.SetBlockPrototype(new RelativeBlockPosition(x, y, z), prototype); } } } }
//private void GenerateCaves1() //{ // var primitive = new SimplexPerlin // { // Quality = NoiseQuality.Best, // Seed = 1 // }; // var filter = new HeterogeneousMultiFractal() // { // Primitive3D = primitive, // Frequency = 1, // Gain = 2, // Lacunarity = 2, // OctaveCount = 1, // Offset = 1, // SpectralExponent = 0.9f // }; // _blockArray.Initialize((x, y, z) => // { // if (x > 0 && x < _blockArray.XDimension - 1 && y > 0 && y < _blockArray.YDimension - 1 && z > 0 && z < _blockArray.ZDimension - 1) // { // float divisor = 20; // float filterX = (XDimension * Position.X + x) / divisor; // float filterY = y / divisor; // float filterZ = (ZDimension * Position.Z + z) / divisor; // return filter.GetValue(filterX, filterY, filterZ) < 1.4 ? _prototypeMap[1] : _prototypeMap[0]; // } // else // { // return _prototypeMap[0]; // } // }); //} //private void GenerateCaves2() //{ // var primitive = new SimplexPerlin // { // Quality = NoiseQuality.Best, // Seed = 1 // }; // var filter = new HybridMultiFractal() // { // Primitive3D = primitive, // Frequency = 1, // Gain = 2, // Lacunarity = 2, // OctaveCount = 1, // Offset = 1, // SpectralExponent = 0.9f // }; // _blockArray.Initialize((x, y, z) => // { // if (x > 0 && x < _blockArray.XDimension - 1 && y > 0 && y < _blockArray.YDimension - 1 && z > 0 && z < _blockArray.ZDimension - 1) // { // float divisor = 20; // float filterX = (XDimension * Position.X + x) / divisor; // float filterY = y / divisor; // float filterZ = (ZDimension * Position.Z + z) / divisor; // return filter.GetValue(filterX, filterY, filterZ) < 1.5 ? _prototypeMap[1] : _prototypeMap[0]; // } // else // { // return _prototypeMap[0]; // } // }); //} void GenerateSlab(Chunk chunk) { for (int x = 0; x < Chunk.XDimension; x++) { for (int z = 0; z < Chunk.ZDimension; z++) { chunk.SetBlockPrototype(new RelativeBlockPosition(x, 0, z), BlockPrototype.StoneBlock); } } }