public static void CustomPlasmaBallCSharp() { //GameObject newMeshObject = new GameObject(); int cells = 2; //System.Diagnostics.Debug.WriteLine( "make plasma..." ); //PatchSphere sphere = new PatchSphere( 73 ); GameObject newMeshObject = new GameObject(); PatchSphere sphere = //new PatchSphere( 2 ); newMeshObject.AddComponent <PatchSphere>(); //Terrain terrain = new Terrain(); Mesh mesh = new Mesh(); { // fill mesh Vector3[] verts; Vector3[] norms; Vector2[] uvs; int[] tris; newMeshObject.AddComponent <MeshRenderer>(); sphere.ReadSphere(out verts, out norms, out uvs, out tris); mesh.vertices = verts; mesh.triangles = tris; mesh.uv = uvs; mesh.normals = norms; newMeshObject.AddComponent <MeshFilter>().mesh = mesh; AssetDatabase.CreateAsset(mesh, "Assets/Default Patch Shere-" + sphere.Cells + ".asset"); } }
public Patch(PatchSphere sphere, int cells) { this.sphere = sphere; this.cells = cells; heightmap = new float[cells * cells]; }