Beispiel #1
0
        static void Exec(bool gui, string input, string output, string export, string format, float magnification)
        {
            var      systemLanguage = EfkN.GetSystemLanguage();
            Language?language       = null;

            if (systemLanguage != swig.SystemLanguage.Unknown)
            {
                language = (Language)systemLanguage;
            }
            else
            {
                language = Language.English;
            }

            Core.OnOutputMessage += new Action <string>(Core_OnOutputMessage);
            Core.Initialize(language);

            if (gui)
            {
                // Failed to compile script
                if (Core.ExportScripts.Count == 0)
                {
                    Script.ExportScript defaultExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.ExportDefault.UniqueName,
                        Plugin.ExportDefault.Author,
                        Plugin.ExportDefault.Title,
                        Plugin.ExportDefault.Description,
                        Plugin.ExportDefault.Filter,
                        Plugin.ExportDefault.Call);
                    Core.ExportScripts.Add(defaultExporter);

                    Script.ExportScript glTFExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.ExportglTF.UniqueName,
                        Plugin.ExportglTF.Author,
                        Plugin.ExportglTF.Title,
                        Plugin.ExportglTF.Description,
                        Plugin.ExportglTF.Filter,
                        Plugin.ExportglTF.Call);
                    Core.ExportScripts.Add(glTFExporter);

                    Script.ExportScript glbExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.Exportglb.UniqueName,
                        Plugin.Exportglb.Author,
                        Plugin.Exportglb.Title,
                        Plugin.Exportglb.Description,
                        Plugin.Exportglb.Filter,
                        Plugin.Exportglb.Call);
                    Core.ExportScripts.Add(glbExporter);
                }

                {
                    var appDirectory = GUI.Manager.GetEntryDirectory();
                    if (Core.Language == Language.Japanese)
                    {
                        var fullPath = Path.Combine(appDirectory, "resources/languages/effekseer_ja.txt");
                        Resources.LoadLanguageFile(fullPath);
                    }
                    if (Core.Language == Language.English)
                    {
                        var fullPath = Path.Combine(appDirectory, "resources/languages/effekseer_en.txt");
                        Resources.LoadLanguageFile(fullPath);
                    }
                }

                System.OperatingSystem os         = System.Environment.OSVersion;
                swig.DeviceType        deviceType = swig.DeviceType.DirectX11;

                if (!(os.Platform == PlatformID.Win32NT ||
                      os.Platform == PlatformID.Win32S ||
                      os.Platform == PlatformID.Win32Windows ||
                      os.Platform == PlatformID.WinCE))
                {
                    deviceType = swig.DeviceType.OpenGL;
                }

                if (!GUI.Manager.Initialize(960, 540, deviceType))
                {
                    return;
                }
            }

            try
            {
                if (input != string.Empty)
                {
                    Core.LoadFrom(input);
                }

                if (output != string.Empty)
                {
                    Core.SaveTo(output);
                }

                if (export != string.Empty)
                {
                    if (magnification == 0.0f)
                    {
                        magnification = Core.Option.Magnification;
                    }

                    if (format == "gltf")
                    {
                        var option = new Effekseer.Exporter.glTFExporterOption();
                        option.Scale = magnification;
                        var exporter = new Effekseer.Exporter.glTFExporter();
                        exporter.Export(export, option);
                    }
                    else if (format == "glb")
                    {
                        var option = new Effekseer.Exporter.glTFExporterOption();
                        option.Scale  = magnification;
                        option.Format = Exporter.glTFExporterFormat.glb;
                        var exporter = new Effekseer.Exporter.glTFExporter();
                        exporter.Export(export, option);
                    }
                    else
                    {
                        var binaryExporter = new Binary.Exporter();
                        var binary         = binaryExporter.Export(magnification);
                        System.IO.File.WriteAllBytes(export, binary);
                    }
                }
            }
            catch (Exception e)
            {
                System.Console.Error.WriteLine(e.Message);
            }

            if (gui)
            {
                while (GUI.Manager.NativeManager.DoEvents())
                {
                    GUI.Manager.Update();
                }

                GUI.Manager.Terminate();
                Process.MaterialEditor.Terminate();
            }

            Core.Dispose();
        }
Beispiel #2
0
        static void Exec(bool gui, string input, string output, string export, string format, float magnification, bool materialCache)
        {
            // Register UI
            GUI.Component.ParameterListComponentFactory.Register(typeof(Data.LanguageSelector), () => { return(new GUI.Component.LanguageSelector()); });

            GUI.Component.ParameterListComponentFactory.Register(typeof(Data.ProcedualModelReference), () => {
                return(new GUI.Component.ObjectReference <Data.ProcedualModelParameter>(Core.ProcedualModel.ProcedualModels));
            });

            // Debug
            bool isDebugMode = false;

#if DEBUG
            isDebugMode = true;
#endif
            if (System.IO.File.Exists(Path.Combine(EntryDirectory, "debug.txt")) || isDebugMode)
            {
                swig.Native.SetFileLogger(Path.Combine(GUI.Manager.GetEntryDirectory(), "Effekseer.log.txt"));
                Utils.Logger.LogPath = Path.Combine(GUI.Manager.GetEntryDirectory(), "Effekseer.Managed.log.txt");
            }

            LanguageTable.LoadTable(Path.Combine(EntryDirectory, "resources/languages/languages.txt"));

            var    systemLanguage = EfkN.GetSystemLanguage();
            string language       = null;

            if (systemLanguage != swig.SystemLanguage.Unknown)
            {
                if (systemLanguage == swig.SystemLanguage.Japanese)
                {
                    language = "ja";
                }
                else if (systemLanguage == swig.SystemLanguage.English)
                {
                    language = "en";
                }
            }
            else
            {
                language = "en";
            }

            Core.OnOutputMessage += new Action <string>(Core_OnOutputMessage);
            Core.Initialize(language);

            if (gui)
            {
                ChangeLanguage();
                LanguageTable.OnLanguageChanged += (o, e) => { ChangeLanguage(); };

                // Failed to compile script
                if (Core.ExportScripts.Count == 0)
                {
                    Script.ExportScript efkpkgExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.ExportEfkPkg.UniqueName,
                        Plugin.ExportEfkPkg.Author,
                        Plugin.ExportEfkPkg.Title,
                        Plugin.ExportEfkPkg.Description,
                        Plugin.ExportEfkPkg.Filter,
                        Plugin.ExportEfkPkg.Call);
                    Core.ExportScripts.Add(efkpkgExporter);

                    Script.ExportScript defaultExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.ExportDefault.UniqueName,
                        Plugin.ExportDefault.Author,
                        Plugin.ExportDefault.Title,
                        Plugin.ExportDefault.Description,
                        Plugin.ExportDefault.Filter,
                        Plugin.ExportDefault.Call);
                    Core.ExportScripts.Add(defaultExporter);

                    Script.ExportScript glTFExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.ExportglTF.UniqueName,
                        Plugin.ExportglTF.Author,
                        Plugin.ExportglTF.Title,
                        Plugin.ExportglTF.Description,
                        Plugin.ExportglTF.Filter,
                        Plugin.ExportglTF.Call);
                    Core.ExportScripts.Add(glTFExporter);

                    Script.ExportScript glbExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.Exportglb.UniqueName,
                        Plugin.Exportglb.Author,
                        Plugin.Exportglb.Title,
                        Plugin.Exportglb.Description,
                        Plugin.Exportglb.Filter,
                        Plugin.Exportglb.Call);
                    Core.ExportScripts.Add(glbExporter);
                }



                System.OperatingSystem os         = System.Environment.OSVersion;
                swig.DeviceType        deviceType = swig.DeviceType.DirectX11;

                if (!(os.Platform == PlatformID.Win32NT ||
                      os.Platform == PlatformID.Win32S ||
                      os.Platform == PlatformID.Win32Windows ||
                      os.Platform == PlatformID.WinCE))
                {
                    deviceType = swig.DeviceType.OpenGL;
                }

                if (!GUI.Manager.Initialize(960, 540, deviceType))
                {
                    return;
                }
            }

            try
            {
                if (input != string.Empty)
                {
                    Core.LoadFrom(input);
                }

                if (output != string.Empty)
                {
                    Core.SaveTo(output);
                }

                if (export != string.Empty)
                {
                    if (magnification == 0.0f)
                    {
                        magnification = Core.Option.Magnification;
                    }

                    if (format == "gltf")
                    {
                        var option = new Effekseer.Exporter.glTFExporterOption();
                        option.Scale = magnification;
                        var exporter = new Effekseer.Exporter.glTFExporter();
                        exporter.Export(export, option);
                    }
                    else if (format == "glb")
                    {
                        var option = new Effekseer.Exporter.glTFExporterOption();
                        option.Scale  = magnification;
                        option.Format = Exporter.glTFExporterFormat.glb;
                        var exporter = new Effekseer.Exporter.glTFExporter();
                        exporter.Export(export, option);
                    }
                    else
                    {
                        var binaryExporter = new Binary.Exporter();
                        var binary         = binaryExporter.Export(Core.Root, magnification);
                        System.IO.File.WriteAllBytes(export, binary);
                    }
                }
            }
            catch (Exception e)
            {
                System.Console.Error.WriteLine(e.Message);
            }

            try
            {
                if (materialCache)
                {
                    IO.MaterialCacheGenerator.GenerateMaterialCaches();
                }
            }
            catch (Exception e)
            {
                System.Console.Error.WriteLine(e.Message);
            }

            if (gui)
            {
                while (GUI.Manager.NativeManager.DoEvents())
                {
                    GUI.Manager.Update();
                }

                GUI.Manager.Terminate();
                Process.MaterialEditor.Terminate();
            }

            Core.Dispose();
        }
Beispiel #3
0
        public bool Initialize(bool gui)
        {
            // Setup Special Paths
            {
                try
                {
                    StartDirectory = System.IO.Directory.GetCurrentDirectory();
                    EntryDirectory = GUI.Manager.GetEntryDirectory();
                }
                catch (Exception e)
                {
                    ExportError(e);
                    return(false);
                }

                Name = Path.GetFileNameWithoutExtension(System.AppDomain.CurrentDomain.FriendlyName);
            }



            // Register UI
            GUI.Component.ParameterListComponentFactory.Register(typeof(Data.LanguageSelector), () => { return(new GUI.Component.LanguageSelector()); });

            GUI.Component.ParameterListComponentFactory.Register(typeof(Data.ProceduralModelReference), () => {
                return(new GUI.Component.ObjectReference <Data.ProceduralModelParameter>(Core.ProceduralModel.ProceduralModels));
            });

            // Debug
            bool isDebugMode = false;

#if DEBUG
            isDebugMode = true;
#endif
            if (System.IO.File.Exists(Path.Combine(EntryDirectory, "debug.txt")) || isDebugMode)
            {
                swig.Native.SetFileLogger(Path.Combine(GUI.Manager.GetEntryDirectory(), "Effekseer.log.txt"));
                Utils.Logger.LogPath = Path.Combine(GUI.Manager.GetEntryDirectory(), "Effekseer.Managed.log.txt");
            }

            LanguageTable.CreateTableFromDirectory(EntryDirectory);

            var    systemLanguage = EfkN.GetSystemLanguage();
            string language       = null;

            if (systemLanguage != swig.SystemLanguage.Unknown)
            {
                if (systemLanguage == swig.SystemLanguage.Japanese)
                {
                    language = "ja";
                }
                else if (systemLanguage == swig.SystemLanguage.English)
                {
                    language = "en";
                }
            }
            else
            {
                language = "en";
            }

            Core.OnOutputMessage += new Action <string>(Core_OnOutputMessage);
            Core.Initialize(language);

            if (gui)
            {
                ChangeLanguage();
                LanguageTable.OnLanguageChanged += (o, e) => { ChangeLanguage(); };

                // Failed to compile script
                if (Core.ExportScripts.Count == 0)
                {
                    Script.ExportScript efkpkgExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.ExportEfkPkg.UniqueName,
                        Plugin.ExportEfkPkg.Author,
                        Plugin.ExportEfkPkg.Title,
                        Plugin.ExportEfkPkg.Description,
                        Plugin.ExportEfkPkg.Filter,
                        Plugin.ExportEfkPkg.Call);
                    Core.ExportScripts.Add(efkpkgExporter);

                    Script.ExportScript defaultExporter = new Script.ExportScript(
                        Script.ScriptPosition.External,
                        Plugin.ExportDefault.UniqueName,
                        Plugin.ExportDefault.Author,
                        Plugin.ExportDefault.Title,
                        Plugin.ExportDefault.Description,
                        Plugin.ExportDefault.Filter,
                        Plugin.ExportDefault.Call);
                    Core.ExportScripts.Add(defaultExporter);

                    Script.ImportScript efkpkgImporter = new Script.ImportScript(
                        Script.ScriptPosition.External,
                        Plugin.ImportEfkPkg.UniqueName,
                        Plugin.ImportEfkPkg.Author,
                        Plugin.ImportEfkPkg.Title,
                        Plugin.ImportEfkPkg.Description,
                        Plugin.ImportEfkPkg.Filter,
                        Plugin.ImportEfkPkg.Call);
                    Core.ImportScripts.Add(efkpkgImporter);
                }

                OnInitialize();
            }

            return(true);
        }