Fixed unity terrain generation bug.
This commit is contained in:
@ -45,10 +45,14 @@ namespace TransportGame.Generator
|
||||
|
||||
// Generate water level
|
||||
float waterAmount = random.NextSingle(map.Biome.Moisture.Minimum, map.Biome.Moisture.Maximum);
|
||||
map.WaterLevel = Mathf.Pow(waterAmount, ConfigurationManager.TerrGenConfig.WaterNonLinearPower)
|
||||
* (map.Biome.HeightRange.Maximum - map.Biome.HeightRange.Minimum) + map.Biome.HeightRange.Minimum;
|
||||
map.WaterLevel = Mathf.Pow(waterAmount, ConfigurationManager.TerrGenConfig.WaterNonLinearPower) * map.Biome.Height;
|
||||
|
||||
DumpData(map, "1generated.map");
|
||||
|
||||
// Simulate water erosion
|
||||
//Erode(map);
|
||||
//DumpData(map, "2eroded.map");
|
||||
|
||||
DumpData(map);
|
||||
return map;
|
||||
}
|
||||
|
||||
@ -64,14 +68,21 @@ namespace TransportGame.Generator
|
||||
{
|
||||
for (int x = 0; x < map.Width; ++x)
|
||||
for (int y = 0; y < map.Height; ++y)
|
||||
map[x, y] = Noise.Generate(x, y, map.Biome.HeightRange.Minimum, map.Biome.HeightRange.Maximum);
|
||||
map[x, y] = Noise.Generate(x, y, 0, 1);
|
||||
}
|
||||
|
||||
private void DumpData(Map map)
|
||||
//private void Erode(Map map)
|
||||
//{
|
||||
// float[,] water = new float[map.Width, map.Height];
|
||||
|
||||
|
||||
//}
|
||||
|
||||
private void DumpData(Map map, string filename)
|
||||
{
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(Map));
|
||||
|
||||
using (StreamWriter writer = new StreamWriter(Path.Combine(Logger.LogsDirectory, "mapdump.map")))
|
||||
using (StreamWriter writer = new StreamWriter(Path.Combine(Logger.LogsDirectory, filename)))
|
||||
{
|
||||
serializer.Serialize(writer, map);
|
||||
writer.Close();
|
||||
|
Reference in New Issue
Block a user