public Task buildTask(string name, VoxelStruct vs, GeometryResult cb) { VoxelGeometry.MeshData data = null; TaskPack tp = new TaskPack(delegate(){ vs.arrange(); string md5 = VoxelFormater.GetMd5(vs); data = this.LoadFromFile(GetKey(md5)); if (data == null) { return(buildData(vs, delegate(VoxelGeometry.MeshData result) { data = result; // Debug.Log(md5); this.SaveToFile(GetKey(md5), data); })); } return(new Task()); }); TaskManager.PushBack(tp, delegate { if (this.gameObject.GetComponent <VoxelMesh>() == null) { this.gameObject.AddComponent <VoxelMesh>(); } VoxelMesh mesh = VoxelGeometry.Draw(name, data, this.gameObject, this._material); mesh.vs = vs; cb(mesh); }); return(tp); }
public VoxelMesh draw(string name, VoxelStruct vs, VoxelGeometry.MeshData data, GameObject obj = null) { if (obj == null) { obj = this.gameObject; } VoxelMesh mesh = VoxelGeometry.Draw(name, data, obj, this._material); mesh.vs = vs; return(mesh); }
public VoxelMesh build(VoxelStruct vs, GameObject obj = null) { //VoxelData[] datas = vs.datas.ToArray (); if (obj == null) { obj = this.gameObject; } VoxelGeometry.MeshData data = BuildMeshData(vs); VoxelMesh mesh = VoxelGeometry.Draw("Mesh", data, obj, this._material); mesh.vs = vs; return(mesh); }