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); }
public ElevationHelper erode(List <Corner> corners) { updateCornerElevations(corners); ElevationUtils.calculateDownslopes(corners); ElevationUtils.calculateMoisture(corners); ElevationFunctions.performWaterErosion(corners); return(this); }
public ElevationHelper updateCornerElevations(List <Corner> corners) { if (!cornersUpToDate) { ElevationUtils.assignCornerElevations(corners); cornersUpToDate = true; } return(this); }
internal static void addNoise(List <Coord> coords, RandomProvider random, float horizontalScale, float verticalScale) { float offset = random.getFloat(); foreach (Coord coord in coords) { var perlin = ElevationUtils.getPerlin(offset, horizontalScale, coord.x, coord.y); coord.setElevation(coord.elevation + perlin * verticalScale); } }
/** * Applys perlin noise across the map with a radial bias, maximum strength at the center, 0 at map width. * Changing the horizonal scale should change the frequency of the effect. Smaller numbers = less detailed. * Change the vertical scale to change the strength of the effect. */ internal static void addRadialWeightedNoise(Vector3 center, float radius, List <Coord> coords, RandomProvider random, float horizontalScale, float verticalScale) { float offset = random.getFloat(); foreach (Coord coord in coords) { var perlin = ElevationUtils.getPerlin( offset, horizontalScale, coord.x / radius, coord.y / radius ); float distance = Vector3.Distance(center, coord.toVector3()); coord.setElevation(Mathf.Lerp(coord.elevation, coord.elevation + perlin * verticalScale, 1 - Mathf.Clamp01(distance / radius))); } }
/** * 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); }
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); }
internal static void addCone(List <Coord> coords, float radius, float x, float y, float verticalScale) { ElevationUtils.elevate(coords, radius, x, y, verticalScale, 1); }