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); } } }
/// <summary> /// Reads a binary FBX file /// </summary> /// <param name="path"></param> /// <returns>The top level document node</returns> public static FbxDocument ReadBinary(string path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } using (var stream = new FileStream(path, FileMode.Open)) { var reader = new FbxBinaryReader(stream); return(reader.Read()); } }