Esempio n. 1
0
        public void WriteMaterial(CryEngine cryEngine)
        {
            if (cryEngine.Materials == null)
            {
                Utils.Log(LogLevelEnum.Debug, "No materials loaded");
                return;
            }

            if (!this.OutputFile_Material.Directory.Exists)
            {
                this.OutputFile_Material.Directory.Create();
            }

            using (StreamWriter file = new StreamWriter(this.OutputFile_Material.FullName))
            {
                file.WriteLine("# cgf-converter .mtl export version {0}", Assembly.GetExecutingAssembly().GetName().Version.ToString());
                file.WriteLine("#");
                foreach (CryEngine_Core.Material material in cryEngine.Materials)
                {
#if DUMP_JSON
                    File.WriteAllText(String.Format("_material-{0}.json", material.Name.Replace(@"/", "").Replace(@"\", "")), material.ToJSON());
#endif

                    file.WriteLine("newmtl {0}", material.Name);
                    if (material.Diffuse != null)
                    {
                        file.WriteLine("Ka {0:F6} {1:F6} {2:F6}", material.Diffuse.Red, material.Diffuse.Green, material.Diffuse.Blue);    // Ambient
                        file.WriteLine("Kd {0:F6} {1:F6} {2:F6}", material.Diffuse.Red, material.Diffuse.Green, material.Diffuse.Blue);    // Diffuse
                    }
                    else
                    {
                        Utils.Log(LogLevelEnum.Debug, "Skipping Diffuse for {0}", material.Name);
                    }
                    if (material.Specular != null)
                    {
                        file.WriteLine("Ks {0:F6} {1:F6} {2:F6}", material.Specular.Red, material.Specular.Green, material.Specular.Blue); // Specular
                        file.WriteLine("Ns {0:F6}", material.Shininess / 255D);                                                            // Specular Exponent
                    }
                    else
                    {
                        Utils.Log(LogLevelEnum.Debug, "Skipping Specular for {0}", material.Name);
                    }
                    file.WriteLine("d {0:F6}", material.Opacity); // Dissolve

                    file.WriteLine("illum 2");                    // Highlight on. This is a guess.

                    // Phong materials

                    // 0. Color on and Ambient off
                    // 1. Color on and Ambient on
                    // 2. Highlight on
                    // 3. Reflection on and Ray trace on
                    // 4. Transparency: Glass on, Reflection: Ray trace on
                    // 5. Reflection: Fresnel on and Ray trace on
                    // 6. Transparency: Refraction on, Reflection: Fresnel off and Ray trace on
                    // 7. Transparency: Refraction on, Reflection: Fresnel on and Ray trace on
                    // 8. Reflection on and Ray trace off
                    // 9. Transparency: Glass on, Reflection: Ray trace off
                    // 10. Casts shadows onto invisible surfaces

                    foreach (CryEngine_Core.Material.Texture texture in material.Textures)
                    {
                        String textureFile = texture.File;

                        if (this.Args.DataDir != null)
                        {
                            textureFile = Path.Combine(this.Args.DataDir, textureFile);
                        }

                        // TODO: More filehandling here

                        if (!this.Args.TiffTextures)
                        {
                            textureFile = textureFile.Replace(".tif", ".dds");
                        }
                        else
                        {
                            textureFile = textureFile.Replace(".dds", ".tif");
                        }

                        textureFile = textureFile.Replace(@"/", @"\");

                        switch (texture.Map)
                        {
                        case CryEngine_Core.Material.Texture.MapTypeEnum.Diffuse:
                            file.WriteLine("map_Kd {0}", textureFile);
                            break;

                        case CryEngine_Core.Material.Texture.MapTypeEnum.Specular:
                            file.WriteLine("map_Ks {0}", textureFile);
                            file.WriteLine("map_Ns {0}", textureFile);
                            break;

                        case CryEngine_Core.Material.Texture.MapTypeEnum.Bumpmap:
                        case CryEngine_Core.Material.Texture.MapTypeEnum.Detail:
                            // <Texture Map="Detail" File="textures/unified_detail/metal/metal_scratches_a_detail.tif" />
                            file.WriteLine("map_bump {0}", textureFile);
                            break;

                        case CryEngine_Core.Material.Texture.MapTypeEnum.Heightmap:
                            // <Texture Map="Heightmap" File="objects/spaceships/ships/aegs/gladius/textures/aegs_switches_buttons_disp.tif"/>
                            file.WriteLine("disp {0}", textureFile);
                            break;

                        case CryEngine_Core.Material.Texture.MapTypeEnum.Decal:
                            // <Texture Map="Decal" File="objects/spaceships/ships/aegs/textures/interior/metal/aegs_int_metal_alum_bare_diff.tif"/>
                            file.WriteLine("decal {0}", textureFile);
                            break;

                        case CryEngine_Core.Material.Texture.MapTypeEnum.SubSurface:
                            // <Texture Map="SubSurface" File="objects/spaceships/ships/aegs/textures/interior/atlas/aegs_int_atlas_retaliator_spec.tif"/>
                            file.WriteLine("map_Ns {0}", textureFile);
                            break;

                        case CryEngine_Core.Material.Texture.MapTypeEnum.Custom:
                            // <Texture Map="Custom" File="objects/spaceships/ships/aegs/textures/interior/metal/aegs_int_metal_painted_red_ddna.tif"/>
                            // file.WriteLine("decal {0}", textureFile);
                            break;

                        case CryEngine_Core.Material.Texture.MapTypeEnum.BlendDetail:
                            // <Texture Map="BlendDetail" File="textures/unified_detail/metal/metal_scratches-01_detail.tif">
                            break;

                        case CryEngine_Core.Material.Texture.MapTypeEnum.Opacity:
                            // <Texture Map="Opacity" File="objects/spaceships/ships/aegs/textures/interior/blend/interior_blnd_a_diff.tif"/>
                            file.WriteLine("map_d {0}", textureFile);
                            break;

                        case CryEngine_Core.Material.Texture.MapTypeEnum.Environment:
                            // <Texture Map="Environment" File="nearest_cubemap" TexType="7"/>
                            break;

                        default:
                            break;
                        }
                    }
                    file.WriteLine();
                }
            }
        }
Esempio n. 2
0
 public Wavefront(ArgsHandler argsHandler, CryEngine cryEngine) : base(argsHandler, cryEngine)
 {
 }
Esempio n. 3
0
 public CryRender(ArgsHandler argsHandler, CryEngine cryEngine) : base(argsHandler, cryEngine)
 {
 }
        /// <summary>
        /// Flatten all child materials into a one dimensional list
        /// </summary>
        /// <param name="material"></param>
        /// <returns></returns>
        public static IEnumerable <CryEngine_Core.Material> FlattenMaterials(CryEngine_Core.Material material)
        {
            if (material != null)
            {
                yield return(material);

                if (material.SubMaterials != null)
                {
                    foreach (var subMaterial in material.SubMaterials.SelectMany(m => CryEngine.FlattenMaterials(m)))
                    {
                        yield return(subMaterial);
                    }
                }
            }
        }
        public CryEngine(String fileName, String dataDir)
        {
            this.InputFile = fileName;

            FileInfo        inputFile  = new FileInfo(fileName);
            List <FileInfo> inputFiles = new List <FileInfo> {
                inputFile
            };

            // Validate file extension - handles .cgam / skinm
            if (!CryEngine._validExtensions.Contains(inputFile.Extension))
            {
                Utils.Log(LogLevelEnum.Debug, "Warning: Unsupported file extension - please use a cga, cgf, chr or skin file");
                throw new FileLoadException("Warning: Unsupported file extension - please use a cga, cgf, chr or skin file", fileName);
            }

            #region m-File Auto-Detection

            FileInfo mFile = new FileInfo(Path.ChangeExtension(fileName, String.Format("{0}m", inputFile.Extension)));

            if (mFile.Exists)
            {
                Utils.Log(LogLevelEnum.Debug, "Found geometry file {0}", mFile.Name);

                // Add to list of files to process
                inputFiles.Add(mFile);
            }

            #endregion

            this.Models = new List <CryEngine_Core.Model> {
            };

            foreach (var file in inputFiles)
            {
                // Each file (.cga and .cgam if applicable) will have its own RootNode.  This can cause problems.  .cga files with a .cgam files won't have geometry for the one root node.
                CryEngine_Core.Model model = CryEngine_Core.Model.FromFile(file.FullName);
                if (this.RootNode == null)
                {
                    RootNode = model.RootNode;  // This makes the assumption that we read the .cga file before the .cgam file.
                }
                //this.RootNode = this.RootNode ?? model.RootNode;
                this.Bones = this.Bones ?? model.Bones;
                this.Models.Add(model);
            }
            SkinningInfo = ConsolidateSkinningInfo();
            // For eanch node with geometry info, populate that node's Mesh Chunk GeometryInfo with the geometry data.
            ConsolidateGeometryInfo();

            #region Get material file name
            // Get the material file name
            foreach (CryEngine_Core.ChunkMtlName mtlChunk in this.Models.SelectMany(a => a.ChunkMap.Values).Where(c => c.ChunkType == ChunkTypeEnum.MtlName))
            {
                // Don't process child or collision materials for now
                if (mtlChunk.MatType == MtlNameTypeEnum.Child || mtlChunk.MatType == MtlNameTypeEnum.Unknown1)
                {
                    continue;
                }

                // The Replace part is for SC files that point to a _core material file that doesn't exist.
                String cleanName = mtlChunk.Name.Replace("_core", "");

                FileInfo materialFile;

                if (mtlChunk.Name.Contains("default_body"))
                {
                    // New MWO models for some crazy reason don't put the actual mtl file name in the mtlchunk.  They just have /objects/mechs/default_body
                    // have to assume that it's /objects/mechs/<mechname>/body/<mechname>_body.mtl.  There is also a <mechname>.mtl that contains mtl
                    // info for hitboxes, but not needed.
                    // TODO:  This isn't right.  Fix it.
                    var charsToClean = cleanName.ToCharArray().Intersect(Path.GetInvalidFileNameChars()).ToArray();
                    if (charsToClean.Length > 0)
                    {
                        foreach (Char character in charsToClean)
                        {
                            cleanName = cleanName.Replace(character.ToString(), "");
                        }
                    }
                    materialFile = new FileInfo(Path.Combine(Path.GetDirectoryName(fileName), cleanName));
                }
                else if (mtlChunk.Name.Contains(@"/") || mtlChunk.Name.Contains(@"\"))
                {
                    // The mtlname has a path.  Most likely starts at the Objects directory.
                    //
                    string[] stringSeparators = new string[] { @"\", @"/" };
                    string[] result;
                    // if objectdir is provided, check objectdir + mtlchunk.name
                    if (dataDir != null)
                    {
                        materialFile = new FileInfo(Path.Combine(dataDir, mtlChunk.Name));
                    }
                    else
                    {
                        // object dir not provided, but we have a path.  Just grab the last part of the name and check the dir of the cga file
                        result       = mtlChunk.Name.Split(stringSeparators, StringSplitOptions.None);
                        materialFile = new FileInfo(result[result.Length - 1]);
                    }
                }
                else
                {
                    var charsToClean = cleanName.ToCharArray().Intersect(Path.GetInvalidFileNameChars()).ToArray();
                    if (charsToClean.Length > 0)
                    {
                        foreach (Char character in charsToClean)
                        {
                            cleanName = cleanName.Replace(character.ToString(), "");
                        }
                    }
                    materialFile = new FileInfo(Path.Combine(Path.GetDirectoryName(fileName), cleanName));
                }

                // First try relative to file being processed
                if (materialFile.Extension != ".mtl")
                {
                    materialFile = new FileInfo(Path.ChangeExtension(materialFile.FullName, "mtl"));
                }

                // Then try just the last part of the chunk, relative to the file being processed
                if (!materialFile.Exists)
                {
                    materialFile = new FileInfo(Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileName(cleanName)));
                }
                if (materialFile.Extension != ".mtl")
                {
                    materialFile = new FileInfo(Path.ChangeExtension(materialFile.FullName, "mtl"));
                }

                // Then try relative to the ObjectDir
                if (!materialFile.Exists && dataDir != null)
                {
                    materialFile = new FileInfo(Path.Combine(dataDir, cleanName));
                }
                if (materialFile.Extension != ".mtl")
                {
                    materialFile = new FileInfo(Path.ChangeExtension(materialFile.FullName, "mtl"));
                }

                // Then try just the fileName.mtl
                if (!materialFile.Exists)
                {
                    materialFile = new FileInfo(fileName);
                }
                if (materialFile.Extension != ".mtl")
                {
                    materialFile = new FileInfo(Path.ChangeExtension(materialFile.FullName, "mtl"));
                }

                // TODO: Try more paths

                // Populate CryEngine_Core.Material
                CryEngine_Core.Material material = CryEngine_Core.Material.FromFile(materialFile);

                if (material != null)
                {
                    Utils.Log(LogLevelEnum.Debug, "Located material file {0}", materialFile.Name);

                    this.Materials = CryEngine.FlattenMaterials(material).Where(m => m.Textures != null).ToArray();

                    if (this.Materials.Length == 1)
                    {
                        // only one material, so it's a material file with no submaterials.  Check and set the name
                        //Console.WriteLine("Single material found.  setting name...");
                        this.Materials[0].Name = this.RootNode.Name;
                    }

                    // Early return - we have the material map
                    return;
                }
                else
                {
                    Utils.Log(LogLevelEnum.Debug, "Unable to locate material file {0}.mtl", mtlChunk.Name);
                }
            }
            #endregion

            Utils.Log(LogLevelEnum.Debug, "Unable to locate any material file");
            this.Materials = new CryEngine_Core.Material[] { };
        }
        public static Int32 Main(String[] args)
        {
            Utils.LogLevel   = LogLevelEnum.Warning;
            Utils.DebugLevel = LogLevelEnum.Debug;

            String oldTitle = Console.Title;

#if DEV_DOLKENSP
            Utils.LogLevel   = LogLevelEnum.None;    // Display NO error logs
            Utils.DebugLevel = LogLevelEnum.Debug;

            args = new String[] { @"O:\Mods\Models\*.cg?", @"O:\Mods\Models\*.skin", @"O:\Mods\Models\*.chr", "-objectdir", @"O:\Mods\SC\Latest", "-tif", "-merge", "-obj", "-outdir", @"O:\Mods\Models\Export" };
            args = new String[] { @"O:\Mods\SC\Latest\*.cg?", @"O:\Mods\SC\Latest\*.skin", @"O:\Mods\SC\Latest\*.chr", "-objectdir", @"O:\Mods\SC\Latest", "-tif", "-merge", "-obj", "-outdir", @"O:\Mods\Assets_Out" };
            args = new String[] { @"Objects\*.cg?", @"Objects\*.skin", @"Objects\*.chr", "-objectdir", @"O:\Mods\SC\Latest", "-tif", "-merge", "-obj", "-outdir", @"Export" };
            // args = new String[] { @"O:\Mods\Assets\*.cg?", "-objectdir", @"O:\Mods\SC\Latest", "-tif", "-merge", "-dae", "-outdir", @"O:\Mods\Assets_Out" };
            args = new String[] { @"Objects\*.cg?", @"Objects\*.skin", @"Objects\*.chr", "-objectdir", @"O:\Mods\SC\Latest", "-tif", "-merge", "-obj", "-cry", "-dae", "-outdir", @"Export", "-skipshield", "-skipproxy" };
            args = new String[] { @"Starfarer\*.cg?", "-objectdir", @"D:\Workspaces\github\Cryengine-Converter\cgf-converter\bin\dev_dolkensp", "-tif", "-merge", "-obj", "-cry", "-outdir", @"Export", "-skipshield", "-skipproxy" };
#endif

#if DEV_MARKEMP
            Utils.LogLevel   = LogLevelEnum.Verbose; // Display ALL error logs in the console
            Utils.DebugLevel = LogLevelEnum.Debug;   // Send all to the IDE Output window
            //args = new String[] { @"c:\users\geoff\source\repos\cgf-converter\cgf-converter\bin\Debug\raptor.chr", "-dds", "-dae" };
            //args = new String[] { @"c:\users\geoff\source\repos\cgf-converter\cgf-converter\bin\Debug\ar03.chr", "-dds", "-dae" };
            //args = new String[] { @"D:\depot\mwo\Objects\environments\frontend\mechlab_a\lights\industrial_wetlamp_a.cgf", "-dds", "-dae", "-objectdir", @"d:\depot\mwo\" };
            //args = new String[] { @"D:\depot\mwo\Objects\mechs\timberwolf\body\timberwolf.chr", "-dds", "-dae", "-objectdir", @"d:\depot\mwo\" };
            //args = new String[] { @"D:\depot\mwo\Objects\mechs\hellbringer\body\hbr_right_torso_uac5_bh1.cga", "-dds", "-dae", "-objectdir", @"d:\depot\mwo\" };
            //args = new String[] { @"D:\depot\mwo\Objects\environments\frontend\mechlab_a\mechbay_ceilings\mechbay_ceilinga.cgf", "-dds", "-dae", "-objectdir", @"d:\depot\mwo\" };
            args = new String[] { @"D:\depot\mwo\Objects\environments\industrial\mf_maglev_loader_a.cgf", "-dds", "-dae", "-objectdir", @"d:\depot\mwo\" };
            //args = new String[] { @"D:\Blender Projects\Mechs\Objects\characters\pilot\pilot_body.chr", "-dds", "-dae", "-objectdir", @"d:\blender projects\mechs\" };
            //args = new String[] { @"D:\Blender Projects\Star Citizen\Objects\animals\crab\props\crab_thorshu_prop_01.chr", "-objectdir", @"d:\blender projects\star citizen", "-dae", "-tif" };
            //args = new String[] { @"D:\Blender Projects\Star Citizen\Objects\animals\fish\CleanerFish_clean_prop_animal_01.chr", "-objectdir", @"d:\blender projects\star citizen", "-dae", "-tif" };
            //args = new String[] { @"d:\Blender Projects\Star Citizen\Objects\Spaceships\Ships\AEGS\Gladius\AEGS_Gladius.cga", "-objectdir", @"d:\blender projects\star citizen", "-dae", "-tif" };
            //args = new String[] { @"d:\Blender Projects\Star Citizen\Objects\Spaceships\Ships\AEGS\Retaliator\AEGS_retaliator.cga", "-objectdir", @"d:\blender projects\star citizen", "-dae", "-tif" };
            //args = new String[] { @"D:\Blender Projects\Star Citizen\Objects\Spaceships\Ships\AEGS\Redeemer\AEGS_Redeemer.cga", "-objectdir", @"d:\blender projects\star citizen", "-dae", "-tif" };
            //args = new String[] { @"D:\Blender Projects\Star Citizen\Objects\Spaceships\Ships\DRAK\Cutlass\DRAK_Cutlass.cga", "-objectdir", @"d:\blender projects\star citizen", "-dae", "-tif" };
            //args = new String[] { @"d:\Blender Projects\Star Citizen\Objects\buildingsets\human\lowtech\bravo\grimhex\anchor\anchor_gun_a.cgf", "-objectdir", @"d:\blender projects\star citizen", "-dds", "-dae", "-tif" };
            //args = new String[] { @"d:\Blender Projects\Star Citizen\Objects\buildingsets\human\hightech\alpha\ext\landingpad\ext_landingpad_floor_center_stair_16x08x10_b.cgf", "-objectdir", @"d:\blender projects\star citizen", "-dae", "-tif" };
            //args = new String[] { @"d:\Blender Projects\Star Citizen\Objects\buildingsets\human\hightech\alpha\ext\landingpad\landingpad_decal_landingzone_a.cgf", "-objectdir", @"d:\blender projects\star citizen", "-dae", "-tif" };
            //args = new String[] { @"D:\depot\SC\Objects\Characters\Human\heads\male\npc\male09\male09_t1_head.skin", "-objectdir", @"d:\blender projects\star citizen", "-dae", "-tif" };
            //args = new String[] { @"D:\Blender Projects\Star Citizen\Objects\Characters\Human\male_v7\export\bhm_skeleton_v7.chr", "-objectdir", @"d:\blender projects\star citizen", "-dae", "-tif" };
            //args = new String[] { @"D:\Blender Projects\Star Citizen\Objects\buildingsets\human\universal\org\trees\tree_ash_a.cgf", "-objectdir", @"d:\blender projects\star citizen", "-dae", "-tif" };
            //args = new String[] { @"D:\Blender Projects\Star Citizen\Objects\Characters\Human\male_v7\armor\rsi\m_rsi_pilot_flightsuit_01.skin", "-objectdir", @"d:\blender projects\star citizen\", "-dae", "-tif" };
            //args = new String[] { @"D:\Blender Projects\Star Citizen\Objects\Characters\Human\male_v7\armor\slaver\m_slaver_medium_armor_01_core.skin", "-objectdir", @"d:\blender projects\star citizen", "-dae", "-tif" };
            //args = new String[] { @"D:\Blender Projects\Mechs\Objects\environments\city\im_roads_zone_05\im_zone05_block16.cgf", "-objectdir", @"d:\blender projects\mechs", "-dae" };
            //args = new String[] { @"d:\temp\prey\dahl_genmalebody01.skin", "-objectdir", @"d:\temp\prey", "-dae", "-dds" };
#endif

            ArgsHandler argsHandler = new ArgsHandler();
            Int32       result      = argsHandler.ProcessArgs(args);

#if !DEBUG
            try
            {
#endif
            System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            customCulture.NumberFormat.NumberDecimalSeparator = ".";

            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

            if (result == 0)
            {
                foreach (String inputFile in argsHandler.InputFiles)
                {
                    try
                    {
                        // Read CryEngine Files
                        CryEngine cryData = new CryEngine(inputFile, argsHandler.DataDir.FullName);

                        #region Render Output Files

                        if (argsHandler.Output_Blender == true)
                        {
                            Blender blendFile = new Blender(argsHandler, cryData);

                            blendFile.Render(argsHandler.OutputDir, argsHandler.InputFiles.Count > 1);
                        }

                        if (argsHandler.Output_Wavefront == true)
                        {
                            Wavefront objFile = new Wavefront(argsHandler, cryData);

                            objFile.Render(argsHandler.OutputDir, argsHandler.InputFiles.Count > 1);
                        }

                        if (argsHandler.Output_CryTek == true)
                        {
                            CryRender cryFile = new CryRender(argsHandler, cryData);

                            cryFile.Render(argsHandler.OutputDir, argsHandler.InputFiles.Count > 1);
                        }

                        if (argsHandler.Output_Collada == true)
                        {
                            COLLADA daeFile = new COLLADA(argsHandler, cryData);

                            daeFile.Render(argsHandler.OutputDir, argsHandler.InputFiles.Count > 1);
                        }

                        #endregion
                    }
                    catch (Exception ex)
                    {
                        Utils.Log(LogLevelEnum.Critical);
                        Utils.Log(LogLevelEnum.Critical, "********************************************************************************");
                        Utils.Log(LogLevelEnum.Critical, "There was an error rendering {0}", inputFile);
                        Utils.Log(LogLevelEnum.Critical);
                        Utils.Log(LogLevelEnum.Critical, ex.Message);
                        Utils.Log(LogLevelEnum.Critical);
                        Utils.Log(LogLevelEnum.Critical, ex.StackTrace);
                        Utils.Log(LogLevelEnum.Critical, "********************************************************************************");
                        Utils.Log(LogLevelEnum.Critical);
                    }
                }
            }

#if !DEBUG
        }

        catch (Exception)
        {
            if (argsHandler.Throw)
            {
                throw;
            }
        }
#endif

            Console.Title = oldTitle;

#if (DEV_DOLKENSP || DEV_MARKEMP)
            Console.WriteLine("Done...");
            Console.ReadKey();
#endif

            return(result);
        }
Esempio n. 7
0
        public static Int32 Main(String[] args)
        {
            Utils.LogLevel   = LogLevelEnum.Warning;
            Utils.DebugLevel = LogLevelEnum.Debug;

            String oldTitle = Console.Title;

#if DEV_DOLKENSP
            Utils.LogLevel   = LogLevelEnum.None;    // Display NO error logs
            Utils.DebugLevel = LogLevelEnum.Debug;

            args = new String[] { @"O:\Mods\Models\*.cg?", @"O:\Mods\Models\*.skin", @"O:\Mods\Models\*.chr", "-objectdir", @"O:\Mods\SC\Latest", "-tif", "-merge", "-obj", "-outdir", @"O:\Mods\Models\Export" };
            args = new String[] { @"O:\Mods\SC\Latest\*.cg?", @"O:\Mods\SC\Latest\*.skin", @"O:\Mods\SC\Latest\*.chr", "-objectdir", @"O:\Mods\SC\Latest", "-tif", "-merge", "-obj", "-outdir", @"O:\Mods\Assets_Out" };
            args = new String[] { @"Objects\*.cg?", @"Objects\*.skin", @"Objects\*.chr", "-objectdir", @"O:\Mods\SC\Latest", "-tif", "-merge", "-obj", "-outdir", @"Export" };
            // args = new String[] { @"O:\Mods\Assets\*.cg?", "-objectdir", @"O:\Mods\SC\Latest", "-tif", "-merge", "-dae", "-outdir", @"O:\Mods\Assets_Out" };
            args = new String[] { @"Objects\*.cg?", @"Objects\*.skin", @"Objects\*.chr", "-objectdir", @"O:\Mods\SC\Latest", "-tif", "-merge", "-obj", "-cry", "-dae", "-outdir", @"Export", "-skipshield", "-skipproxy" };
#endif

#if DEV_MARKEMP
            Utils.LogLevel   = LogLevelEnum.Verbose; // Display ALL error logs in the console
            Utils.DebugLevel = LogLevelEnum.Debug;   // Send all to the IDE Output window

            //args = new String[] { @"C:\Users\Geoff\Documents\Visual Studio 2013\Projects\cgf-converter\cgf-converter\bin\Debug\AEGS_Gladius.cga", "-objectdir", @"e:\blender projects\star citizen", "-dds", "-obj" };
            //args = new String[] { @"E:\Blender Projects\Star Citizen\Objects\Spaceships\Ships\ORIG\300I\ORIG_300I.cga", "-objectdir", @"e:\blender projects\star citizen", "-dds", "-obj" };
            //args = new String[] { @"E:\Blender Projects\Star Citizen\Objects\Spaceships\Ships\AEGS\Gladius\AEGS_Gladius.cga", "-objectdir", @"e:\blender projects\star citizen", "-dds", "-obj" , "-merge"};
            //args = new String[] { @"C:\Users\Geoff\Documents\Visual Studio 2013\Projects\cgf-converter\cgf-converter\bin\Debug\RSI_Aurora.cga", "-objectdir", @"e:\blender projects\star citizen", "-dds", "-obj" };
            //args = new String[] { @"C:\Users\Geoff\Documents\Visual Studio 2013\Projects\cgf-converter\cgf-converter\bin\Debug\hulagirl_a.cga", "-objectdir", @"e:\blender projects\mechs", "-dds", "-dae" };
            //args = new String[] { @"C:\Users\Geoff\Documents\Visual Studio 2013\Projects\cgf-converter\cgf-converter\bin\Debug\atlas_leg_left.cga", "-objectdir", @"e:\blender projects\mechs", "-dds", "-dae" };
            args = new String[] { @"C:\Users\Geoff\Documents\Visual Studio 2013\Projects\cgf-converter\cgf-converter\bin\Debug\adder_a_cockpit_standard.cga", "-dds", "-dae" };
            //args = new String[] { @"C:\Users\Geoff\Documents\Visual Studio 2013\Projects\cgf-converter\cgf-converter\bin\Debug\candycane_a.chr", "-objectdir", @"e:\blender projects\mechs", "-dds", "-dae" };
            //args = new String[] { @"C:\Users\Geoff\Documents\Visual Studio 2013\Projects\cgf-converter\cgf-converter\bin\Debug\raptor.chr", "-dds", "-dae" };
            //args = new String[] { @"C:\Users\Geoff\Documents\Visual Studio 2013\Projects\cgf-converter\cgf-converter\bin\Debug\ar03.chr", "-dds", "-obj" };
#endif

            ArgsHandler argsHandler = new ArgsHandler();
            Int32       result      = argsHandler.ProcessArgs(args);

#if !DEBUG
            try
            {
#endif

            if (result == 0)
            {
                foreach (String inputFile in argsHandler.InputFiles)
                {
                    try
                    {
                        // Read CryEngine Files
                        CryEngine cryData = new CryEngine(inputFile, argsHandler.DataDir);

                        #region Render Output Files

                        if (argsHandler.Output_Blender == true)
                        {
                            Blender blendFile = new Blender(argsHandler, cryData);

                            blendFile.Render(argsHandler.OutputDir, argsHandler.InputFiles.Count > 1);
                        }

                        if (argsHandler.Output_Wavefront == true)
                        {
                            Wavefront objFile = new Wavefront(argsHandler, cryData);

                            objFile.Render(argsHandler.OutputDir, argsHandler.InputFiles.Count > 1);
                        }

                        if (argsHandler.Output_CryTek == true)
                        {
                            CryRender cryFile = new CryRender(argsHandler, cryData);

                            cryFile.Render(argsHandler.OutputDir, argsHandler.InputFiles.Count > 1);
                        }

                        if (argsHandler.Output_Collada == true)
                        {
                            COLLADA daeFile = new COLLADA(argsHandler, cryData);

                            daeFile.Render(argsHandler.OutputDir, argsHandler.InputFiles.Count > 1);
                        }

                        #endregion
                    }
                    catch (Exception ex)
                    {
                        Utils.Log(LogLevelEnum.Critical);
                        Utils.Log(LogLevelEnum.Critical, "********************************************************************************");
                        Utils.Log(LogLevelEnum.Critical, "There was an error rendering {0}", inputFile);
                        Utils.Log(LogLevelEnum.Critical);
                        Utils.Log(LogLevelEnum.Critical, ex.Message);
                        Utils.Log(LogLevelEnum.Critical);
                        Utils.Log(LogLevelEnum.Critical, ex.StackTrace);
                        Utils.Log(LogLevelEnum.Critical, "********************************************************************************");
                        Utils.Log(LogLevelEnum.Critical);
                    }
                }
            }

#if !DEBUG
        }

        catch (Exception)
        {
            if (argsHandler.Throw)
            {
                throw;
            }
        }
#endif

            Console.Title = oldTitle;

#if (DEV_DOLKENSP || DEV_MARKEMP)
            Console.WriteLine("Done...");
            Console.ReadKey();
#endif

            return(result);
        }