private void TestCommon(byte[] data, bool isBinary) { // Binary using (var streamIn = new MemoryStream(data)) using (var streamOut = new MemoryStream()) using (var streamTmp = new MemoryStream()) { if (isBinary) { var reader = new FbxBinaryReader(streamIn); var doc = reader.Read(); FbxIO.WriteAscii(doc, streamOut); // read output again and ensure for correct output data streamOut.Position = 0; reader = new FbxBinaryReader(streamOut); FbxIO.WriteBinary(doc, streamTmp); } else { var reader = new FbxAsciiReader(streamIn); var doc = reader.Read(); FbxIO.WriteAscii(doc, streamOut); // read output again and ensure for correct output data streamOut.Position = 0; reader = new FbxAsciiReader(streamOut); FbxIO.WriteAscii(doc, streamTmp); } } }
public static void CompareBinaryFiles(string filename) { var testFile = Path.Combine(PathHelper.FilesPath, filename); var originalData = File.ReadAllBytes(testFile); var isBinary = FbxIO.IsBinaryFbx(testFile); Assert.True(isBinary); var documentNode = FbxIO.Read(testFile); using (var newStream = new MemoryStream()) { FbxIO.WriteBinary(documentNode, newStream); var newData = newStream.ToArray(); Assert.True(newData.Length <= originalData.Length, $"Unexpected size comparisson"); var identical = true; for (var i = 0; i < newData.Length; i++) { if (originalData[i] != newData[i]) { identical = false; break; } } Assert.True(identical, $"Files data did not match as expected"); } }
static void Test1() { string dir = @"C:\Users\dell\AppData\Local\Colossal Order\Cities_Skylines\Addons\Import\ARDumps\"; string file1 = "RoadMediumNode._ascii.fbx"; var doc = FbxIO.ReadAscii(dir + file1); string fileA = "testA_" + file1; FbxIO.WriteAscii(doc, dir + fileA); doc = FbxIO.ReadAscii(dir + fileA); string fileB = "testB_" + file1; FbxIO.WriteBinary(doc, dir + fileB); // i can't open this doc = FbxIO.ReadBinary(dir + fileB); FbxIO.WriteAscii(doc, dir + "testC_" + file1); // i can open this }
static void Test4() { Test3(); string dir = @"C:\Users\dell\AppData\Local\Colossal Order\Cities_Skylines\Addons\Import\ARDumps\"; string file1 = "RoadMediumNode._ascii.fbx"; // can open this string file2 = "TEST3_RoadMediumNode.binary.fbx"; // can open this string file3 = "TEST3_RoadMediumNode.ascii.fbx"; string fileB = "TEST3B_RoadMediumNode.binary.fbx"; Console.WriteLine("reading binary ..."); var doc1 = FbxIO.ReadBinary(dir + file2); FbxIO.WriteAscii(doc1, dir + file3); var doc2 = FbxIO.ReadAscii(dir + file3); doc1.Diff(doc2); FbxIO.WriteBinary(doc2, dir + fileB); }
public static void ExportBinaryFbx(this Mesh mesh, string path) => FbxIO.WriteBinary(mesh.ToFBXDocument(), path);