/// <summary> /// Erodes plates. /// </summary> private static void GenerateErosion() { var rulesLocation = InputFileName("Erosion Rule"); var inHeightLocation = InputFileName("Height Data"); var inRainLocation = InputFileName("Rainfall Data"); var outErosionLocation = InputFileName("Erosion Data"); var outIsWaterLocation = InputFileName("Is Water Data"); var rules = (ErosionMapRules)RulesIO.Load(rulesLocation.Name, nameof(ErosionMapRules)); var heightMap = PointIO.OpenDoubleData(inHeightLocation.Name + ".bin", 2 * rules.xHalfSize, rules.ySize); var rainfallMap = new double[2 * rules.xHalfSize, rules.ySize]; for (int i = 0; i < rules.numberSeasons; i++) { var rainfallMapTemp = PointIO.OpenDoubleData(inHeightLocation.Name + ".bin", 2 * rules.xHalfSize, rules.ySize); for (int x = 0; x < 2 * rules.xHalfSize; x++) { for (int y = 0; y < rules.ySize; y++) { rainfallMap[x, y] += rainfallMapTemp[x, y]; } } } GenerateErosionMap.Run(heightMap, rainfallMap, rules, out bool[,] isWater, out double[,] erosionMap); PointIO.SaveHeightImage(outErosionLocation.Name, erosionMap); PointIO.SaveMapData(outErosionLocation.Name + ".bin", erosionMap); CheapBinaryIO.WriteBinary(outIsWaterLocation.Name + ".bin", isWater); }
/// <summary> /// Generates tectonic plates. /// </summary> private static void GeneratePlates() { var rulesLocation = InputFileName("Generate Rules"); var outDataLocation = InputFileName("Point Data"); var outImageLocation = InputFileName("Point Image"); var rules = (GenerateRules)RulesIO.Load(rulesLocation.Name, nameof(GenerateRules)); var pointData = GeneratePlateData.Run(rules); PointIO.SavePointData(outDataLocation.Name, rules, pointData); PointIO.SavePointImage(outImageLocation.Name, rules, pointData); }
/// <summary> /// Generates altitude map for points. /// </summary> private static void GenerateAltitudes() { var rulesLocation = InputFileName("Generate Height Rules"); var inDataLocation = InputFileName("Point Data"); var outDataLocation = InputFileName("Height Data"); var rules = (AltitudeMapRules)RulesIO.Load(rulesLocation.Name, nameof(AltitudeMapRules)); var inPointData = PointIO.OpenPointData(inDataLocation.Name, rules); var heightMap = GenerateAltitudeMap.Run(inPointData, rules); PointIO.SaveHeightImage(outDataLocation.Name, heightMap); PointIO.SaveMapData(outDataLocation.Name + ".bin", heightMap); }
/// <summary> /// Moves tectonic plates. /// </summary> private static void MovePlates() { var rulesLocation = InputFileName("Move Rules"); var plateDataLocation = InputFileName("Plate Data"); var inPointDataLocation = InputFileName("Source Point Data"); var outPointDataLocation = InputFileName("Destination Point Data"); var plateImageLocation = InputFileName("Image"); var rules = (MoveRules)RulesIO.Load(rulesLocation.Name, nameof(MoveRules)); var plateData = PlateIO.Open(plateDataLocation.Name); var inPointData = PointIO.OpenPointData(inPointDataLocation.Name, rules); var outPointData = MovePlatesData.Run(rules, plateData, inPointData); PointIO.SavePointData(outPointDataLocation.Name, rules, outPointData); PointIO.SavePointImage(plateImageLocation.Name, rules, outPointData); }
/// <summary> /// Generates rainfall map. /// </summary> private static void GenerateRainfall() { var rulesLocation = InputFileName("Rainfall Rules"); var inDataLocation = InputFileName("Height Map Data"); var outDataLocation = InputFileName("Rainfall Data"); var rules = (RainfallMapRules)RulesIO.Load(rulesLocation.Name, nameof(RainfallMapRules)); var heightMap = PointIO.OpenDoubleData(inDataLocation.Name + ".bin", 2 * rules.xHalfSize, rules.ySize); var rainfallMap = GenerateRainfallMap.Run(heightMap, rules); for (int i = 0; i < rainfallMap.GetLength(2); i++) { var rainfallMapTemp = new double[rainfallMap.GetLength(0), rainfallMap.GetLength(1)]; for (int x = 0; x < rainfallMap.GetLength(0); x++) { for (int y = 0; y < rainfallMap.GetLength(1); y++) { rainfallMapTemp[x, y] = rainfallMap[x, y, i]; } } PointIO.SaveHeightImage(outDataLocation.Name + i, rainfallMapTemp); PointIO.SaveMapData(outDataLocation.Name + i + ".bin", rainfallMapTemp); } }