Exemple #1
0
        public bool ShowViewer(IntPtr handle, int width, int height, swig.DeviceType deviceType)
        {
            if (isViewerShown)
            {
                return(false);
            }

            if (native == null)
            {
                throw new Exception("native is null.");
            }

            if (native.CreateWindow_Effekseer(
                    handle, width <= 0 ? 1 : width,
                    height <= 0 ? 1 : height,
                    Core.Option.ColorSpace.Value == Data.OptionValues.ColorSpaceType.LinearSpace,
                    deviceType))
            {
                isViewerShown = true;
                return(true);
            }
            else
            {
                Core.OnOutputMessage("描画画面の生成に失敗しました。DirectXのバージョンの問題、メモリの不足等が考えられます。");
            }

            return(false);
        }
Exemple #2
0
        protected override void OnInitialize()
        {
            var dockTypes = new Type[]
            {
                typeof(Dock.FileViewer),
                typeof(Dock.PrefabListDock),
                typeof(Dock.TimelineDock),
                typeof(Dock.NodePropertiesDock),
                typeof(Dock.CellPropertiesDock),
            };

            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, dockTypes))
            {
                throw new InvalidOperationException("Initialization failed.");
            }
        }
Exemple #3
0
        public bool ShowViewer(IntPtr handle, int width, int height, swig.DeviceType deviceType)
        {
            if (isViewerShown)
            {
                return(false);
            }

            if (native == null)
            {
                throw new Exception("native is null.");
            }

            ViewPointController = new swig.ViewPointController();

            ViewPointController.ProjectionStyle = deviceType == swig.DeviceType.OpenGL ? swig.ProjectionMatrixStyle.OpenGLStyle : swig.ProjectionMatrixStyle.DirectXStyle;

            if (native.CreateWindow_Effekseer(
                    handle,
                    width <= 0 ? 1 : width,
                    height <= 0 ? 1 : height,
                    Core.Option.ColorSpace.Value == Data.OptionValues.ColorSpaceType.LinearSpace,
                    deviceType))
            {
                isViewerShown = true;
            }
            else
            {
                var message = MultiLanguageTextProvider.GetText("System_FailedToInitialize");
                Core.OnOutputMessage(message);
                return(false);
            }

            ViewMode_OnChanged(null, null);
            Core.Option.ViewerMode.OnChanged += ViewMode_OnChanged;

            Core.Option.RenderingMode.OnChanged += RenderingMode_OnChanged;
            RenderingMode_OnChanged(null, null);

            Bloom_OnChanged(null, null);
            Core.Environment.PostEffect.BloomSwitch.OnChanged     += Bloom_OnChanged;
            Core.Environment.PostEffect.Bloom.Intensity.OnChanged += Bloom_OnChanged;
            Core.Environment.PostEffect.Bloom.Threshold.OnChanged += Bloom_OnChanged;
            Core.Environment.PostEffect.Bloom.SoftKnee.OnChanged  += Bloom_OnChanged;

            Tonemap_OnChanged(null, null);
            Core.Environment.PostEffect.TonemapSelector.OnChanged          += Tonemap_OnChanged;
            Core.Environment.PostEffect.TonemapReinhard.Exposure.OnChanged += Tonemap_OnChanged;

            effectFactory = new swig.EffectFactory(native);

            return(true);
        }
Exemple #4
0
        public bool ShowViewer(IntPtr handle, int width, int height, swig.DeviceType deviceType)
        {
            if (isViewerShown)
            {
                return(false);
            }

            if (native == null)
            {
                throw new Exception("native is null.");
            }

            if (native.CreateWindow_Effekseer(
                    handle,
                    width <= 0 ? 1 : width,
                    height <= 0 ? 1 : height,
                    Core.Option.ColorSpace.Value == Data.OptionValues.ColorSpaceType.LinearSpace,
                    deviceType))
            {
                isViewerShown = true;
            }
            else
            {
                if (Core.Language == Language.Japanese)
                {
                    Core.OnOutputMessage("描画画面の生成に失敗しました。DirectXのバージョンの問題、メモリの不足等が考えられます。");
                }
                else
                {
                    Core.OnOutputMessage("Failed to generate drawing screen. DirectX version problems, memory shortage, and so on.");
                }
                return(false);
            }

            ViewMode_OnChanged(null, null);
            Core.Option.ViewerMode.OnChanged += ViewMode_OnChanged;

            Bloom_OnChanged(null, null);
            Core.Environment.PostEffect.BloomSwitch.OnChanged     += Bloom_OnChanged;
            Core.Environment.PostEffect.Bloom.Intensity.OnChanged += Bloom_OnChanged;
            Core.Environment.PostEffect.Bloom.Threshold.OnChanged += Bloom_OnChanged;
            Core.Environment.PostEffect.Bloom.SoftKnee.OnChanged  += Bloom_OnChanged;

            Tonemap_OnChanged(null, null);
            Core.Environment.PostEffect.TonemapSelector.OnChanged          += Tonemap_OnChanged;
            Core.Environment.PostEffect.TonemapReinhard.Exposure.OnChanged += Tonemap_OnChanged;

            return(true);
        }
Exemple #5
0
        protected override void OnInitialize()
        {
            var dockTypes = new Type[]
            {
                typeof(Dock.ViewerController),
                typeof(Dock.NodeTreeView),
                typeof(Dock.CommonValues),
                typeof(Dock.LocationValues),
                typeof(Dock.LocationAbsValues),
                typeof(Dock.GenerationLocationValues),
                typeof(Dock.RotationValues),
                typeof(Dock.ScaleValues),
                typeof(Dock.DepthValues),
                typeof(Dock.RendererCommonValues),
                typeof(Dock.RendererValues),
                typeof(Dock.SoundValues),
                typeof(Dock.FCurves),
                typeof(Dock.ViewPoint),
                typeof(Dock.Recorder),
                typeof(Dock.Option),
                typeof(Dock.Environement),
                typeof(Dock.GlobalValues),
                typeof(Dock.BehaviorValues),
                typeof(Dock.Culling),
                typeof(Dock.Network),
                typeof(Dock.FileViewer),
                typeof(Dock.Dynamic),
                typeof(Dock.ProceduralModel),
                typeof(Dock.AdvancedRenderCommonValues),
            };

            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, dockTypes))
            {
                throw new InvalidOperationException("Initialization failed.");
            }
        }
Exemple #6
0
        public EffectViwerPaneBase(swig.DeviceType deviceType)
        {
            Label      = Resources.GetString("Viewer") + "###Viewer";
            renderMode = new Component.Enum();
            renderMode.Initialize(typeof(Data.OptionValues.RenderMode));
            renderMode.SetBinding(Core.Option.RenderingMode);
            renderMode.EnableUndo = false;
            viewMode = new Component.Enum();
            viewMode.Initialize(typeof(Data.OptionValues.ViewMode));
            viewMode.SetBinding(Core.Option.ViewerMode);
            viewMode.EnableUndo = false;

            NoPadding      = true;
            NoScrollBar    = true;
            NoCloseButton  = true;
            AllowsShortTab = false;

            this.deviceType = deviceType;
        }
Exemple #7
0
        public bool Initialize(swig.DeviceType deviceType)
        {
            if (isViewerShown)
            {
                return(false);
            }

            // because internal buffer is 16bit
            var spriteCount = 65000 / 4;

            effectSetting = swig.EffectSetting.Create(hardwareDevice.GraphicsDevice, hardwareDevice.SoundDevice);

            EffectRenderer = new swig.MainScreenEffectRenderer();
            EffectRenderer.Initialize(hardwareDevice.GraphicsDevice, hardwareDevice.SoundDevice, effectSetting, spriteCount, hardwareDevice.GraphicsDevice.GetIsSRGBMode());

            ViewPointController = new swig.ViewPointController();

            ViewPointController.ProjectionStyle = deviceType == swig.DeviceType.OpenGL ? swig.ProjectionMatrixStyle.OpenGLStyle : swig.ProjectionMatrixStyle.DirectXStyle;

            ViewMode_OnChanged(null, null);
            Core.Option.ViewerMode.OnChanged += ViewMode_OnChanged;

            Core.Option.RenderingMode.OnChanged += RenderingMode_OnChanged;
            RenderingMode_OnChanged(null, null);

            Bloom_OnChanged(null, null);
            Core.Environment.PostEffect.BloomSwitch.OnChanged     += Bloom_OnChanged;
            Core.Environment.PostEffect.Bloom.Intensity.OnChanged += Bloom_OnChanged;
            Core.Environment.PostEffect.Bloom.Threshold.OnChanged += Bloom_OnChanged;
            Core.Environment.PostEffect.Bloom.SoftKnee.OnChanged  += Bloom_OnChanged;

            Tonemap_OnChanged(null, null);
            Core.Environment.PostEffect.TonemapSelector.OnChanged          += Tonemap_OnChanged;
            Core.Environment.PostEffect.TonemapReinhard.Exposure.OnChanged += Tonemap_OnChanged;

            effectFactory = new swig.EffectFactory(effectSetting);

            isViewerShown = true;

            return(true);
        }
Exemple #8
0
        public bool ShowViewer(IntPtr handle, int width, int height, swig.DeviceType deviceType)
        {
            if (isViewerShown)
            {
                return(false);
            }

            if (native == null)
            {
                throw new Exception("native is null.");
            }

            if (native.CreateWindow_Effekseer(
                    handle,
                    width <= 0 ? 1 : width,
                    height <= 0 ? 1 : height,
                    Core.Option.ColorSpace.Value == Data.OptionValues.ColorSpaceType.LinearSpace,
                    deviceType))
            {
                isViewerShown = true;
                return(true);
            }
            else
            {
                if (Core.Language == Language.Japanese)
                {
                    Core.OnOutputMessage("描画画面の生成に失敗しました。DirectXのバージョンの問題、メモリの不足等が考えられます。");
                }
                else
                {
                    Core.OnOutputMessage("Failed to generate drawing screen. DirectX version problems, memory shortage, and so on.");
                }
            }

            return(false);
        }
Exemple #9
0
        public static bool Initialize(int width, int height, swig.DeviceType deviceType, Type[] dockTypes_)
        {
            dockTypes = dockTypes_;
            var appDirectory = Manager.GetEntryDirectory();

            swig.MainWindowState state = new swig.MainWindowState();

            if (System.Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                IsWindowFrameless = true;
            }

            // TODO : refactor
            var windowConfig = new Configs.WindowConfig();

            if (windowConfig.Load(ConfigFilePath))
            {
                state.PosX          = windowConfig.WindowPosX;
                state.PosY          = windowConfig.WindowPosY;
                state.Width         = windowConfig.WindowWidth;
                state.Height        = windowConfig.WindowHeight;
                state.IsMaximumMode = windowConfig.WindowIsMaximumMode;
            }
            else
            {
                state.PosX   = -10000;               // nodata
                state.Width  = 1280;
                state.Height = 720;
                windowConfig = null;
            }

            state.IsFrameless = IsWindowFrameless;

            if (!swig.MainWindow.Initialize("Effekseer", state, false, deviceType == swig.DeviceType.OpenGL))
            {
                return(false);
            }
            MainWindow = swig.MainWindow.GetInstance();

            swig.IO.Initialize(1000);
            IO         = swig.IO.GetInstance();
            ioCallback = new ManagerIOCallback();
            IO.AddCallback(ioCallback);

            Core.OnFileLoaded += (string path) => {
#if DEBUG
                Console.WriteLine("OnFileLoaded : " + path);
#endif

                var f = IO.LoadIPCFile(path);
                if (f == null)
                {
                    f = IO.LoadFile(path);
                }

                // TODO : refactor it
                // Permission error
                if (f != null && f.GetSize() == 0)
                {
                    var message = MultiLanguageTextProvider.GetText("PermissionError_File");

                    if (swig.GUIManager.IsMacOSX())
                    {
                        message += "\n";
                        message += MultiLanguageTextProvider.GetText("PermissionError_File_Mac");
                    }

                    message = string.Format(message, System.IO.Path.GetFileName(path));

                    throw new FileLoadPermissionException(message);
                }

                if (f == null)
                {
                    return(null);
                }

                byte[] ret = new byte[f.GetSize()];
                System.Runtime.InteropServices.Marshal.Copy(f.GetData(), ret, 0, ret.Length);
                f.Dispose();
                return(ret);
            };

            ThumbnailManager.Initialize();

            var mgr = new swig.GUIManager();
            if (mgr.Initialize(MainWindow, deviceType))
            {
            }
            else
            {
                mgr.Dispose();
                mgr = null;
                return(false);
            }

            Native = new swig.Native();

            Viewer = new Viewer(Native);
            if (!Viewer.ShowViewer(mgr.GetNativeHandle(), state.Width, state.Height, deviceType))
            {
                mgr.Dispose();
                mgr = null;
                return(false);
            }

            mgr.InitializeGUI(Native);

            NativeManager = mgr;

            Images.Load(GUI.Manager.Native);

            guiManagerCallback = new GUIManagerCallback();
            NativeManager.SetCallback(guiManagerCallback);

            panels = new Dock.DockPanel[dockTypes.Length];

            // Load font
            UpdateFont();

            // Load window icon
            NativeManager.SetWindowIcon(System.IO.Path.Combine(appDirectory, "resources/icon.png"));

            // Load config
            RecentFiles.LoadRecentConfig();
            Shortcuts.LoadShortcuts();
            Commands.Register();

            // Add controls
            Application.Current.OnCreateMainMenu();

            dockManager = new GUI.Dock.DockManager();
            GUI.Manager.AddControl(dockManager);

            // EffectViwer
            Application.Current.OnCreateEffectViwer();

            if (LoadWindowConfig(ConfigFilePath))
            {
            }
            else
            {
                ResetWindow();
            }

            TextOffsetY = (NativeManager.GetTextLineHeightWithSpacing() - NativeManager.GetTextLineHeight()) / 2;

            Network = new Network(Native);
            Network.Load();

            Command.CommandManager.Changed += OnChanged;

            Core.EffectBehavior.Location.X.OnChanged += OnChanged;
            Core.EffectBehavior.Location.Y.OnChanged += OnChanged;
            Core.EffectBehavior.Location.Z.OnChanged += OnChanged;
            Core.EffectBehavior.Rotation.X.OnChanged += OnChanged;
            Core.EffectBehavior.Rotation.Y.OnChanged += OnChanged;
            Core.EffectBehavior.Rotation.Z.OnChanged += OnChanged;
            Core.EffectBehavior.Scale.X.OnChanged    += OnChanged;
            Core.EffectBehavior.Scale.Y.OnChanged    += OnChanged;
            Core.EffectBehavior.Scale.Z.OnChanged    += OnChanged;

            Core.EffectBehavior.LocationVelocity.X.OnChanged   += OnChanged;
            Core.EffectBehavior.LocationVelocity.Y.OnChanged   += OnChanged;
            Core.EffectBehavior.LocationVelocity.Z.OnChanged   += OnChanged;
            Core.EffectBehavior.RotationVelocity.X.OnChanged   += OnChanged;
            Core.EffectBehavior.RotationVelocity.Y.OnChanged   += OnChanged;
            Core.EffectBehavior.RotationVelocity.Z.OnChanged   += OnChanged;
            Core.EffectBehavior.ScaleVelocity.X.OnChanged      += OnChanged;
            Core.EffectBehavior.ScaleVelocity.Y.OnChanged      += OnChanged;
            Core.EffectBehavior.ScaleVelocity.Z.OnChanged      += OnChanged;
            Core.EffectBehavior.RemovedTime.Infinite.OnChanged += OnChanged;
            Core.EffectBehavior.RemovedTime.Value.OnChanged    += OnChanged;

            Core.EffectBehavior.TargetLocation.X.OnChanged += OnChanged;
            Core.EffectBehavior.TargetLocation.Y.OnChanged += OnChanged;
            Core.EffectBehavior.TargetLocation.Z.OnChanged += OnChanged;

            Core.EffectBehavior.CountX.OnChanged += OnChanged;
            Core.EffectBehavior.CountY.OnChanged += OnChanged;
            Core.EffectBehavior.CountZ.OnChanged += OnChanged;

            Core.EffectBehavior.Distance.OnChanged += OnChanged;

            Core.EffectBehavior.TimeSpan.OnChanged   += OnChanged;
            Core.EffectBehavior.ColorAll.R.OnChanged += OnChanged;
            Core.EffectBehavior.ColorAll.G.OnChanged += OnChanged;
            Core.EffectBehavior.ColorAll.B.OnChanged += OnChanged;
            Core.EffectBehavior.ColorAll.A.OnChanged += OnChanged;

            Core.EffectBehavior.PlaybackSpeed.OnChanged += OnChanged;

            Core.Option.Magnification.OnChanged += OnChanged;
            Core.Option.IsGridShown.OnChanged   += OnChanged;
            Core.Option.GridLength.OnChanged    += OnChanged;
            Core.Option.GridColor.R.OnChanged   += OnChanged;
            Core.Option.GridColor.G.OnChanged   += OnChanged;
            Core.Option.GridColor.B.OnChanged   += OnChanged;
            Core.Option.GridColor.A.OnChanged   += OnChanged;
            Core.Option.FPS.OnChanged           += OnChanged;

            Core.Option.DistortionType.OnChanged += OnChanged;
            Core.Option.Coordinate.OnChanged     += OnChanged;

            Core.Environment.Background.BackgroundColor.R.OnChanged += OnChanged;
            Core.Environment.Background.BackgroundColor.G.OnChanged += OnChanged;
            Core.Environment.Background.BackgroundColor.B.OnChanged += OnChanged;
            Core.Environment.Background.BackgroundColor.A.OnChanged += OnChanged;
            Core.Environment.Background.BackgroundImage.OnChanged   += OnChanged;

            Core.Environment.Ground.IsShown.OnChanged += OnChanged;
            Core.Environment.Ground.Height.OnChanged  += OnChanged;
            Core.Environment.Ground.Extent.OnChanged  += OnChanged;

            Core.Culling.IsShown.OnChanged           += OnChanged;
            Core.Culling.Type.OnChanged              += OnChanged;
            Core.Culling.Sphere.Location.X.OnChanged += OnChanged;
            Core.Culling.Sphere.Location.Y.OnChanged += OnChanged;
            Core.Culling.Sphere.Location.Z.OnChanged += OnChanged;
            Core.Culling.Sphere.Radius.OnChanged     += OnChanged;

            Core.OnAfterLoad += new EventHandler(Core_OnAfterLoad);
            Core.OnAfterNew  += new EventHandler(Core_OnAfterNew);
            Core.OnReload    += new EventHandler(Core_OnReload);

            // Set imgui path
            var entryDirectory = GetEntryDirectory();
            swig.GUIManager.SetIniFilename(ImGuiIniFilePath);

            // check files
            if (!System.IO.File.Exists(System.IO.Path.Combine(appDirectory, "resources/fonts/GenShinGothic-Monospace-Bold.ttf")))
            {
                ErrorUtils.ThrowFileNotfound();
            }

            if (!System.IO.File.Exists(System.IO.Path.Combine(appDirectory, "resources/icons/MenuIcons.png")))
            {
                ErrorUtils.ThrowFileNotfound();
            }

            return(true);
        }
Exemple #10
0
 public bool Initialize(IntPtr handle, int width, int height, swig.DeviceType deviceType)
 {
     GraphicsDevice = swig.GraphicsDevice.Create(handle, width, height, Core.Option.ColorSpace.Value == Data.OptionValues.ColorSpaceType.LinearSpace, deviceType);
     SoundDevice    = swig.SoundDevice.Create();
     return(GraphicsDevice != null);
 }
Exemple #11
0
        static void Exec(bool gui, string input, string output, string export, float magnification)
        {
            var      languageIndex = swig.GUIManager.GetLanguage();
            Language?language      = null;

            if (languageIndex >= 0)
            {
                language = (Language)languageIndex;
            }

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

            // Failed to compile script
            if (Core.ExportScripts.Count == 0)
            {
                Script.ExportScript script = 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(script);
            }

            if (Core.Language == Language.Japanese)
            {
                Resources.LoadLanguageFile("resources/lang_ja.txt");
            }
            if (Core.Language == Language.English)
            {
                Resources.LoadLanguageFile("resources/lang_en.txt");
            }

            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;
            }

            //Images.Load(GUI.Manager.Native);

            //GUI.Manager.AddControl(new DebugMenu());

            //GUI.Manager.AddControl(new TestWindow());

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

            //Images.Unload();

            GUI.Manager.Terminate();

            Core.Dispose();
        }
Exemple #12
0
        public static bool Initialize(int width, int height, swig.DeviceType deviceType)
        {
            var mgr = new swig.GUIManager();

            if (mgr.Initialize("Effekseer", 1280, 720, deviceType, false))
            {
            }
            else
            {
                mgr.Dispose();
                mgr = null;
                return(false);
            }

            Native = new swig.Native();

            Viewer = new Viewer(Native);
            if (!Viewer.ShowViewer(mgr.GetNativeHandle(), 1280, 720, deviceType))
            {
                mgr.Dispose();
                mgr = null;
                return(false);
            }

            mgr.InitializeGUI(Native);

            NativeManager = mgr;

            Images.Load(GUI.Manager.Native);

            guiManagerCallback = new GUIManagerCallback();
            NativeManager.SetCallback(guiManagerCallback);

            panels = new Dock.DockPanel[dockTypes.Length];

            // Load font
            NativeManager.AddFontFromFileTTF("resources/GenShinGothic-Monospace-Normal.ttf", 16);

            // Load window icon
            NativeManager.SetWindowIcon("resources/icon.png");

            // Load config
            RecentFiles.LoadRecentConfig();
            Shortcuts.LoadShortcuts();
            Commands.Register();

            // Add controls
            var mainMenu = new GUI.Menu.MainMenu();

            GUI.Manager.AddControl(mainMenu);

            dockManager = new GUI.Dock.DockManager();
            GUI.Manager.AddControl(dockManager);

            // Default
            effectViewer = new Dock.EffectViwer();
            if (dockManager != null)
            {
                effectViewer.InitialDockSlot = swig.DockSlot.None;
                dockManager.Controls.Add(effectViewer);
            }
            else
            {
                AddControl(effectViewer);
            }

            if (LoadWindowConfig("config.Dock.xml"))
            {
                Manager.NativeManager.LoadDock("config.Dock.config");
            }
            else
            {
                ResetWindowActually();
            }

            TextOffsetY = (NativeManager.GetTextLineHeightWithSpacing() - NativeManager.GetTextLineHeight()) / 2;

            Network = new Network(Native);

            Command.CommandManager.Changed += OnChanged;

            Core.EffectBehavior.Location.X.OnChanged += OnChanged;
            Core.EffectBehavior.Location.Y.OnChanged += OnChanged;
            Core.EffectBehavior.Location.Z.OnChanged += OnChanged;
            Core.EffectBehavior.Rotation.X.OnChanged += OnChanged;
            Core.EffectBehavior.Rotation.Y.OnChanged += OnChanged;
            Core.EffectBehavior.Rotation.Z.OnChanged += OnChanged;
            Core.EffectBehavior.Scale.X.OnChanged    += OnChanged;
            Core.EffectBehavior.Scale.Y.OnChanged    += OnChanged;
            Core.EffectBehavior.Scale.Z.OnChanged    += OnChanged;

            Core.EffectBehavior.LocationVelocity.X.OnChanged   += OnChanged;
            Core.EffectBehavior.LocationVelocity.Y.OnChanged   += OnChanged;
            Core.EffectBehavior.LocationVelocity.Z.OnChanged   += OnChanged;
            Core.EffectBehavior.RotationVelocity.X.OnChanged   += OnChanged;
            Core.EffectBehavior.RotationVelocity.Y.OnChanged   += OnChanged;
            Core.EffectBehavior.RotationVelocity.Z.OnChanged   += OnChanged;
            Core.EffectBehavior.ScaleVelocity.X.OnChanged      += OnChanged;
            Core.EffectBehavior.ScaleVelocity.Y.OnChanged      += OnChanged;
            Core.EffectBehavior.ScaleVelocity.Z.OnChanged      += OnChanged;
            Core.EffectBehavior.RemovedTime.Infinite.OnChanged += OnChanged;
            Core.EffectBehavior.RemovedTime.Value.OnChanged    += OnChanged;

            Core.EffectBehavior.TargetLocation.X.OnChanged += OnChanged;
            Core.EffectBehavior.TargetLocation.Y.OnChanged += OnChanged;
            Core.EffectBehavior.TargetLocation.Z.OnChanged += OnChanged;

            Core.EffectBehavior.CountX.OnChanged += OnChanged;
            Core.EffectBehavior.CountY.OnChanged += OnChanged;
            Core.EffectBehavior.CountZ.OnChanged += OnChanged;

            Core.EffectBehavior.Distance.OnChanged += OnChanged;

            Core.EffectBehavior.TimeSpan.OnChanged   += OnChanged;
            Core.EffectBehavior.ColorAll.R.OnChanged += OnChanged;
            Core.EffectBehavior.ColorAll.G.OnChanged += OnChanged;
            Core.EffectBehavior.ColorAll.B.OnChanged += OnChanged;
            Core.EffectBehavior.ColorAll.A.OnChanged += OnChanged;

            Core.Option.Magnification.OnChanged     += OnChanged;
            Core.Option.IsGridShown.OnChanged       += OnChanged;
            Core.Option.GridLength.OnChanged        += OnChanged;
            Core.Option.BackgroundColor.R.OnChanged += OnChanged;
            Core.Option.BackgroundColor.G.OnChanged += OnChanged;
            Core.Option.BackgroundColor.B.OnChanged += OnChanged;
            Core.Option.BackgroundColor.A.OnChanged += OnChanged;
            Core.Option.GridColor.R.OnChanged       += OnChanged;
            Core.Option.GridColor.G.OnChanged       += OnChanged;
            Core.Option.GridColor.B.OnChanged       += OnChanged;
            Core.Option.GridColor.A.OnChanged       += OnChanged;
            Core.Option.FPS.OnChanged += OnChanged;

            Core.Option.DistortionType.OnChanged += OnChanged;
            Core.Option.Coordinate.OnChanged     += OnChanged;

            Core.Option.BackgroundImage.OnChanged += OnChanged;

            Core.Culling.IsShown.OnChanged           += OnChanged;
            Core.Culling.Type.OnChanged              += OnChanged;
            Core.Culling.Sphere.Location.X.OnChanged += OnChanged;
            Core.Culling.Sphere.Location.Y.OnChanged += OnChanged;
            Core.Culling.Sphere.Location.Z.OnChanged += OnChanged;
            Core.Culling.Sphere.Radius.OnChanged     += OnChanged;

            Core.OnAfterLoad += new EventHandler(Core_OnAfterLoad);
            Core.OnAfterNew  += new EventHandler(Core_OnAfterNew);
            Core.OnReload    += new EventHandler(Core_OnReload);

            // Set imgui path
            var entryDirectory = GetEntryDirectory();

            swig.GUIManager.SetIniFilename(entryDirectory + "/imgui.ini");

            return(true);
        }
Exemple #13
0
        public static bool Initialize(int width, int height, swig.DeviceType deviceType)
        {
            var appDirectory = Manager.GetEntryDirectory();

            swig.MainWindowState state = new swig.MainWindowState();

            // TODO : refactor
            var windowConfig = new Configs.WindowConfig();

            if (windowConfig.Load(System.IO.Path.Combine(appDirectory, "config.Dock.xml")))
            {
                state.PosX          = windowConfig.WindowPosX;
                state.PosY          = windowConfig.WindowPosY;
                state.Width         = windowConfig.WindowWidth;
                state.Height        = windowConfig.WindowHeight;
                state.IsMaximumMode = windowConfig.WindowIsMaximumMode;
            }
            else
            {
                state.PosX   = -10000;               // nodata
                state.Width  = 1280;
                state.Height = 720;
                windowConfig = null;
            }

            if (!swig.MainWindow.Initialize("Effekseer", state, false, deviceType == swig.DeviceType.OpenGL))
            {
                return(false);
            }
            MainWindow = swig.MainWindow.GetInstance();

            swig.IO.Initialize(1000);
            IO         = swig.IO.GetInstance();
            ioCallback = new ManagerIOCallback();
            IO.AddCallback(ioCallback);
            ThumbnailManager.Initialize();

            var mgr = new swig.GUIManager();

            if (mgr.Initialize(MainWindow, deviceType))
            {
            }
            else
            {
                mgr.Dispose();
                mgr = null;
                return(false);
            }

            Native = new swig.Native();

            Viewer = new Viewer(Native);
            if (!Viewer.ShowViewer(mgr.GetNativeHandle(), state.Width, state.Height, deviceType))
            {
                mgr.Dispose();
                mgr = null;
                return(false);
            }

            mgr.InitializeGUI(Native);

            NativeManager = mgr;

            Images.Load(GUI.Manager.Native);

            guiManagerCallback = new GUIManagerCallback();
            NativeManager.SetCallback(guiManagerCallback);

            panels = new Dock.DockPanel[dockTypes.Length];

            // Load font
            UpdateFontSize();

            // Load window icon
            NativeManager.SetWindowIcon(System.IO.Path.Combine(appDirectory, "resources/icon.png"));

            // Load config
            RecentFiles.LoadRecentConfig();
            Shortcuts.LoadShortcuts();
            Commands.Register();

            // Add controls
            var mainMenu = new GUI.Menu.MainMenu();

            GUI.Manager.AddControl(mainMenu);

            dockManager = new GUI.Dock.DockManager();
            GUI.Manager.AddControl(dockManager);

            // Default
            effectViewer = new Dock.EffectViwer();
            if (dockManager != null)
            {
                effectViewer.InitialDockSlot = swig.DockSlot.None;
                dockManager.Controls.Add(effectViewer);
            }
            else
            {
                AddControl(effectViewer);
            }

            // TODO : refactor
            if (LoadWindowConfig(System.IO.Path.Combine(appDirectory, "config.Dock.xml")))
            {
                Manager.NativeManager.LoadDock(System.IO.Path.Combine(appDirectory, "config.Dock.config"));
            }
            else
            {
                ResetWindowActually();
            }

            TextOffsetY = (NativeManager.GetTextLineHeightWithSpacing() - NativeManager.GetTextLineHeight()) / 2;

            Network = new Network(Native);
            Network.Load();

            Command.CommandManager.Changed += OnChanged;

            Core.EffectBehavior.Location.X.OnChanged += OnChanged;
            Core.EffectBehavior.Location.Y.OnChanged += OnChanged;
            Core.EffectBehavior.Location.Z.OnChanged += OnChanged;
            Core.EffectBehavior.Rotation.X.OnChanged += OnChanged;
            Core.EffectBehavior.Rotation.Y.OnChanged += OnChanged;
            Core.EffectBehavior.Rotation.Z.OnChanged += OnChanged;
            Core.EffectBehavior.Scale.X.OnChanged    += OnChanged;
            Core.EffectBehavior.Scale.Y.OnChanged    += OnChanged;
            Core.EffectBehavior.Scale.Z.OnChanged    += OnChanged;

            Core.EffectBehavior.LocationVelocity.X.OnChanged   += OnChanged;
            Core.EffectBehavior.LocationVelocity.Y.OnChanged   += OnChanged;
            Core.EffectBehavior.LocationVelocity.Z.OnChanged   += OnChanged;
            Core.EffectBehavior.RotationVelocity.X.OnChanged   += OnChanged;
            Core.EffectBehavior.RotationVelocity.Y.OnChanged   += OnChanged;
            Core.EffectBehavior.RotationVelocity.Z.OnChanged   += OnChanged;
            Core.EffectBehavior.ScaleVelocity.X.OnChanged      += OnChanged;
            Core.EffectBehavior.ScaleVelocity.Y.OnChanged      += OnChanged;
            Core.EffectBehavior.ScaleVelocity.Z.OnChanged      += OnChanged;
            Core.EffectBehavior.RemovedTime.Infinite.OnChanged += OnChanged;
            Core.EffectBehavior.RemovedTime.Value.OnChanged    += OnChanged;

            Core.EffectBehavior.TargetLocation.X.OnChanged += OnChanged;
            Core.EffectBehavior.TargetLocation.Y.OnChanged += OnChanged;
            Core.EffectBehavior.TargetLocation.Z.OnChanged += OnChanged;

            Core.EffectBehavior.CountX.OnChanged += OnChanged;
            Core.EffectBehavior.CountY.OnChanged += OnChanged;
            Core.EffectBehavior.CountZ.OnChanged += OnChanged;

            Core.EffectBehavior.Distance.OnChanged += OnChanged;

            Core.EffectBehavior.TimeSpan.OnChanged   += OnChanged;
            Core.EffectBehavior.ColorAll.R.OnChanged += OnChanged;
            Core.EffectBehavior.ColorAll.G.OnChanged += OnChanged;
            Core.EffectBehavior.ColorAll.B.OnChanged += OnChanged;
            Core.EffectBehavior.ColorAll.A.OnChanged += OnChanged;

            Core.Option.Magnification.OnChanged += OnChanged;
            Core.Option.IsGridShown.OnChanged   += OnChanged;
            Core.Option.GridLength.OnChanged    += OnChanged;
            Core.Option.GridColor.R.OnChanged   += OnChanged;
            Core.Option.GridColor.G.OnChanged   += OnChanged;
            Core.Option.GridColor.B.OnChanged   += OnChanged;
            Core.Option.GridColor.A.OnChanged   += OnChanged;
            Core.Option.FPS.OnChanged           += OnChanged;

            Core.Option.DistortionType.OnChanged += OnChanged;
            Core.Option.Coordinate.OnChanged     += OnChanged;

            Core.Environment.Background.BackgroundColor.R.OnChanged += OnChanged;
            Core.Environment.Background.BackgroundColor.G.OnChanged += OnChanged;
            Core.Environment.Background.BackgroundColor.B.OnChanged += OnChanged;
            Core.Environment.Background.BackgroundColor.A.OnChanged += OnChanged;
            Core.Environment.Background.BackgroundImage.OnChanged   += OnChanged;

            Core.Culling.IsShown.OnChanged           += OnChanged;
            Core.Culling.Type.OnChanged              += OnChanged;
            Core.Culling.Sphere.Location.X.OnChanged += OnChanged;
            Core.Culling.Sphere.Location.Y.OnChanged += OnChanged;
            Core.Culling.Sphere.Location.Z.OnChanged += OnChanged;
            Core.Culling.Sphere.Radius.OnChanged     += OnChanged;

            Core.OnAfterLoad += new EventHandler(Core_OnAfterLoad);
            Core.OnAfterNew  += new EventHandler(Core_OnAfterNew);
            Core.OnReload    += new EventHandler(Core_OnReload);

            // Set imgui path
            var entryDirectory = GetEntryDirectory();

            swig.GUIManager.SetIniFilename(entryDirectory + "/imgui.ini");

            // check files
            if (!System.IO.File.Exists(System.IO.Path.Combine(appDirectory, "resources/fonts/GenShinGothic-Monospace-Bold.ttf")))
            {
                ErrorUtils.ThrowFileNotfound();
            }

            return(true);
        }
Exemple #14
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();
        }
Exemple #15
0
        static void Exec(bool gui, string input, string output, string export, float magnification)
        {
            var      languageIndex = swig.GUIManager.GetLanguage();
            Language?language      = null;

            if (languageIndex >= 0)
            {
                language = (Language)languageIndex;
            }

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

            if (gui)
            {
                // Failed to compile script
                if (Core.ExportScripts.Count == 0)
                {
                    Script.ExportScript script = 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(script);
                }

                {
                    var appDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                    if (Core.Language == Language.Japanese)
                    {
                        var fullPath = Path.Combine(appDirectory, "resources/lang_ja.txt");
                        Resources.LoadLanguageFile(fullPath);
                    }
                    if (Core.Language == Language.English)
                    {
                        var fullPath = Path.Combine(appDirectory, "resources/lang_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;
                    }

                    var binary = Binary.Exporter.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();
            }

            Core.Dispose();
        }
Exemple #16
0
        public static bool Initialize(int width, int height, swig.DeviceType deviceType)
        {
            var mgr = new swig.GUIManager();

            if (mgr.Initialize("Effekseer", 1280, 720, deviceType, false))
            {
            }
            else
            {
                mgr.Dispose();
                mgr = null;
                return(false);
            }

            Native = new swig.Native();

            Viewer = new Viewer(Native);
            if (!Viewer.ShowViewer(mgr.GetNativeHandle(), 1280, 720, deviceType))
            {
                mgr.Dispose();
                mgr = null;
                return(false);
            }

            mgr.InitializeGUI(Native);

            NativeManager = mgr;

            Images.Load(GUI.Manager.Native);

            guiManagerCallback = new GUIManagerCallback();
            NativeManager.SetCallback(guiManagerCallback);

            panels = new Dock.DockPanel[dockTypes.Length];

            var appDirectory = Manager.GetEntryDirectory();

            // Load font
            UpdateFontSize();

            // Load window icon
            NativeManager.SetWindowIcon(System.IO.Path.Combine(appDirectory, "resources/icon.png"));

            // Load config
            RecentFiles.LoadRecentConfig();
            Shortcuts.LoadShortcuts();
            Commands.Register();

            // Add controls
            var mainMenu = new GUI.Menu.MainMenu();

            GUI.Manager.AddControl(mainMenu);

            dockManager = new GUI.Dock.DockManager();
            GUI.Manager.AddControl(dockManager);

            // Default
            effectViewer = new Dock.EffectViwer();
            if (dockManager != null)
            {
                effectViewer.InitialDockSlot = swig.DockSlot.None;
                dockManager.Controls.Add(effectViewer);
            }
            else
            {
                AddControl(effectViewer);
            }

            if (LoadWindowConfig(System.IO.Path.Combine(appDirectory, "config.Dock.xml")))
            {
                Manager.NativeManager.LoadDock(System.IO.Path.Combine(appDirectory, "config.Dock.config"));
            }
            else
            {
                ResetWindowActually();
            }

            TextOffsetY = (NativeManager.GetTextLineHeightWithSpacing() - NativeManager.GetTextLineHeight()) / 2;

            Network = new Network(Native);
            Network.Load();

            Command.CommandManager.Changed += OnChanged;

            Core.EffectBehavior.Location.X.OnChanged += OnChanged;
            Core.EffectBehavior.Location.Y.OnChanged += OnChanged;
            Core.EffectBehavior.Location.Z.OnChanged += OnChanged;
            Core.EffectBehavior.Rotation.X.OnChanged += OnChanged;
            Core.EffectBehavior.Rotation.Y.OnChanged += OnChanged;
            Core.EffectBehavior.Rotation.Z.OnChanged += OnChanged;
            Core.EffectBehavior.Scale.X.OnChanged    += OnChanged;
            Core.EffectBehavior.Scale.Y.OnChanged    += OnChanged;
            Core.EffectBehavior.Scale.Z.OnChanged    += OnChanged;

            Core.EffectBehavior.LocationVelocity.X.OnChanged   += OnChanged;
            Core.EffectBehavior.LocationVelocity.Y.OnChanged   += OnChanged;
            Core.EffectBehavior.LocationVelocity.Z.OnChanged   += OnChanged;
            Core.EffectBehavior.RotationVelocity.X.OnChanged   += OnChanged;
            Core.EffectBehavior.RotationVelocity.Y.OnChanged   += OnChanged;
            Core.EffectBehavior.RotationVelocity.Z.OnChanged   += OnChanged;
            Core.EffectBehavior.ScaleVelocity.X.OnChanged      += OnChanged;
            Core.EffectBehavior.ScaleVelocity.Y.OnChanged      += OnChanged;
            Core.EffectBehavior.ScaleVelocity.Z.OnChanged      += OnChanged;
            Core.EffectBehavior.RemovedTime.Infinite.OnChanged += OnChanged;
            Core.EffectBehavior.RemovedTime.Value.OnChanged    += OnChanged;

            Core.EffectBehavior.TargetLocation.X.OnChanged += OnChanged;
            Core.EffectBehavior.TargetLocation.Y.OnChanged += OnChanged;
            Core.EffectBehavior.TargetLocation.Z.OnChanged += OnChanged;

            Core.EffectBehavior.CountX.OnChanged += OnChanged;
            Core.EffectBehavior.CountY.OnChanged += OnChanged;
            Core.EffectBehavior.CountZ.OnChanged += OnChanged;

            Core.EffectBehavior.Distance.OnChanged += OnChanged;

            Core.EffectBehavior.TimeSpan.OnChanged   += OnChanged;
            Core.EffectBehavior.ColorAll.R.OnChanged += OnChanged;
            Core.EffectBehavior.ColorAll.G.OnChanged += OnChanged;
            Core.EffectBehavior.ColorAll.B.OnChanged += OnChanged;
            Core.EffectBehavior.ColorAll.A.OnChanged += OnChanged;

            Core.Option.Magnification.OnChanged += OnChanged;
            Core.Option.IsGridShown.OnChanged   += OnChanged;
            Core.Option.GridLength.OnChanged    += OnChanged;
            Core.Option.GridColor.R.OnChanged   += OnChanged;
            Core.Option.GridColor.G.OnChanged   += OnChanged;
            Core.Option.GridColor.B.OnChanged   += OnChanged;
            Core.Option.GridColor.A.OnChanged   += OnChanged;
            Core.Option.FPS.OnChanged           += OnChanged;

            Core.Option.DistortionType.OnChanged += OnChanged;
            Core.Option.Coordinate.OnChanged     += OnChanged;

            Core.Environment.Background.BackgroundColor.R.OnChanged += OnChanged;
            Core.Environment.Background.BackgroundColor.G.OnChanged += OnChanged;
            Core.Environment.Background.BackgroundColor.B.OnChanged += OnChanged;
            Core.Environment.Background.BackgroundColor.A.OnChanged += OnChanged;
            Core.Environment.Background.BackgroundImage.OnChanged   += OnChanged;

            Core.Culling.IsShown.OnChanged           += OnChanged;
            Core.Culling.Type.OnChanged              += OnChanged;
            Core.Culling.Sphere.Location.X.OnChanged += OnChanged;
            Core.Culling.Sphere.Location.Y.OnChanged += OnChanged;
            Core.Culling.Sphere.Location.Z.OnChanged += OnChanged;
            Core.Culling.Sphere.Radius.OnChanged     += OnChanged;

            Core.OnAfterLoad += new EventHandler(Core_OnAfterLoad);
            Core.OnAfterNew  += new EventHandler(Core_OnAfterNew);
            Core.OnReload    += new EventHandler(Core_OnReload);

            // Set imgui path
            var entryDirectory = GetEntryDirectory();

            swig.GUIManager.SetIniFilename(entryDirectory + "/imgui.ini");

            // check files
            if (!System.IO.File.Exists(System.IO.Path.Combine(appDirectory, "resources/fonts/GenShinGothic-Monospace-Bold.ttf")))
            {
                if (Core.Option.GuiLanguage.Value == Language.Japanese)
                {
                    throw new Exception("リソースファイルを更新してください。Script/setup.pyを呼ぶか、cmakeを使用し、ResourceDataをリビルドしてください。");
                }
                else
                {
                    throw new Exception("Please update resource files!. call Script/setup.py or use cmake and rebuild ResourceData.");
                }
            }

            return(true);
        }
Exemple #17
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();
        }
Exemple #18
0
 public EffectViwerDock(swig.DeviceType deviceType)
     : base(deviceType)
 {
 }