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); }
private void readVoxFile(TextAsset voxFile) { Stream sw = new MemoryStream(voxFile.bytes); System.IO.BinaryReader br = new System.IO.BinaryReader(sw); var vs = VoxelFormater.ReadFromMagicaVoxel(br); SplitVoxel split = new SplitVoxel(vs); for (int i = 0; i < _boxes.Count; ++i) { split.addBox(_boxes[i]); } VoxelStruct[] vses = split.doIt(); _items.Clear(); for (int i = 0; i < vses.Length; ++i) { vses [i].arrange(); string md5 = VoxelFormater.GetMd5(vses [i]); Item item = new Item(); item.voxel = vses [i]; item._MD5 = md5; item.data = CreateData(md5, vses [i]); _items.Add(item); } }
private void readVoxFile(TextAsset voxFile) { vs_ = createStruct(voxFile); vs_.arrange(); this._md5 = VoxelFormater.GetMd5(vs_); this.data_ = createMeshData(this._md5); this.gameObject.name = voxFile.name; }
public static VoxelGeometry.MeshData BuildMeshData(VoxelStruct vs) { vs.arrange(); string md5 = VoxelFormater.GetMd5(vs); VoxelGeometry.MeshData data = LoadFromFile(GetKey(md5)); if (data == null) { data = CreateMeshData(vs); SaveToFile(GetKey(md5), data); } return(data); }