Finished road generator

This commit is contained in:
2015-05-29 19:03:08 +03:00
parent 1304499b66
commit 54b833b620
21 changed files with 638 additions and 169 deletions

View File

@ -39,10 +39,10 @@ public class TerrainGeneratorScript : MonoBehaviour
};
water.triangles = new[] { 0, 1, 2, 2, 1, 3 };
water.uv = new[] {
new Vector2(0, 0),
new Vector2(0, 1),
new Vector2(1, 0),
new Vector2(1, 1)
new UnityEngine.Vector2(0, 0),
new UnityEngine.Vector2(0, 1),
new UnityEngine.Vector2(1, 0),
new UnityEngine.Vector2(1, 1)
};
water.RecalculateNormals();
@ -102,7 +102,27 @@ public class TerrainGeneratorScript : MonoBehaviour
yield return null;
// Set up textures
SetupSplatmaps(terrainData);
//SetupSplatmaps(terrainData);
// -- DEBUG --
foreach (var center in map.PopulationCenters)
Debug.DrawLine(new Vector3(center.Y, 0, center.X), new Vector3(center.Y, map.Biome.Height, center.X), Color.yellow, 100000);
// Debug - draw lines
if (map != null && map.RoadNetwork != null)
{
foreach (var segment in map.RoadNetwork.ArticulationSegments)
{
Color color = (segment.Value.LanesTo1 >= 3) ? Color.magenta : Color.red;
Debug.DrawLine(new Vector3(segment.Value.Terminal1.Y, map.Biome.Height / 2, segment.Value.Terminal1.X), new Vector3(segment.Value.Terminal2.Y, map.Biome.Height / 2, segment.Value.Terminal2.X), color, 10000);
}
foreach (var node in map.RoadNetwork.Nodes)
{
Debug.DrawLine(new Vector3(node.Value.Y, map.Biome.Height / 2, node.Value.X), new Vector3(node.Value.Y, map.Biome.Height / 2 + 5, node.Value.X), Color.blue, 10000);
}
}
}
private void SetupSplatmaps(TerrainData terrainData)
@ -162,4 +182,18 @@ public class TerrainGeneratorScript : MonoBehaviour
void Update()
{
}
void OnGUI()
{
Event e = Event.current;
if (e.type == EventType.KeyDown)
{
if (e.keyCode == KeyCode.Home)
{
Logger.Warning("Writing to file...");
Logger.DumpMap(map, "map.map");
Logger.Warning("Wrote map to file.");
}
}
}
}