public void ExportBMD(string fileName, bool isBDL) { string outDir = Path.GetDirectoryName(fileName); string fileNameNoExt = Path.GetFileNameWithoutExtension(fileName); fileNameNoExt = fileNameNoExt.Split('.')[0]; if (isBDL) { fileName = Path.Combine(outDir, fileNameNoExt + ".bdl"); } else { fileName = Path.Combine(outDir, fileNameNoExt + ".bmd"); } using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { EndianBinaryWriter writer = new EndianBinaryWriter(stream, Endian.Big); if (isBDL) { writer.Write("J3D2bdl4".ToCharArray()); } else { writer.Write("J3D2bmd3".ToCharArray()); } writer.Write(0); // Placeholder for file size if (isBDL) { writer.Write(9); // Number of sections; bmd has 8, bdl has 9 } else { writer.Write(8); } writer.Write("SuperBMD - Gamma".ToCharArray()); Scenegraph.Write(writer, packetCount, vertexCount); VertexData.Write(writer); SkinningEnvelopes.Write(writer); PartialWeightData.Write(writer); Joints.Write(writer); Shapes.Write(writer); Materials.Write(writer); if (isBDL) { MatDisplayList.Write(writer); } Textures.Write(writer); writer.Seek(8, SeekOrigin.Begin); writer.Write((int)writer.BaseStream.Length); } }
public void Export(string fileName) { using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { EndianBinaryWriter writer = new EndianBinaryWriter(stream, Endian.Big); writer.Write("J3D2bmd3".ToCharArray()); writer.Write(0); // Placeholder for file size writer.Write(8); // Number of sections; bmd has 8, bdl has 9 writer.Write("SVR3".ToCharArray()); writer.Write(-1); writer.Write((long)-1); Scenegraph.Write(writer, packetCount, vertexCount); VertexData.Write(writer); SkinningEnvelopes.Write(writer); PartialWeightData.Write(writer); Joints.Write(writer); Shapes.Write(writer); Materials.Write(writer); Textures.Write(writer); writer.Seek(8, SeekOrigin.Begin); writer.Write((int)writer.BaseStream.Length); } }