public ChunkPrimer OnCreateChunk(CubizerBehaviour terrain, int x, int y, int z) { var map = new ChunkPrimer(terrain.profile.chunk.settings.chunkSize, (short)x, (short)y, (short)z); int offsetX = x * map.voxels.Bound.x; int offsetY = y * map.voxels.Bound.y; int offsetZ = z * map.voxels.Bound.z; for (int ix = 0; ix < map.voxels.Bound.x; ix++) { for (int iz = 0; iz < map.voxels.Bound.y; iz++) { int dx = offsetX + ix; int dz = offsetZ + iz; for (int iy = 0; iy < 8; iy++) { int dy = offsetY + iy; if (Math.Noise.Simplex3(dx * 0.01f, dy * 0.1f, dz * 0.01f, 8, 0.5f, 2) > _params.thresholdCloud) { map.voxels.Set((byte)ix, (byte)iy, (byte)iz, _materials.cloud); } } } } return(map); }
public ChunkPrimer OnCreateChunk(CubizerBehaviour terrain, int x, int y, int z) { switch (_params.layer) { case BasicObjectBiomeType.Grassland: return(Buildland(terrain, x, y, z, _materials.grass)); case BasicObjectBiomeType.Forest: return(Buildland(terrain, x, y, z, _materials.grass)); case BasicObjectBiomeType.Sandyland: return(Buildland(terrain, x, y, z, _materials.sand)); default: return(null); } }
public ChunkPrimer buildObsidian(CubizerBehaviour terrain, int x, int y, int z) { var size = terrain.profile.chunk.settings.chunkSize; var map = new ChunkPrimer(size, x, y, z, size * size * 8); for (byte ix = 0; ix < map.voxels.Bound.x; ix++) { for (byte iz = 0; iz < map.voxels.Bound.z; iz++) { for (byte iy = 0; iy < 8; iy++) { map.voxels.Set(ix, iy, iz, _materials.obsidian); } } } return(map); }
public ChunkPrimer OnCreateChunk(CubizerBehaviour terrain, int x, int y, int z) { var size = terrain.profile.chunk.settings.chunkSize; var map = new ChunkPrimer(size, x, y, z, size * size * _params.floorBase); for (byte ix = 0; ix < map.voxels.Bound.x; ix++) { for (byte iz = 0; iz < map.voxels.Bound.z; iz++) { for (byte iy = 0; iy < _params.floorBase; iy++) { map.voxels.Set(ix, iy, iz, _materials.grass); } } } return(map); }
public ChunkPrimer Buildland(CubizerBehaviour terrain, int x, int y, int z, VoxelMaterial main) { var size = terrain.profile.chunk.settings.chunkSize; var map = new ChunkPrimer(size, x, y, z, size * size * _params.floorBase); int offsetX = x * map.voxels.Bound.x; int offsetZ = z * map.voxels.Bound.z; for (byte ix = 0; ix < map.voxels.Bound.x; ix++) { for (byte iz = 0; iz < map.voxels.Bound.z; iz++) { int dx = offsetX + ix; int dz = offsetZ + iz; float f; byte h; this.BuildGrass(map, ix, iz, dx, dz, main, out f, out h); var waterHeight = (byte)(_params.floorBase - _params.floorHeightLismit * 0.2f); if (_params.isGenWater && h <= waterHeight) { for (byte iy = h; iy <= waterHeight; iy++) { map.voxels.Set(ix, iy, iz, _materials.water); } } else { if (f > waterHeight && f < (waterHeight + 0.1)) { map.voxels.Set(ix, (byte)(h - 1), iz, _materials.sand); } if (_params.isGenWeed && Noise.Simplex2( _params.weeds.loopX * dx, _params.weeds.loopZ * dz, _params.weeds.octaves, _params.weeds.persistence, _params.weeds.lacunarity) > _params.weeds.threshold) { map.voxels.Set(ix, h, iz, _materials.weed[random.Next(0, _materials.weed.Length - 1)]); } else if (_params.isGenFlower && Noise.Simplex2( _params.flowers.loopX * dx, _params.flowers.loopZ * dz, _params.flowers.octaves, _params.flowers.persistence, _params.flowers.lacunarity) > _params.flowers.threshold) { map.voxels.Set(ix, h, iz, _materials.flower[random.Next(0, _materials.flower.Length - 1)]); } else if (_params.isGenTree && h < map.voxels.Bound.y - 8) { if (ix > 3 && ix < map.voxels.Bound.y - 3 && iz > 3 && iz < map.voxels.Bound.y - 3) { if (Noise.Simplex2( _params.tree.loopX * dx, _params.tree.loopZ * dz, _params.tree.octaves, _params.tree.persistence, _params.tree.lacunarity) > _params.tree.threshold) { this.BuildTree(map, ix, iz, h); } } } } } } return(map); }