Beispiel #1
0
        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);
                        }
                    }
        }
Beispiel #2
0
        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");
        }
Beispiel #3
0
        public static void CompareAsciiFiles(string filename)
        {
            var path     = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            var testFile = Path.Combine(path, "Files", filename);
            var isBinary = FbxIO.IsBinaryFbx(testFile);

            Assert.False(isBinary);
            var documentNode = FbxIO.Read(testFile);

            using (var tempStream = new MemoryStream())
            {
                FbxIO.WriteAscii(documentNode, tempStream);
                tempStream.Position = 0;

                var originalBuffer = string.Empty;
                using (StreamReader originalStream = new StreamReader(testFile))
                {
                    while (originalStream.EndOfStream)
                    {
                        originalBuffer += FilterLine(originalStream.ReadLine());
                    }
                }

                var newBuffer = string.Empty;
                using (StreamReader newStream = new StreamReader(tempStream))
                {
                    while (newStream.EndOfStream)
                    {
                        newBuffer += FilterLine(newStream.ReadLine());
                    }
                }

                Assert.True(originalBuffer.Length == newBuffer.Length, $"Unexpected size comparisson");

                var identical = true;
                for (var i = 0; i < newBuffer.Length; i++)
                {
                    if (originalBuffer[i] != newBuffer[i])
                    {
                        identical = false;
                        break;
                    }
                }

                Assert.True(identical, $"Files data did not match as expected");
            }
        }
Beispiel #4
0
        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
        }
Beispiel #5
0
        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);
        }