private void Build() { filter.sharedMesh = ChunkBuilder.BuildChunk(filter.sharedMesh, chunk); if (filter.sharedMesh == null) { Destroy(gameObject); return; } GetComponent <Renderer>().sharedMaterials = blockSet.GetMaterials(filter.sharedMesh.subMeshCount); }
IEnumerator RenderChunk() { //Debug.Log ("Rendering chunk..."); bool isDone = false; ChunkMeshObject cmo = null; Thread t = new Thread(() => { cmo = ChunkBuilder.BuildChunk(this); isDone = true; }); t.Start(); while (!isDone) { yield return(null); } Mesh m = new Mesh(); m.name = "ChunkMesh-" + x + "-" + y; m.vertices = cmo.verts.ToArray(); m.triangles = cmo.tris.ToArray(); m.uv = cmo.uvs.ToArray(); m.RecalculateBounds(); m.RecalculateNormals(); m.RecalculateTangents(); if (GetComponent <MeshFilter> () == null) { this.gameObject.AddComponent <MeshFilter> ().mesh = m; this.gameObject.AddComponent <MeshRenderer> ().material = World.instance.material; } else { GetComponent <MeshFilter> ().mesh = m; } //Debug.Log ("Chunk " + x + "," + y + " renderered"); }
public override Chunk Process(Chunk chunk) { ChunkBuilder.BuildChunk(chunk, _device); return(chunk); }