public void TestRoads2() { var svg = new SVGParser(File.ReadAllText(@"C:\Users\Rhys\Documents\roads.svg")); var paths = svg.ToLinePaths(); var geom = new RoadGeometry(paths, TS1RoadTemplates.OLD_TOWN_DEFAULT_TEMPLATES); geom.GenerateIntersections(); geom.GenerateRoadGeometry(); //write result using (var file = File.Open(@"C:\Users\Rhys\Documents\testroad2.obj", FileMode.Create)) { SaveRoadResult(geom, file); } }
public void TestCombo() { var map = BasicMap(); var timer = new System.Diagnostics.Stopwatch(); timer.Start(); var heightmap = new SimplifiedHeightmap(512, map); heightmap.BuildSecondDerivative(); heightmap.GenerateFullTree(); heightmap.GenerateMesh(); timer.Stop(); Console.WriteLine("!!! Heightmap took " + timer.ElapsedMilliseconds + "ms."); timer.Restart(); var svg = new SVGParser(File.ReadAllText(@"C:\Users\Rhys\Documents\roads.svg")); var paths = svg.ToLinePaths(); var geom = new RoadGeometry(paths, TS1RoadTemplates.OLD_TOWN_DEFAULT_TEMPLATES); geom.GenerateIntersections(); geom.GenerateRoadGeometry(); timer.Stop(); Console.WriteLine("!!! Road took " + timer.ElapsedMilliseconds + "ms."); timer.Restart(); List <MeshProjector> projectors = new List <MeshProjector>(); foreach (var pair in geom.Meshes) { var mesh = pair.Value; var baseTris = new List <BaseMeshTriangle>(); for (int i = 0; i < heightmap.Indices.Count; i += 3) { baseTris.Add(new BaseMeshTriangle() { Vertices = new Vector3[] { heightmap.Vertices[heightmap.Indices[i]], heightmap.Vertices[heightmap.Indices[i + 1]], heightmap.Vertices[heightmap.Indices[i + 2]], } }); } var projTris = new List <MeshTriangle>(); for (int i = 0; i < mesh.Indices.Count; i += 3) { projTris.Add(new MeshTriangle() { Vertices = new Vector3[] { mesh.Vertices[mesh.Indices[i]].Position, mesh.Vertices[mesh.Indices[i + 1]].Position, mesh.Vertices[mesh.Indices[i + 2]].Position, }, TexCoords = new float[][] { mesh.Vertices[mesh.Indices[i]].TexCoords, mesh.Vertices[mesh.Indices[i + 1]].TexCoords, mesh.Vertices[mesh.Indices[i + 2]].TexCoords, } }); } var proj = new MeshProjector(baseTris, projTris); proj.Project(); projectors.Add(proj); } timer.Stop(); Console.WriteLine("!!! Projection took " + timer.ElapsedMilliseconds + "ms."); //write result using (var file = File.Open(@"C:\Users\Rhys\Documents\combined.obj", FileMode.Create)) { SaveResults(projectors, file); } }