public void modifyVerticeHeights()
{
// Get mesh of planet
this.mesh = GetComponent<MeshFilter>().sharedMesh;
// Get copy of vertices
// Hmmm... do we have to clone these? Maybe, but maybe we can reuse them?
this.vertices = (Vector3[]) this.mesh.vertices.Clone();
this.flyingVertices = (Vector3[]) this.mesh.vertices.Clone();
// Convert vertices to global coordiantes
for (int i = 0; i < mesh.vertexCount; ++i)
{
// get global position
this.vertices[i] = this.transform.TransformPoint(this.vertices[i]);
this.flyingVertices[i] = this.vertices[i];
// Get angle to planet
Vector3 angleToPlanet = this.vertices[i] - this.transform.position;
// Adjust vertice a tiny bit up
this.vertices[i] += (angleToPlanet.normalized * this.verticeHeight);
this.flyingVertices[i] += (angleToPlanet.normalized * this.flyingVerticeHeight);
}
}
public override void OnInspectorGUI() { DrawDefaultInspector(); if (GUILayout.Button("Bake")) { Debug.Log("beggining baking"); foreach (Object targ in targets) { VertexNavigation vertNav = targ as VertexNavigation; vertNav.buildTable(); } Debug.Log("done baking"); } if (GUILayout.Button("Kill Bake")) { foreach (Object targ in targets) { VertexNavigation vertNav = targ as VertexNavigation; vertNav.killTable(); } Debug.Log("Killed table"); } if (GUILayout.Button("Modify Vertice Height")) { Debug.Log("Modifying height of vertices"); foreach (Object targ in targets) { VertexNavigation vertNav = targ as VertexNavigation; vertNav.modifyVerticeHeights(); } Debug.Log("finished modifying height of vertices"); } if (GUILayout.Button("Set Average Vertex Length")) { foreach (Object targ in targets) { VertexNavigation vertNav = targ as VertexNavigation; vertNav.setAverageVerticeLength(); Debug.Log("average vertex length: " + vertNav.avgVertexlength); } } }