Ejemplo n.º 1
0
        internal static void addBump(Vector3 center, float graphSize, List <Coord> coords, float radius, float verticalScale, float x, float y)
        {
            Coord initial      = ElevationUtils.findClosestCoord(x, y, coords);
            float radialFactor = 1f - Vector3.Distance(center, initial.toVector3()) * 2 / graphSize;

            ElevationUtils.elevate(initial, coords, radius, verticalScale * radialFactor, 2);
        }
Ejemplo n.º 2
0
        /**
         *              radius, x and y are normalised to map size.
         */
        public ElevationHelper plateau(float x, float y, float height, float radius)
        {
            PerlinRadialShape shape         = new PerlinRadialShape(random, radius, 1, x * size, y * size);
            Coord             centralCoord  = ElevationUtils.findClosestCoord(x * size, y * size, coords);
            float             plateauHeight = centralCoord.elevation + height;

            foreach (var coord in coords)
            {
                if (shape.isInside(coord.x, coord.y))
                {
                    float heightMod = (centralCoord.elevation - coord.elevation) * 0.1f;
                    coord.setElevation(plateauHeight + heightMod);
                }
            }
            return(this);
        }
Ejemplo n.º 3
0
        public ElevationHelper crater(float x, float y, float radius)
        {
            Coord origin           = ElevationUtils.findClosestCoord(x * size, y * size, coords);
            float originDepth      = radius * 0.5f;
            float wallHeight       = radius * 0.25f;
            float totalHeightDelta = originDepth + wallHeight;
            float wallFalloff      = radius + radius * 0.25f;

            foreach (var coord in coords)
            {
                float distance = Vector3.Distance(origin.toVector3(), coord.toVector3());
                if (distance < radius)
                {
                    float factor = distance / radius;
                    coord.changeElevationBy(totalHeightDelta * (factor * factor * factor) - originDepth);
                }
                else if (distance < wallFalloff)
                {
                    float factor = (distance - radius) / (wallFalloff - radius);
                    coord.changeElevationBy(wallHeight * (1 - (factor * factor)));
                }
            }
            return(this);
        }