Example #1
0
 public VoxelBlock(BinaryReader reader)
 {
     children = new VoxelHolder[CHILD_DIMENSION, CHILD_DIMENSION, CHILD_DIMENSION];
     ++blockCount;
     for (byte xi = 0; xi < CHILD_DIMENSION; ++xi)
     {
         for (byte yi = 0; yi < CHILD_DIMENSION; ++yi)
         {
             for (byte zi = 0; zi < CHILD_DIMENSION; ++zi)
             {
                 children[xi, yi, zi] = VoxelHolder.deserialize(reader);
             }
         }
     }
 }
Example #2
0
        public void OnAfterDeserialize()
        {
            //			clearRenderers();
            //print("Deserializing");
            lock (this) {
                if (voxelData.Length > 0)
                {
                    MemoryStream stream = new MemoryStream(voxelData);
                    BinaryReader reader = new BinaryReader(stream);
                    head = (VoxelBlock)VoxelHolder.deserialize(reader);
                    stream.Close();
                }

                // relink renderers
                //relinkRenderers();
                enqueueJob(new LinkRenderersJob(this));
            }
        }
Example #3
0
        public bool import(string fileName)
        {
            clearRenderers();
            Stream       stream            = File.OpenRead(fileName);
            BinaryReader reader            = new BinaryReader(stream);
            ulong        fileFormatVersion = reader.ReadUInt64();

            if (fileFormatVersion != FILE_FORMAT_VERSION)
            {
                stream.Close();
                print("Wrong voxel file format version: " + fileFormatVersion + ", should be " + FILE_FORMAT_VERSION);
                return(false);
            }
            else
            {
                head  = (VoxelBlock)VoxelHolder.deserialize(reader);
                dirty = true;
                stream.Close();
                return(true);
            }
        }