Пример #1
0
        /// <inheritdoc />
        public void Populate(IVoxelGridChunk chunk)
        {
            IChunkPopulatorContracts.Populate(chunk);

            foreach (var index in chunk.VoxelsStageView.Select(pair => pair.Key))
            {
                double density = this.distorter.Noise(this.noise, index.X, index.Y, index.Z);
                chunk.VoxelsStageView[index] = TerrainVoxelFromNoise.New(this.material, density);
            }
        }
        private TerrainVoxel GenerateVoxel(int x, int y, int z, double gradientDensity, float mapTopHeight)
        {
            double          voxelDensity = this.GenerateDensity(x, y, z, gradientDensity, mapTopHeight);
            TerrainMaterial material     = TerrainMaterial.Air;

            if (voxelDensity > 0)
            {
                if (y >= mapTopHeight)
                {
                    material = TerrainMaterial.Grass;
                }
                else if (y >= mapTopHeight - 8)
                {
                    material = TerrainMaterial.Dirt;
                }
                else
                {
                    material = TerrainMaterial.Stone;
                }
            }

            return(TerrainVoxelFromNoise.New(material, voxelDensity));
        }