예제 #1
0
        public static void Save(Vox vox, ITopoArray <byte> topArray)
        {
            Size size = null;

            foreach (var chunk in vox.Chunks)
            {
                if (chunk is Size)
                {
                    size = (Size)chunk;
                }
                else if (chunk is Xyzi xyzi)
                {
                    Save(size, xyzi, topArray);
                    return;
                }
            }
        }
예제 #2
0
        public static ITopoArray <byte> ToTopoArray(Vox vox)
        {
            Size size = null;

            foreach (var chunk in vox.Chunks)
            {
                if (chunk is Size)
                {
                    size = (Size)chunk;
                }
                else if (chunk is Xyzi xyzi)
                {
                    return(Load(size, xyzi));
                }
            }
            throw new Exception();
        }
예제 #3
0
        public static void Write(BinaryWriter writer, Vox vox)
        {
            writer.Write(VOX_);
            writer.Write(vox.Version);
            writer.Write(MAIN);
            writer.Write(0);
            var childrenSizePos = writer.Seek(0, SeekOrigin.Current);

            writer.Write(0); // Will be filled in in retrospect
            foreach (var chunk in vox.Chunks)
            {
                WriteChunk(writer, chunk);
            }
            var endPos = writer.Seek(0, SeekOrigin.Current);

            writer.Seek((int)childrenSizePos, SeekOrigin.Begin);
            writer.Write((int)(endPos - childrenSizePos - 4));
        }