/// <inheritdoc />
        public void Populate(IVoxelGridChunk chunk)
        {
            IChunkPopulatorContracts.Populate(chunk);

            foreach (var pair in chunk.VoxelsLocalView)
            {
                chunk.VoxelsLocalView[pair.Key] = new TerrainVoxel(TerrainMaterial.Air, byte.MaxValue);
            }

            var start = this.bufferWidth;
            var end   = chunk.VoxelsLocalView.Dimensions[0] - this.bufferWidth - 1;

            for (int count = start; count <= end; count++)
            {
                chunk.VoxelsLocalView[new Index3D(count, start, start)] = this.voxel;
                chunk.VoxelsLocalView[new Index3D(count, start, end)]   = this.voxel;
                chunk.VoxelsLocalView[new Index3D(count, end, start)]   = this.voxel;
                chunk.VoxelsLocalView[new Index3D(count, end, end)]     = this.voxel;

                chunk.VoxelsLocalView[new Index3D(start, start, count)] = this.voxel;
                chunk.VoxelsLocalView[new Index3D(start, end, count)]   = this.voxel;
                chunk.VoxelsLocalView[new Index3D(end, start, count)]   = this.voxel;
                chunk.VoxelsLocalView[new Index3D(end, end, count)]     = this.voxel;

                chunk.VoxelsLocalView[new Index3D(start, count, start)] = this.voxel;
                chunk.VoxelsLocalView[new Index3D(start, count, end)]   = this.voxel;
                chunk.VoxelsLocalView[new Index3D(end, count, start)]   = this.voxel;
                chunk.VoxelsLocalView[new Index3D(end, count, end)]     = this.voxel;
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public void Populate(IVoxelGridChunk chunk)
        {
            IChunkPopulatorContracts.Populate(chunk);

            foreach (var pair in chunk.VoxelsLocalView)
            {
                chunk.VoxelsLocalView[pair.Key] = this.voxel;
            }

            var start = 0;
            var end   = chunk.VoxelsLocalView.UpperBounds[0];

            for (int iX = start; iX <= end; iX++)
            {
                for (int iY = start; iY <= end; iY++)
                {
                    chunk.VoxelsLocalView[new Index3D(iX, iY, start)] = Air;
                    chunk.VoxelsLocalView[new Index3D(iX, iY, end)]   = Air;

                    chunk.VoxelsLocalView[new Index3D(iX, start, iY)] = Air;
                    chunk.VoxelsLocalView[new Index3D(iX, end, iY)]   = Air;

                    chunk.VoxelsLocalView[new Index3D(start, iX, iY)] = Air;
                    chunk.VoxelsLocalView[new Index3D(end, iX, iY)]   = Air;
                }
            }
        }
        /// <inheritdoc />
        public void Populate(IVoxelGridChunk chunk)
        {
            IChunkPopulatorContracts.Populate(chunk);

            foreach (var pair in chunk.VoxelsLocalView)
            {
                chunk.VoxelsLocalView[pair.Key] = this.outOfBoundsValue;
            }
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        public void Populate(ISkyIslandMapChunk chunk)
        {
            IChunkPopulatorContracts.Populate(chunk);

            foreach (var pair in chunk.MapsLocalView)
            {
                chunk.MapsLocalView[pair.Key] = this.outOfBoundsValue;
            }
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        /// <inheritdoc />
        public void Populate(ISkyIslandMapChunk chunk)
        {
            IChunkPopulatorContracts.Populate(chunk);

            Index2D min = chunk.MapsStageView.LowerBounds;
            Index2D max = chunk.MapsStageView.UpperBounds;

            // iX and iY are in global stage coordinates
            for (int iY = min.Y; iY <= max.Y; iY++)
            {
                for (int iX = min.X; iX <= max.X; iX++)
                {
                    // TODO Steven - I don't think centerX, centerY, radiusStart, radiusEnd are defined correctly.
                    // What if the stage is rectangular or not 0, 0, 0 lower bound.
                    // Also the radial gradient seems to be keeping anything from getting generated...

                    // creates a map that cookie cuts islands out of the top and bottom maps by removing the
                    // open space around the sides and forcing the maps to seam at the island edges
                    double shape = this.mapsConfig.ShapeDistorter.Noise(this.shapeNoise, iX, iY);                     //// +
                    ////Gradient.Radial(
                    ////	x: iX,
                    ////	y: iY,
                    ////	centerX: this.halfStageLength,
                    ////	centerY: this.halfStageLength,
                    ////	radiusStart: this.radiusStart,
                    ////	radiusEnd: this.halfStageLength,
                    ////	valueStart: 0,
                    ////	valueEnd: -2);
                    shape = shape.Clamp(-1, 1);

                    // generates a baseline for island height that will factor into the top and bottom heights
                    double baselineHeight =
                        this.mapsConfig.BaselineHeightDistorter.Noise(this.baselineNoise, iX, iY);

                    double mountain;
                    double topHeight;
                    double bottomHeight;

                    if (shape > 0)
                    {
                        // only generate meaningful values within the shape of the island

                        // decides where mountains will be
                        mountain = this.mapsConfig.MountainDistorter.Noise(this.mountainNoise, iX, iY);

                        // shapes the top of the islands
                        topHeight = Interpolation.WeightedAverage(
                            this.mapsConfig.TopHeightNearEdgeDistorter.Noise(this.topNoise, iX, iY),
                            this.mapsConfig.TopHeightDistorter.Noise(this.topNoise, iX, iY),
                            shape);
                        topHeight = (topHeight * mountain * shape) + baselineHeight;

                        // shapes the bottom of the islands
                        bottomHeight = Interpolation.WeightedAverage(
                            this.mapsConfig.BottomHeightNearEdgeDistorter.Noise(this.bottomNoise, iX, iY),
                            this.mapsConfig.BottomHeightDistorter.Noise(this.bottomNoise, iX, iY),
                            shape);
                        bottomHeight = (bottomHeight * shape) + baselineHeight;
                    }
                    else
                    {
                        // don't bother generating values outside the shape of the island
                        mountain     = 0;
                        topHeight    = 0;
                        bottomHeight = 0;
                    }

                    chunk.MapsStageView[new Index2D(iX, iY)] = new SkyIslandMaps(
                        shapePercentWeight: shape,
                        baselineHeight: baselineHeight,
                        mountainHeightMultiplier: mountain,
                        topHeight: topHeight,
                        bottomHeight: bottomHeight);
                }
            }
        }