예제 #1
0
        private void readVoxFile(TextAsset voxFile)
        {
            Stream sw = new MemoryStream(voxFile.bytes);

            System.IO.BinaryReader br    = new System.IO.BinaryReader(sw);
            MagicaVoxel            magic = null;
            var        vs    = MagicaVoxelFormater.ReadFromBinary(br).vs;
            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  = MagicaVoxelFormater.GetMd5(vses [i]);
                Item   item = new Item();
                item.voxel = vses [i];
                item._MD5  = md5;
                //item.data = CreateData (md5, vses [i]);
                _items.Add(item);
            }
        }
예제 #2
0
        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);
        }