Exemplo n.º 1
0
        public void Write(Stream stream)
        {
            using (var ms = new MemoryStream())
                using (var writer = new BinaryWriter(ms))
                {
                    var text   = new TextTable();
                    var header = new Header {
                        Version = 2
                    };

                    writer.Write(Identifier);
                    header.Write(writer);

                    WriteBones(writer, text, ref header);
                    WriteVertexArrays(writer, ref header);
                    WriteTriangles(writer, ref header);
                    WriteMeshes(writer, text, ref header);
                    WriteAnimations(writer, text, ref header);

                    var textArray = text.ToArray();
                    header.TextOffset = (int)ms.Position;
                    header.TextCount  = textArray.Length;
                    writer.Write(textArray);

                    header.FileSize = (int)ms.Length;
                    ms.Position     = Identifier.Length;
                    header.Write(writer);

                    ms.Position = 0;
                    ms.CopyTo(stream);
                }
        }