public static MeshFilter Data2Filter(VoxelMeshData data) { var mesh = VoxelBuilder.Data2Mesh(data); var filter = VoxelBuilder.Mesh2Filter(mesh); return(filter); }
public static MeshFilter Struct2Filter(VoxelStruct vs) { var data = Struct2DataInCache(vs); var mesh = VoxelBuilder.Data2Mesh(data); var filter = VoxelBuilder.Mesh2Filter(mesh); return(filter); }
public static Task FilterAddCollider(MeshFilter filter, FilterAddColliderReturn ret) { Task task = new Task(); TaskManager.PushFront(task, delegate() { ret(VoxelBuilder.FilterAddCollider(filter)); }); return(task); }
public static Task FilterAddRenderer(MeshFilter filter, Material material, FilterAddRendererReturn ret) { Task task = new Task(); TaskManager.PushFront(task, delegate() { ret(VoxelBuilder.FilterAddRenderer(filter, material)); }); return(task); }
public static Task Mesh2Filter(Mesh mesh, Mesh2FilterReturn ret) { Task task = new Task(); TaskManager.PushFront(task, delegate() { ret(VoxelBuilder.Mesh2Filter(mesh)); }); return(task); }
public static Task Data2Mesh(VoxelMeshData data, Data2MeshReturn ret) //创建mesh { Task task = new Task(); TaskManager.PushFront(task, delegate() { ret(VoxelBuilder.Data2Mesh(data)); }); return(task); }
public static VoxelMeshData Struct2DataInCache(VoxelStruct vs) { string md5 = MagicaVoxelFormater.GetMd5(vs); VoxelMeshData data = LoadFromCache(GetKey(md5)); if (data == null) { data = VoxelBuilder.Struct2Data(vs); SaveToCache(GetKey(md5), data); } return(data); }
public static VoxelGeometry.MeshData Struct2DataInCache(VoxelStruct vs) { return(VoxelBuilder.Struct2Data(vs)); /* * string md5 = MagicaVoxelFormater.GetMd5 (vs); * VoxelGeometry.MeshData data = VoxelDirectorFile.LoadFromFile (VoxelDirectorFile.GetKey(md5)); * * if(data == null){ * data = VoxelBuilder.Struct2Data (vs); * VoxelDirectorFile.SaveToFile (VoxelDirectorFile.GetKey(md5), data); * } * return data; */ }
static public GameObject CreateMesh(VoxelStruct vs, Transform parent, Material material, string name = "Voxel") { var data = VoxelBuilderHelper.Struct2DataInCache(vs); var mesh = VoxelBuilder.Data2Mesh(data); var filter = VoxelBuilder.Mesh2Filter(mesh); VoxelBuilder.FilterAddRenderer(filter, material); filter.transform.SetParent(parent); filter.transform.localEulerAngles = Vector3.zero; filter.transform.localPosition = Vector3.zero; filter.gameObject.layer = parent.gameObject.layer; filter.name = name; return(filter.gameObject); }
public static GameObject Building(GameObject obj, System.IO.BinaryReader br, Material material, int reversal = 0) { MagicaVoxel magica = MagicaVoxelFormater.ReadFromBinary(br); VoxelStruct vs = VoxelStruct.Reversal(magica.vs, reversal); // VoxelBuilder.Reversal(magica.vs, reversal); var data = VoxelBuilder.Struct2Data(vs); // VoxelBuilderHelper.Struct2DataInCache (vs); var mesh = VoxelBuilder.Data2Mesh(data); var filter = VoxelBuilder.Mesh2Filter(mesh); VoxelBuilder.FilterAddRenderer(filter, material); filter.transform.SetParent(obj.transform); filter.transform.localEulerAngles = Vector3.zero; filter.transform.localPosition = data.offset; filter.gameObject.layer = obj.layer; filter.name = "Voxel"; return(filter.gameObject); }
// Update is called once per frame void Update() { if (_building == true && _voxFile != null) { init(); if (_voxFile != null) { var vs = MagicaVoxelFormater.ReadFromFile(_voxFile).vs; var data = VoxelBuilder.Struct2Data(vs); var mesh = VoxelBuilder.Data2Mesh(data); var filter = VoxelBuilder.Mesh2Filter(mesh); VoxelBuilder.FilterAddRenderer(filter, this._material); filter.transform.SetParent(this.transform); filter.transform.localEulerAngles = Vector3.zero; filter.transform.localPosition = data.offset; filter.gameObject.layer = this.gameObject.layer; filter.name = "Voxel"; } _building = false; } }