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 FbxDocument AsciiToBinary(string data) { using (var s = data.ToStream()) { var reader = new FbxAsciiReader(s); return(reader.Read()); } }
static void Main(string[] args) { //var document = FbxIO.ReadBinary(args[0]); //FbxIO.WriteAscii(document, Path.GetDirectoryName(args[0]) + "/test_ascii.fbx"); var reader = new FbxAsciiReader(new FileStream(Path.GetDirectoryName(args[0]) + "/test_ascii.fbx", FileMode.Open)); var doc = reader.Read(); FbxIO.WriteAscii(doc, Path.GetDirectoryName(args[0]) + "/test_ascii_2.fbx"); }
/// <summary> /// Reads an ASCII FBX file /// </summary> /// <param name="path"></param> /// <returns>The top level document node</returns> public static FbxDocument ReadAscii(string path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } using (var stream = new FileStream(path, FileMode.Open)) { var reader = new FbxAsciiReader(stream); return(reader.Read()); } }