Browse Source

BinaryConverter

David Catuhe 11 years ago
parent
commit
b06070a5cd

+ 6 - 0
Exporters/BinaryConverter/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
+</configuration>

+ 494 - 0
Exporters/BinaryConverter/BabylonLodMesh.cs

@@ -0,0 +1,494 @@
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.Net;
+
+using Vertice.Core;
+using BabylonExport.Core;
+using Newtonsoft.Json;
+
+
+namespace BabylonBinaryConverter
+{
+    public enum VertexAttributes
+    {
+        Undefined = 0,
+        Position = 2,
+        Color = 4,
+        Normal = 8,
+        Uv1 = 16,
+        Uv2 = 32,
+        HPos = 64
+    }
+
+    public enum DataType
+    {
+        Byte,
+        UByte,
+        Int16,
+        UInt16,
+        Int32,
+        UInt32,
+        Int64,
+        UInt64,
+        Float,
+        Double
+    }
+
+
+    [DataContract]
+    public class IncrMeshData
+    {
+        [DataMember]
+        public float[] positions { get; set; }
+
+        [DataMember]
+        public float[] colors { get; set; }
+
+        [DataMember]
+        public float[] normals { get; set; }
+
+        [DataMember]
+        public float[] uvs { get; set; }
+
+        [DataMember]
+        public float[] uvs2 { get; set; }
+
+        [DataMember]
+        public int[] indices { get; set; }
+
+        [DataMember]
+        public int[] matricesIndices { get; set; }
+
+        [DataMember]
+        public float[] matricesWeights { get; set; }
+
+        [DataMember]
+        public BabylonSubMesh[] subMeshes { get; set; }
+    }
+
+
+    [DataContract]
+    public class AttrDesc
+    {
+        [DataMember]
+        public int count;
+
+        [DataMember]
+        public int stride;
+
+        [DataMember]
+        public long offset;
+
+        [DataMember]
+        public DataType dataType;
+
+        
+        public AttrDesc()
+        {
+            count = 0;
+            stride = 0;
+            offset = 0;
+            dataType = DataType.Float;
+        }
+
+
+        public AttrDesc(int _count, int _stride, long _offset, DataType _dataType)
+        {
+            count = _count;
+            stride = _stride;
+            offset = _offset;
+            dataType = _dataType;
+        }
+    }
+
+
+    [DataContract]
+    public class BabylonLodMesh : BabylonMesh
+    {
+        [DataMember]
+        public int lod { get; set; }
+
+        [DataMember]
+        public float distance { get; set; }
+
+        [DataMember]
+        public string delayLoadingFile { get; set; }
+
+        [DataMember]
+        public float[] boundingBoxMinimum { get; set; }
+
+        [DataMember]
+        public float[] boundingBoxMaximum { get; set; }
+
+        [DataMember]
+        public bool hasUVs { get; set; }
+
+        [DataMember]
+        public bool hasUVs2 { get; set; }
+
+        [DataMember]
+        public bool hasColors { get; set; }
+
+        [DataMember]
+        public bool hasMatricesIndices { get; set; }
+
+        [DataMember]
+        public bool hasMatricesWeights { get; set; }
+
+        [DataMember]
+        public AttrDesc positionsAttrDesc { get; set; }
+
+        [DataMember]
+        public AttrDesc colorsAttrDesc { get; set; }
+
+        [DataMember]
+        public AttrDesc normalsAttrDesc { get; set; }
+
+        [DataMember]
+        public AttrDesc uvsAttrDesc { get; set; }
+
+        [DataMember]
+        public AttrDesc uvs2AttrDesc { get; set; }
+
+        [DataMember]
+        public AttrDesc indicesAttrDesc { get; set; }
+
+        [DataMember]
+        public AttrDesc matricesIndicesAttrDesc { get; set; }
+
+        [DataMember]
+        public AttrDesc matricesWeightsAttrDesc { get; set; }
+
+        [DataMember]
+        public AttrDesc combinedAttrDesc { get; set; }
+
+        [DataMember]
+        public VertexAttributes vertexAttributes { get; set; }
+        
+        const string fileEXT = ".binarymesh.babylon";
+
+        
+        public BabylonLodMesh() : base()
+        {
+            lod = 0;
+            distance = 0.0f;
+            delayLoadingFile = "";
+
+            positionsAttrDesc = new AttrDesc();
+            colorsAttrDesc = new AttrDesc();
+            normalsAttrDesc = new AttrDesc();
+            uvsAttrDesc = new AttrDesc();
+            uvs2AttrDesc = new AttrDesc();
+
+            indicesAttrDesc = new AttrDesc();
+
+            matricesIndicesAttrDesc = new AttrDesc();
+            matricesWeightsAttrDesc = new AttrDesc();
+
+            combinedAttrDesc = new AttrDesc();
+            vertexAttributes = VertexAttributes.Undefined;
+        }
+
+
+        public void Convert(string srcPath, string dstPath, bool _combined = false, int _lod = 0, float _distance = 0.0f)
+        {
+            lod = _lod;
+            distance = _distance;
+
+            if (Path.GetExtension(delayLoadingFile).CompareTo(".babylonmeshdata") == 0)
+                LoadMeshData(Path.Combine(srcPath, delayLoadingFile));
+
+            if (string.IsNullOrEmpty(delayLoadingFile))
+                delayLoadingFile = id + fileEXT;
+            else
+                delayLoadingFile = Path.GetFileNameWithoutExtension(delayLoadingFile) + fileEXT;
+
+            string fullPath = Path.Combine(dstPath, delayLoadingFile);
+
+            if (localMatrix == null)
+                localMatrix = Matrix.Identity.ToArray();
+
+            if (boundingBoxMinimum == null || boundingBoxMaximum == null)
+                CalculateBoundingBox();
+
+            if (!_combined)
+                MultipleBuffers(fullPath);
+
+            else
+                VertexBuffer(fullPath);
+        }
+
+
+        private void LoadMeshData(string srcFilename)
+        {
+            try
+            {
+                string filename = WebUtility.UrlDecode(srcFilename);
+
+                IncrMeshData meshData = JsonConvert.DeserializeObject<IncrMeshData>(File.ReadAllText(filename));
+
+                positions = meshData.positions;
+                colors = meshData.colors;
+                normals = meshData.normals;
+                uvs = meshData.uvs;
+                uvs2 = meshData.uvs2;
+                indices = meshData.indices;
+
+                matricesIndices = meshData.matricesIndices;
+                matricesWeights = meshData.matricesWeights;
+
+                subMeshes = meshData.subMeshes;
+            }
+            catch (Exception ex)
+            {
+                Console.ForegroundColor = ConsoleColor.Red;
+                Console.WriteLine();
+                Console.WriteLine(ex.Message);
+                Console.ForegroundColor = ConsoleColor.DarkCyan;
+                Console.WriteLine(ex);
+                Console.ResetColor();
+            }
+        }
+        
+        
+        private void MultipleBuffers(string fullPath)
+        {
+            try
+            {
+                using (var stream = File.Open(WebUtility.UrlDecode(fullPath), FileMode.Create))
+                {
+                    BinaryWriter writer = new BinaryWriter(stream);
+
+                    if (positions != null && positions.Length > 0)
+                    {
+                        positionsAttrDesc.count = positions.Length;
+                        positionsAttrDesc.stride = 3;
+                        positionsAttrDesc.offset = stream.Length;
+                        positionsAttrDesc.dataType = DataType.Float;
+
+                        for (int x = 0; x < positions.Length; x++)
+                            writer.Write(positions[x]);
+
+                        positions = null;
+                    }
+
+                    if (colors != null && colors.Length > 0)
+                    {
+                        colorsAttrDesc.count = colors.Length;
+                        colorsAttrDesc.stride = 3;
+                        colorsAttrDesc.offset = stream.Length;
+                        colorsAttrDesc.dataType = DataType.Float;
+
+                        for (int x = 0; x < colors.Length; x++)
+                            writer.Write(colors[x]);
+
+                        hasColors = true;
+
+                        colors = null;
+                    }
+
+                    if (normals != null && normals.Length > 0)
+                    {
+                        normalsAttrDesc.count = normals.Length;
+                        normalsAttrDesc.stride = 3;
+                        normalsAttrDesc.offset = stream.Length;
+                        normalsAttrDesc.dataType = DataType.Float;
+
+                        for (int x = 0; x < normals.Length; x++)
+                            writer.Write(normals[x]);
+
+                        normals = null;
+                    }
+
+                    if (uvs != null && uvs.Length > 0)
+                    {
+                        uvsAttrDesc.count = uvs.Length;
+                        uvsAttrDesc.stride = 2;
+                        uvsAttrDesc.offset = stream.Length;
+                        uvsAttrDesc.dataType = DataType.Float;
+
+                        for (int x = 0; x < uvs.Length; x++)
+                            writer.Write(uvs[x]);
+
+                        hasUVs = true;
+
+                        uvs = null;
+                    }
+
+                    if (uvs2 != null && uvs2.Length > 0)
+                    {
+                        uvs2AttrDesc.count = uvs2.Length;
+                        uvs2AttrDesc.stride = 2;
+                        uvs2AttrDesc.offset = stream.Length;
+                        uvs2AttrDesc.dataType = DataType.Float;
+
+                        for (int x = 0; x < uvs2.Length; x++)
+                            writer.Write(uvs2[x]);
+
+                        hasUVs2 = true;
+
+                        uvs2 = null;
+                    }
+
+                    if (indices != null && indices.Length > 0)
+                    {
+                        indicesAttrDesc.count = indices.Length;
+                        indicesAttrDesc.stride = 1;
+                        indicesAttrDesc.offset = stream.Length;
+                        indicesAttrDesc.dataType = DataType.Int32;
+
+                        for (int x = 0; x < indices.Length; x++)
+                            writer.Write(indices[x]);
+
+                        indices = null;
+                    }
+
+                    if (matricesIndices != null && matricesIndices.Length > 0)
+                    {
+                        matricesIndicesAttrDesc.count = matricesIndices.Length;
+                        matricesIndicesAttrDesc.stride = 1;
+                        matricesIndicesAttrDesc.offset = stream.Length;
+                        matricesIndicesAttrDesc.dataType = DataType.Int32;
+
+                        for (int x = 0; x < matricesIndices.Length; x++)
+                            writer.Write(matricesIndices[x]);
+
+                        hasMatricesIndices = true;
+
+                        matricesIndices = null;
+                    }
+
+                    if (matricesWeights != null && matricesWeights.Length > 0)
+                    {
+                        matricesWeightsAttrDesc.count = matricesWeights.Length;
+                        matricesWeightsAttrDesc.stride = 2;
+                        matricesWeightsAttrDesc.offset = stream.Length;
+                        matricesWeightsAttrDesc.dataType = DataType.Float;
+
+                        for (int x = 0; x < matricesWeights.Length; x++)
+                            writer.Write(matricesWeights[x]);
+
+                        hasMatricesWeights = true;
+
+                        matricesWeights = null;
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.ForegroundColor = ConsoleColor.Red;
+                Console.WriteLine();
+                Console.WriteLine(ex.Message);
+                Console.ForegroundColor = ConsoleColor.DarkCyan;
+                Console.WriteLine(ex);
+                Console.ResetColor();
+            }
+        }
+
+        
+        private void VertexBuffer(string fullPath)
+        {
+            combinedAttrDesc.count = positions.Length;
+            combinedAttrDesc.stride = 0;
+            combinedAttrDesc.offset = 0;
+
+            vertexAttributes = VertexAttributes.Undefined;
+
+
+            if (positions != null && positions.Length > 0)
+            {
+                vertexAttributes |= VertexAttributes.Position;
+                combinedAttrDesc.stride += 3;
+            }
+
+            if (colors != null && colors.Length > 0)
+            {
+                vertexAttributes |= VertexAttributes.Color;
+                combinedAttrDesc.stride += 4;
+            }
+
+            if (normals != null && normals.Length > 0)
+            {
+                vertexAttributes |= VertexAttributes.Normal;
+                combinedAttrDesc.stride += 3;
+            }
+
+            if (uvs != null && uvs.Length > 0)
+            {
+                vertexAttributes |= VertexAttributes.Uv1;
+                combinedAttrDesc.stride += 2;
+            }
+
+            if (uvs2 != null && uvs2.Length > 0)
+            {
+                vertexAttributes |= VertexAttributes.Uv2;
+                combinedAttrDesc.stride += 2;
+            }
+
+            
+            List<float> data = new List<float>();
+
+            using (var stream = File.Open(WebUtility.UrlDecode(fullPath), FileMode.Create))
+            {
+            }
+        }
+
+
+        private void CalculateBoundingBox()
+        {
+            Vector3 min = new Vector3(0.0f, 0.0f, 0.0f);
+            Vector3 max = new Vector3(0.0f, 0.0f, 0.0f);
+
+            if (positions != null && positions.Length > 0)
+            {
+                Vector3 src = new Vector3(positions[0], positions[1], positions[2]);
+                min = src;
+                max = src;
+
+                for (int x = 3; x < positions.Length; x += 3)
+                {
+                    if (x + 2 < positions.Length)
+                    {
+                        src.X = positions[x + 0];
+                        src.Y = positions[x + 1];
+                        src.Z = positions[x + 2];
+
+                        VecMin(src, ref min);
+                        VecMax(src, ref max);
+                    }
+                }
+            }
+
+            boundingBoxMinimum = min.ToArray();
+            boundingBoxMaximum = max.ToArray();
+        }
+
+
+        private void VecMin(Vector3 src, ref Vector3 dst)
+        {
+            if (src.X < dst.X)
+                dst.X = src.X;
+
+            if (src.Y < dst.Y)
+                dst.Y = src.Y;
+
+            if (src.Z < dst.Z)
+                dst.Z = src.Z;
+        }
+
+
+        private void VecMax(Vector3 src, ref Vector3 dst)
+        {
+            if (src.X > dst.X)
+                dst.X = src.X;
+
+            if (src.Y > dst.Y)
+                dst.Y = src.Y;
+
+            if (src.Z > dst.Z)
+                dst.Z = src.Z;
+        }
+    }
+}

+ 29 - 0
Exporters/BinaryConverter/BabylonLodScene.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+using BabylonExport.Core;
+
+namespace BabylonBinaryConverter
+{
+    [DataContract]
+    public class BabylonLodScene : BabylonScene
+    {
+        [DataMember]
+        public new BabylonLodMesh[] meshes { get; set; }
+
+
+        public BabylonLodScene(string outputPath) : base(outputPath)
+        {
+        }
+
+
+        public void Convert(string srcPath, string dstPath)
+        {
+            for (int x = 0; x < meshes.Length; x++)
+            {
+                meshes[x].Convert(srcPath, dstPath);
+            }
+        }
+    }
+}

+ 126 - 0
Exporters/BinaryConverter/BinaryConverter.csproj

@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>BabylonBinaryConverter</RootNamespace>
+    <AssemblyName>BabylonBinaryConverter</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <PublishUrl>C:\Temp\Converter\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>1</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <PublishWizardCompleted>true</PublishWizardCompleted>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <ManifestCertificateThumbprint>7346144549A904B3EB11D4D318746B02AF5F1A25</ManifestCertificateThumbprint>
+  </PropertyGroup>
+  <PropertyGroup>
+    <ManifestKeyFile>BinaryConverter_TemporaryKey.pfx</ManifestKeyFile>
+  </PropertyGroup>
+  <PropertyGroup>
+    <GenerateManifests>false</GenerateManifests>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignManifests>true</SignManifests>
+  </PropertyGroup>
+  <PropertyGroup>
+    <TargetZone>LocalIntranet</TargetZone>
+  </PropertyGroup>
+  <PropertyGroup>
+    <ApplicationManifest>Properties\app.manifest</ApplicationManifest>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <HintPath>..\packages\Newtonsoft.Json.5.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="Vertice.Core">
+      <HintPath>..\XNA - OBJ\BabylonExport.Core\Refs\Vertice.Core.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="BabylonLodMesh.cs" />
+    <Compile Include="BabylonLodScene.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+    <None Include="packages.config" />
+    <None Include="Properties\app.manifest" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\XNA - OBJ\BabylonExport.Core\BabylonExport.Core.csproj">
+      <Project>{ce70b051-fb63-420d-80c0-51cc03a214ba}</Project>
+      <Name>BabylonExport.Core</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include=".NETFramework,Version=v4.5">
+      <Visible>False</Visible>
+      <ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 122 - 0
Exporters/BinaryConverter/Program.cs

@@ -0,0 +1,122 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Net;
+using System.IO;
+
+using Newtonsoft.Json;
+using BabylonExport.Core;
+
+
+namespace BabylonBinaryConverter
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            string srcFilename = "";
+            string dstPath = "";
+            bool formatted = false;
+
+            try
+            {
+                if (args.Length < 2)
+                {
+                    DisplayUsage();
+                    return;
+                }
+
+                foreach (var arg in args)
+                {
+                    if(arg.ToLower() == "/formatted")
+                    {
+                        formatted = true;
+                    }
+                    else if (arg.Substring(0, 3).ToLower() == "/i:")
+                    {
+                        srcFilename = arg.Substring(3);
+                    }
+                    else if (arg.Substring(0, 3).ToLower() == "/o:")
+                    {
+                        dstPath = arg.Substring(3);
+                    }
+                    else
+                    {
+                        DisplayUsage();
+                    }
+                }
+
+                if (string.IsNullOrEmpty(srcFilename) || string.IsNullOrEmpty(dstPath))
+                {
+                    DisplayUsage();
+                    return;
+                }
+
+                string srcPath = Path.GetDirectoryName(srcFilename);
+                string dstFilename = "";
+                
+                if (!srcFilename.Contains(".incremental.babylon"))
+                    dstFilename = Path.Combine(dstPath, Path.GetFileNameWithoutExtension(srcFilename) + ".incremental.babylon");
+                else
+                    dstFilename = Path.Combine(dstPath, Path.GetFileName(srcFilename));
+
+                if (!Directory.Exists(dstPath))
+                {
+                    Directory.CreateDirectory(dstPath);
+                }
+
+                Console.WriteLine("Converting file " + WebUtility.UrlDecode(srcFilename) + " to binary in folder " + dstPath);
+
+                ParseBabylonSceneFileAsJson(srcPath, srcFilename, dstPath, dstFilename, formatted);
+
+                using (var debugFile = new StreamWriter(dstPath + @"\debug.txt", true))
+                {
+                    debugFile.Write("Generation of " + dstFilename + " successfull");
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.ForegroundColor = ConsoleColor.Red;
+                Console.WriteLine();
+                Console.WriteLine(ex.Message);
+                Console.ResetColor();
+
+                using (var debugFile = new StreamWriter(dstPath + @"\debug.txt", true))
+                {
+                    debugFile.Write(ex);
+                }
+            }
+        }
+
+
+        static void ParseBabylonSceneFileAsJson(string srcPath, string srcFilename, string dstPath, string dstFilename, bool formatted)
+        {
+            try
+            {
+                BabylonLodScene scene = JsonConvert.DeserializeObject<BabylonLodScene>(File.ReadAllText(WebUtility.UrlDecode(srcFilename)));
+                
+                scene.Convert(srcPath, dstPath);
+
+                File.WriteAllText(WebUtility.UrlDecode(dstFilename), JsonConvert.SerializeObject(scene, (formatted ? Formatting.Indented : Formatting.None)));
+            }
+            catch (Exception ex)
+            {
+                Console.ForegroundColor = ConsoleColor.Red;
+                Console.WriteLine();
+                Console.WriteLine(ex.Message);
+                Console.ForegroundColor = ConsoleColor.DarkCyan;
+                Console.WriteLine(ex);
+                Console.ResetColor();
+            }
+        }
+        
+        
+        static void DisplayUsage()
+        {
+            Console.WriteLine("Babylon binary converter usage: BabylonBinaryConverter.exe /i:\"source file\" /o:\"output folder\" /formatted");
+            Console.WriteLine("   /formatted to write formatted Json. The default is compressed.");
+        }
+    }
+}

+ 36 - 0
Exporters/BinaryConverter/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("BabylonBinaryConverter")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("BabylonBinaryConverter")]
+[assembly: AssemblyCopyright("Copyright ©  2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("155c78d1-0e27-4e85-863a-d96a418007cc")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 54 - 0
Exporters/BinaryConverter/Properties/app.manifest

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
+  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
+    <security>
+      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
+        <!-- UAC Manifest Options
+            If you want to change the Windows User Account Control level replace the 
+            requestedExecutionLevel node with one of the following.
+
+        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
+        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
+        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />
+
+            Specifying requestedExecutionLevel node will disable file and registry virtualization.
+            If you want to utilize File and Registry Virtualization for backward 
+            compatibility then delete the requestedExecutionLevel node.
+        -->
+        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
+      </requestedPrivileges>
+      <applicationRequestMinimum>
+        <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
+        <defaultAssemblyRequest permissionSetReference="Custom" />
+      </applicationRequestMinimum>
+    </security>
+  </trustInfo>
+  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
+    <application>
+      <!-- A list of all Windows versions that this application is designed to work with. 
+      Windows will automatically select the most compatible environment.-->
+      <!-- If your application is designed to work with Windows Vista, uncomment the following supportedOS node-->
+      <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>-->
+      <!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
+      <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
+      <!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
+      <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>-->
+      <!-- If your application is designed to work with Windows 8.1, uncomment the following supportedOS node-->
+      <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>-->
+    </application>
+  </compatibility>
+  <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
+  <!-- <dependency>
+    <dependentAssembly>
+      <assemblyIdentity
+          type="win32"
+          name="Microsoft.Windows.Common-Controls"
+          version="6.0.0.0"
+          processorArchitecture="*"
+          publicKeyToken="6595b64144ccf1df"
+          language="*"
+        />
+    </dependentAssembly>
+  </dependency>-->
+</asmv1:assembly>

+ 4 - 0
Exporters/BinaryConverter/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Newtonsoft.Json" version="5.0.4" targetFramework="net45" />
+</packages>

+ 24 - 0
Exporters/ExportToBabylon.sln

@@ -1,6 +1,10 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
+<<<<<<< HEAD
 # Visual Studio 2013
+=======
+# Visual Studio Express 2013 for Windows Desktop
+>>>>>>> cfb69ce8199c03d8c1e9b84a890218e1645564d5
 VisualStudioVersion = 12.0.30723.0
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BabylonExport.Core", "XNA - OBJ\BabylonExport.Core\BabylonExport.Core.csproj", "{CE70B051-FB63-420D-80C0-51CC03A214BA}"
@@ -9,6 +13,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BabylonExport.Interface", "
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BabylonExport", "XNA - OBJ\BabylonExport\BabylonExport.csproj", "{1E0A8EB2-7022-42E2-8970-F0374188A09D}"
 EndProject
+<<<<<<< HEAD
+=======
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BinaryConverter", "BinaryConverter\BinaryConverter.csproj", "{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}"
+EndProject
+>>>>>>> cfb69ce8199c03d8c1e9b84a890218e1645564d5
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -61,6 +70,21 @@ Global
 		{1E0A8EB2-7022-42E2-8970-F0374188A09D}.Release|x64.Build.0 = Release|x64
 		{1E0A8EB2-7022-42E2-8970-F0374188A09D}.Release|x86.ActiveCfg = Release|x86
 		{1E0A8EB2-7022-42E2-8970-F0374188A09D}.Release|x86.Build.0 = Release|x86
+<<<<<<< HEAD
+=======
+		{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}.Release|Any CPU.Build.0 = Release|Any CPU
+		{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}.Release|x64.ActiveCfg = Release|Any CPU
+		{78DEBAD0-4265-4237-9FB3-2AEB63EED7EF}.Release|x86.ActiveCfg = Release|Any CPU
+>>>>>>> cfb69ce8199c03d8c1e9b84a890218e1645564d5
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE