public byte[] Serialize(Tag tag, CompressionInfo boundingBox) { RawOffset = tag.AddRaw(mesh.Serialize(this, boundingBox, out Resources)); MemoryStream stream = new MemoryStream(Size); BinaryWriter bw = new BinaryWriter(stream); bw.Write(buffer); stream.Seek(0, SeekOrigin.Begin); VertexCount = (short)mesh.Vertices.Length; TriangleCount = (short)(mesh.Indices.Length - 2); VertexType = VertexType.Rigid; CompressionFlags = Compression.Position | Compression.Texcoord; bw.Write((int)VertexType); bw.Write(VertexCount); bw.Write(TriangleCount); stream.Position = 26; bw.Write((int)CompressionFlags); stream.Position = 56; bw.Write(RawOffset);//* bw.Write(0);//* bw.Write(RawHeaderSize); bw.Write(RawDataSize); if (!tag.TagReferences.Contains(tag.Filename)) { tag.TagReferences.Add(tag.Filename); } bw.Write(tag.TagReferences.IndexOf(tag.Filename)); bw.Close(); return stream.GetBuffer(); }