コード例 #1
0
        public StandaloneController(App app)
        {
            medicalConfig = new MedicalConfig();
            this.app      = app;

            guiManager = new GUIManager();
            guiManager.MainGUIShown  += guiManager_MainGUIShown;
            guiManager.MainGUIHidden += guiManager_MainGUIHidden;

            MyGUIInterface.OSTheme = PlatformConfig.ThemeFile;

            String title;

            if (MedicalConfig.BuildName != null)
            {
                title = String.Format("{0} {1}", app.Title, MedicalConfig.BuildName);
            }
            else
            {
                title = app.Title;
            }
            mainWindow         = new MainWindow(title);
            mainWindow.Closed += mainWindow_Closed;

            //Setup DPI
            float pixelScale = mainWindow.WindowScaling;

            if (MedicalConfig.PixelScaleOverride > 0.5f)
            {
                pixelScale = MedicalConfig.PixelScaleOverride;
            }

            float scaleFactor = pixelScale;

            pixelScale += MedicalConfig.PlatformExtraScaling * scaleFactor;

            switch (MedicalConfig.ExtraScaling)
            {
            case UIExtraScale.Smaller:
                pixelScale -= .15f * scaleFactor;
                break;

            case UIExtraScale.Larger:
                pixelScale += .25f * scaleFactor;
                break;
            }

            ScaleHelper._setScaleFactor(pixelScale);

            //Initialize engine
            medicalController = new MedicalController(mainWindow);
            idleHandler       = new IdleHandler(medicalController.MainTimer.OnIdle);

            PointerManager.Instance.Visible = false;

            ((RenderWindow)OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget).DeactivateOnFocusChange = false;
        }
コード例 #2
0
        private void BuildPluginManager()
        {
            mainWindow = new NativeOSWindow(startup.Title,
                                            new IntVector2(-1, -1),
                                            new IntSize2(CoreConfig.EngineConfig.HorizontalRes, CoreConfig.EngineConfig.VerticalRes));

            services.TryAddSingleton <OSWindow>(mainWindow);       //This is externally owned
            services.TryAddSingleton <NativeOSWindow>(mainWindow); //This is externally owned

            mainWindow.Closed += w =>
            {
                if (PlatformConfig.CloseMainWindowOnShutdown)
                {
                    mainWindow.close();
                }
                this.exit();
            };

            //Setup DPI
            float pixelScale = mainWindow.WindowScaling;

            switch (CoreConfig.ExtraScaling)
            {
            case UIExtraScale.Smaller:
                pixelScale -= .15f;
                break;

            case UIExtraScale.Larger:
                pixelScale += .25f;
                break;
            }

            ScaleHelper._setScaleFactor(pixelScale);

            pluginManager = new PluginManager(CoreConfig.ConfigFile, services);

            services.TryAddSingleton <SystemTimer, NativeSystemTimer>();

            services.TryAddSingleton <UpdateTimer, NativeUpdateTimer>();

            services.TryAddSingleton <InputHandler>(s =>
            {
                return(new NativeInputHandler(s.GetRequiredService <NativeOSWindow>(), CoreConfig.EnableMultitouch));
            });

            services.TryAddSingleton <EventManager>(s =>
            {
                return(new EventManager(s.GetRequiredService <InputHandler>(), Enum.GetValues(typeof(EventLayers))));
            });

            MyGUIInterface.EventLayerKey     = EventLayers.Gui;
            MyGUIInterface.CreateGuiGestures = CoreConfig.EnableMultitouch && PlatformConfig.TouchType == TouchType.Screen;

            OgreInterface.CompressedTextureSupport = CompressedTextureSupport.None;
            OgreInterface.TrackMemoryLeaks         = true;

            //Configure plugins
            pluginManager.OnConfigureDefaultWindow = delegate(out WindowInfo defaultWindow)
            {
                //Setup main window
                defaultWindow              = new WindowInfo(mainWindow, "Primary");
                defaultWindow.Fullscreen   = CoreConfig.EngineConfig.Fullscreen;
                defaultWindow.MonitorIndex = 0;

                if (CoreConfig.EngineConfig.Fullscreen)
                {
                    mainWindow.setSize(CoreConfig.EngineConfig.HorizontalRes, CoreConfig.EngineConfig.VerticalRes);
                    mainWindow.ExclusiveFullscreen = true;
                    defaultWindow.Width            = CoreConfig.EngineConfig.HorizontalRes;
                    defaultWindow.Height           = CoreConfig.EngineConfig.VerticalRes;
                }
                else
                {
                    mainWindow.Maximized = true;
                }
                mainWindow.show();
            };

            //GuiFrameworkCamerasInterface.CameraTransitionTime = MedicalConfig.CameraTransitionTime;
            //GuiFrameworkCamerasInterface.DefaultCameraButton = MedicalConfig.CameraMouseButton;
            GuiFrameworkCamerasInterface.MoveCameraEventLayer   = EventLayers.Cameras;
            GuiFrameworkCamerasInterface.SelectWindowEventLayer = EventLayers.AfterGui;
            GuiFrameworkCamerasInterface.ShortcutEventLayer     = EventLayers.AfterGui;
            GuiFrameworkCamerasInterface.TouchType = PlatformConfig.TouchType;
            GuiFrameworkCamerasInterface.PanKey    = PlatformConfig.PanKey;

            pluginManager.addPluginAssembly(typeof(OgreInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(BulletInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(NativePlatformPlugin).Assembly());
            pluginManager.addPluginAssembly(typeof(MyGUIInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(RocketInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(SoundPluginInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(GuiFrameworkInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(RocketWidgetInterface).Assembly());
            pluginManager.addPluginAssembly(typeof(GuiFrameworkCamerasInterface).Assembly());
            foreach (var assembly in startup.AdditionalPluginAssemblies)
            {
                pluginManager.addPluginAssembly(assembly);
            }
            pluginManager.initializePlugins();

            var scope = pluginManager.GlobalScope;

            var systemTimer  = scope.ServiceProvider.GetRequiredService <SystemTimer>();
            var mainTimer    = scope.ServiceProvider.GetRequiredService <UpdateTimer>();
            var inputHandler = this.InputHandler = scope.ServiceProvider.GetRequiredService <InputHandler>();
            var eventManager = scope.ServiceProvider.GetRequiredService <EventManager>();

            //Intialize the platform
            BulletInterface.Instance.ShapeMargin = 0.005f;

            //Setup framerate cap
            if (PlatformConfig.FpsCap.HasValue)
            {
                //Use platform cap if it is set always
                mainTimer.FramerateCap = PlatformConfig.FpsCap.Value;
            }
            else if (OgreConfig.VSync)
            {
                //Use a unlimited framerate cap if vsync is on since it will cap our
                //framerate for us. If the user has requested a higher rate use it anyway.
                mainTimer.FramerateCap = 0;
            }
            else
            {
                //Otherwise config cap
                mainTimer.FramerateCap = CoreConfig.EngineConfig.FPSCap;
            }

            mainTimer.addUpdateListener(new EventUpdateListener(eventManager));

            pluginManager.setPlatformInfo(mainTimer, eventManager);

            GuiFrameworkInterface.Instance.handleCursors(mainWindow);

            SoundConfig.initialize(CoreConfig.ConfigFile);

            GuiFrameworkInterface.Instance.handleCursors(mainWindow);
            SoundPluginInterface.Instance.setResourceWindow(mainWindow);

            var touchMouseGuiForwarder = new TouchMouseGuiForwarder(eventManager, inputHandler, systemTimer, mainWindow, EventLayers.Last);

            touchMouseGuiForwarder.ForwardTouchesAsMouse = PlatformConfig.ForwardTouchAsMouse;
            var myGuiKeyboard  = new MyGUIOnscreenKeyboardManager(touchMouseGuiForwarder);
            var rocketKeyboard = new RocketWidgetOnscreenKeyboardManager(touchMouseGuiForwarder);
        }
コード例 #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public AnomalyController(App app, Solution solution, IAnomalyImplementation implementation)
        {
            this.app            = app;
            this.solution       = solution;
            this.implementation = implementation;

            //Create the log.
            logListener = new LogFileListener();
            logListener.openLogFile(AnomalyConfig.DocRoot + "/log.log");
            Log.Default.addLogListener(logListener);

            mainWindow         = new NativeOSWindow(String.Format("{0} - Anomaly", solution.Name), new IntVector2(-1, -1), new IntSize2(AnomalyConfig.EngineConfig.HorizontalRes, AnomalyConfig.EngineConfig.VerticalRes));
            mainWindow.Closed += mainWindow_Closed;

            //Setup DPI
            float pixelScale = mainWindow.WindowScaling;

            ScaleHelper._setScaleFactor(pixelScale);

            var builder = new ServiceCollection();

            //Initialize the plugins
            pluginManager   = new PluginManager(AnomalyConfig.ConfigFile, builder);
            sceneController = new SceneController(pluginManager);
            //Hardcoded assemblies
            MyGUIInterface.EventLayerKey = EventLayers.Main;

            GuiFrameworkCamerasInterface.MoveCameraEventLayer   = EventLayers.Cameras;
            GuiFrameworkCamerasInterface.SelectWindowEventLayer = EventLayers.AfterMain;
            GuiFrameworkCamerasInterface.ShortcutEventLayer     = EventLayers.Main;

            GuiFrameworkEditorInterface.ToolsEventLayers = EventLayers.Tools;

            //Setup microcode cache load
            OgreInterface.MicrocodeCachePath      = Path.Combine(AnomalyConfig.DocRoot, "ShaderCache.mcc");
            OgreInterface.AllowMicrocodeCacheLoad = AnomalyConfig.LastShaderVersion == UnifiedMaterialBuilder.Version;
            AnomalyConfig.LastShaderVersion       = UnifiedMaterialBuilder.Version;

            implementation.AddPlugins(pluginManager);
            pluginManager.OnConfigureDefaultWindow = createWindow;

            //Create core classes
            systemTimer = new NativeSystemTimer();

            mainTimer = new NativeUpdateTimer(systemTimer);
            mainTimer.FramerateCap = AnomalyConfig.EngineConfig.MaxFPS;
            idleHandler            = new IdleHandler(mainTimer.OnIdle);
            inputHandler           = new NativeInputHandler(mainWindow, false);
            eventManager           = new EventManager(inputHandler, Enum.GetValues(typeof(EventLayers)));
            eventUpdate            = new EventUpdateListener(eventManager);

            builder.TryAddSingleton <EventManager>(eventManager); //This is externally owned

            pluginManager.initializePlugins();
            frameClearManager = new FrameClearManager(OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget, new Color(0.2f, 0.2f, 0.2f));

            lightManager = pluginManager.RendererPlugin.createSceneViewLightManager();

            //Core resources
            MyGUIInterface.Instance.CommonResourceGroup.addResource(this.GetType().AssemblyQualifiedName, "EmbeddedResource", true);
            OgreResourceGroupManager.getInstance().initializeAllResourceGroups();

            //Intialize the platform
            mainTimer.addUpdateListener(eventUpdate);
            mainTimer.addUpdateListener(updateEventListener);
            pluginManager.setPlatformInfo(mainTimer, eventManager);

            GuiFrameworkInterface.Instance.handleCursors(mainWindow);

            //Layout Chain
            mdiLayout = new MDILayoutManager();

            //Scene views
            sceneViewController      = new SceneViewController(mdiLayout, eventManager, mainTimer, pluginManager.RendererPlugin.PrimaryWindow, MyGUIInterface.Instance.OgrePlatform.RenderManager, null);
            sceneStatsDisplayManager = new SceneStatsDisplayManager(sceneViewController, OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget);
            sceneStatsDisplayManager.StatsVisible = true;
            sceneViewController.createWindow("Camera 1", AnomalyConfig.CameraConfig.MainCameraPosition, AnomalyConfig.CameraConfig.MainCameraLookAt, Vector3.Min, Vector3.Max, 0.0f, float.MaxValue, 100);

            virtualTextureLink = new VirtualTextureSceneViewLink(this);

            //Tools
            selectionMovementTools         = new SimObjectMover("SelectionMover", PluginManager.Instance.RendererPlugin, eventManager, sceneViewController);
            selectionMovementTools.Visible = true;
            selectionMovementTools.addMovableObject("Selection", new SelectionMovableObject(selectionController));

            mainForm = new AnomalyMain(this);

            LayoutChain layoutChain = new LayoutChain();

            layoutChain.addLink(new SingleChildChainLink(GUILocationNames.Taskbar, mainForm.LayoutContainer), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.FullscreenPopup), true);
            layoutChain.SuppressLayout = true;
            layoutChain.addLink(new MDIChainLink(GUILocationNames.MDI, mdiLayout), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.ContentAreaPopup), true);
            layoutChain.addLink(new FinalChainLink("SceneViews", mdiLayout.DocumentArea), true);
            layoutChain.SuppressLayout = false;

            guiManager = new GUIManager();
            guiManager.createGUI(mdiLayout, layoutChain, mainWindow);

            layoutChain.layout();

            splashScreen                = new SplashScreen(mainWindow, 100, "Anomaly.GUI.SplashScreen.SplashScreen.layout", "Anomaly.GUI.SplashScreen.SplashScreen.xml");
            splashScreen.Hidden        += splashScreen_Hidden;
            splashScreen.StatusUpdated += splashScreen_StatusUpdated;
            splashScreen.updateStatus(0, "Loading...");

            idleHandler.runTemporaryIdle(finishInitialization());
        }
コード例 #4
0
        public OgreModelEditorController(App app, String defaultModel)
        {
            this.app = app;

            //Create the log.
            logListener = new LogFileListener();
            logListener.openLogFile(OgreModelEditorConfig.DocRoot + "/log.log");
            Log.Default.addLogListener(logListener);

            //Main window
            mainWindow         = new NativeOSWindow("Ogre Model Editor", new IntVector2(-1, -1), new IntSize2(OgreModelEditorConfig.EngineConfig.HorizontalRes, OgreModelEditorConfig.EngineConfig.VerticalRes));
            mainWindow.Closed += mainWindow_Closed;

            //Setup DPI
            ScaleHelper._setScaleFactor(mainWindow.WindowScaling);

            //Initailize plugins
            MyGUIInterface.EventLayerKey = EventLayers.Main;

            GuiFrameworkCamerasInterface.MoveCameraEventLayer   = EventLayers.Cameras;
            GuiFrameworkCamerasInterface.SelectWindowEventLayer = EventLayers.AfterMain;
            GuiFrameworkCamerasInterface.ShortcutEventLayer     = EventLayers.Main;

            GuiFrameworkEditorInterface.ToolsEventLayers = EventLayers.Tools;

            //Setup microcode cache load
            OgreInterface.MicrocodeCachePath        = Path.Combine(OgreModelEditorConfig.DocRoot, "ShaderCache.mcc");
            OgreInterface.AllowMicrocodeCacheLoad   = OgreModelEditorConfig.LastShaderVersion == UnifiedMaterialBuilder.Version;
            OgreModelEditorConfig.LastShaderVersion = UnifiedMaterialBuilder.Version;
            OgreInterface.TrackMemoryLeaks          = true;
            OgreInterface.CompressedTextureSupport  = OgreModelEditorConfig.CompressedTextureSupport;

            RuntimePlatformInfo.addPath(OgreModelEditorConfig.OpenGLESEmulatorPath);

            pluginManager = new PluginManager(OgreModelEditorConfig.ConfigFile, new ServiceCollection());
            pluginManager.OnConfigureDefaultWindow = createWindow;
            pluginManager.addPluginAssembly(typeof(OgreInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(NativePlatformPlugin).Assembly);
            pluginManager.addPluginAssembly(typeof(MyGUIInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkCamerasInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkEditorInterface).Assembly);
            pluginManager.addPluginAssembly(typeof(GuiFrameworkDebuggingInterface).Assembly);
            pluginManager.initializePlugins();
            frameClearManager = new FrameClearManager(OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget, new Color(0.2f, 0.2f, 0.2f));

            lightManager = pluginManager.RendererPlugin.createSceneViewLightManager();

            //Core resources
            MyGUIInterface.Instance.CommonResourceGroup.addResource(this.GetType().AssemblyQualifiedName, "EmbeddedResource", true);
            OgreResourceGroupManager.getInstance().addResourceLocation(GetType().AssemblyQualifiedName, "EmbeddedResource", "DebugShaders", true);
            OgreResourceGroupManager.getInstance().initializeAllResourceGroups();

            //Intialize the platform
            systemTimer = new NativeSystemTimer();

            mainTimer = new NativeUpdateTimer(systemTimer);
            mainTimer.FramerateCap = OgreModelEditorConfig.EngineConfig.MaxFPS;
            idleHandler            = new IdleHandler(mainTimer.OnIdle);

            inputHandler = new NativeInputHandler(mainWindow, false);
            eventManager = new EventManager(inputHandler, Enum.GetValues(typeof(EventLayers)));
            eventUpdate  = new EventUpdateListener(eventManager);
            mainTimer.addUpdateListener(eventUpdate);
            mainTimer.addUpdateListener(updateEventListener);
            pluginManager.setPlatformInfo(mainTimer, eventManager);
            GuiFrameworkInterface.Instance.handleCursors(mainWindow);

            //Layout Chain
            mdiLayout = new MDILayoutManager();

            //Scene views
            sceneViewController      = new SceneViewController(mdiLayout, eventManager, mainTimer, pluginManager.RendererPlugin.PrimaryWindow, MyGUIInterface.Instance.OgrePlatform.RenderManager, null);
            sceneStatsDisplayManager = new SceneStatsDisplayManager(sceneViewController, OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget);
            sceneStatsDisplayManager.StatsVisible = true;
            sceneViewController.createWindow("Camera 1", OgreModelEditorConfig.CameraConfig.MainCameraPosition, OgreModelEditorConfig.CameraConfig.MainCameraLookAt, Vector3.Min, Vector3.Max, 0.0f, float.MaxValue, 100);

            virtualTextureLink = new VirtualTextureSceneViewLink(this);

            materialController = new MaterialController(this);

            //Tools
            objectMover = new SimObjectMover("ModelMover", PluginManager.Instance.RendererPlugin, eventManager, sceneViewController);

            mainForm = new OgreModelEditorMain(this);

            LayoutChain layoutChain = new LayoutChain();

            layoutChain.addLink(new SingleChildChainLink(GUILocationNames.Taskbar, mainForm.LayoutContainer), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.FullscreenPopup), true);
            layoutChain.SuppressLayout = true;
            layoutChain.addLink(new MDIChainLink(GUILocationNames.MDI, mdiLayout), true);
            layoutChain.addLink(new PopupAreaChainLink(GUILocationNames.ContentAreaPopup), true);
            layoutChain.addLink(new FinalChainLink("SceneViews", mdiLayout.DocumentArea), true);
            layoutChain.SuppressLayout = false;

            guiManager = new GUIManager(mdiLayout, mainWindow);
            guiManager.createGUILayout(layoutChain);

            layoutChain.layout();

            splashScreen                = new SplashScreen(mainWindow, 100, "OgreModelEditor.GUI.SplashScreen.SplashScreen.layout", "OgreModelEditor.GUI.SplashScreen.SplashScreen.xml");
            splashScreen.Hidden        += splashScreen_Hidden;
            splashScreen.StatusUpdated += splashScreen_StatusUpdated;
            splashScreen.updateStatus(0, "Loading...");

            idleHandler.runTemporaryIdle(finishInitialization(defaultModel));
        }