/// <summary> /// Load a certain mesh. /// </summary> public void SetLevel(int level) { levelIndex = level; double tFactor = 1; int source = 42; int manPos = 42; Settings.cotLimit = 10000; switch (level) { case 0: default: earth.GetComponent<MeshFilter>().mesh = highG; SetTexture(2); source = 1537; manPos = 1947; break; case 1: earth.GetComponent<MeshFilter>().mesh = bague; SetTexture(0); source = 280; manPos = 230; break; case 2: earth.GetComponent<MeshFilter>().mesh = cow; SetTexture(3); source = 429; manPos = 2129; break; case 3: case 6: earth.GetComponent<MeshFilter>().mesh = triceratops; SetTexture(4); Settings.cotLimit = 5; source = 42; manPos = 918; break; case 4: earth.GetComponent<MeshFilter>().mesh = horse; SetTexture(5); tFactor = 10; source = 435; manPos = 31107; break; case 5: earth.GetComponent<MeshFilter>().mesh = road; SetTexture(1); source = 285; manPos = 883; break; case 7: earth.GetComponent<MeshFilter>().mesh = sphere3; SetTexture(7); source = 3341; manPos = 7073; break; case 8: earth.GetComponent<MeshFilter>().mesh = sphere; SetTexture(7); source = 42; manPos = 775; break; case 9: earth.GetComponent<MeshFilter>().mesh = sphere2; SetTexture(7); source = 42; manPos = 775; break; case 11: earth.GetComponent<MeshFilter>().mesh = hemisphere; SetTexture(7); source = 1331; manPos = 475; break; case 12: earth.GetComponent<MeshFilter>().mesh = skull; SetTexture(8); source = 5794; manPos = 781; break; case 10: earth.GetComponent<MeshFilter>().mesh = dragon; SetTexture(6); source = 7561; manPos = 7284; break; } roadBase.SetActive(level == 5); hemiCap.SetActive(level == 11); skullBase.SetActive(level == 12); fire.gameObject.SetActive(level == 10); // Adjust settings if (useDefaultSettings) { Settings.tFactor = tFactor; Settings.defaultSource = new List<int>(); Settings.defaultSource.Add(source); Settings.initialManPos = manPos; inputT.text = Settings.tFactor.ToString(); } else { Settings.defaultSource = new List<int>(); foreach (Vertex sourceVertex in hg.s) { Settings.defaultSource.Add(sourceVertex.index); } Settings.initialManPos = man.coord.triangle.index; } // Set collider to detect mouse hit earth.GetComponent<MeshCollider>().sharedMesh = earth.GetComponent<MeshFilter>().mesh; // Build geometry data g = new Geometry(earth.GetComponent<MeshFilter>().mesh); if (level == 6) { // Fix certain broken triangles for the triceratops g.FixVertex(758); g.FixVertex(295); g.FixVertex(395); g.FixVertex(2449); } // Start heat method hg = new HeatGeodesics(g, Settings.useCholesky, Settings.useAccurateMultisource); hg.Initialize(); List<Vertex> sources = new List<Vertex>(); foreach (int ind in Settings.defaultSource) { sources.Add(g.vertices[ind]); lastClickedVertex = g.vertices[ind]; } hg.CalculateGeodesics(sources); // Spawn the little man if (man.isActiveAndEnabled) { man.GetReady(g, hg, g.faces[Settings.initialManPos]); } // Put the mark at the source vertices if (useDefaultSettings) { foreach (GameObject oldPin in pins) { Destroy(oldPin); } pins.Clear(); foreach (int ind in Settings.defaultSource) { GameObject newPin = Instantiate(pin); pins.Add(newPin); newPin.transform.position = g.vertices[ind].p; newPin.transform.rotation = Quaternion.LookRotation(g.vertices[ind].CalculateNormalTri()); } } // Update counter triangleCounter.text = "Triangle Count = " + g.faces.Count; if (visualState != 0) { if (useDefaultSettings) { VisualizeGradient(visualState == 2); } else { UpdateVisualGradient(); } } }
/// <summary> /// Begins to walk on a mesh providing the geodesics. /// Begins at the center of the triangle startSpot. /// </summary> public void GetReady(Geometry g, HeatGeodesics nav, Face startSpot) { coord = new SurfaceObject(g, nav, startSpot); UpdatePosition(); ready = true; }