Пример #1
0
        public void Initialized(CoreApp pharosApp, PluginManager pluginManager)
        {
            var scope = pluginManager.GlobalScope;

            //Build gui
            sceneViewController = scope.ServiceProvider.GetRequiredService <SceneViewController>();
            var sceneStatsDisplayManager = scope.ServiceProvider.GetRequiredService <SceneStatsDisplayManager>();

            sceneStatsDisplayManager.StatsVisible = true;
            sceneViewController.createWindow("Camera 1", Vector3.UnitX * 100, Vector3.Zero, Vector3.Min, Vector3.Max, 0.0f, float.MaxValue, 100);

            var testWindow = scope.ServiceProvider.GetRequiredService <TestWindow>();

            testWindow.Visible = true;

            var rocketWindow = scope.ServiceProvider.GetRequiredService <RocketWindow>();

            rocketWindow.Visible = true;
        }
Пример #2
0
        public void Initialized(GameApp app, PluginManager pluginManager)
        {
            Logging.Log.Info($"Loading archive {app.PrimaryArchivePath}");
            VirtualFileSystem.Instance.addArchive(app.PrimaryArchivePath);

            var scope = pluginManager.GlobalScope;

            scope.ServiceProvider.GetRequiredService <VirtualTextureSceneViewLink>();

            var guiManager  = scope.ServiceProvider.GetRequiredService <GUIManager>();
            var layoutChain = scope.ServiceProvider.GetRequiredService <LayoutChain>();

            guiManager.createGUILayout(layoutChain);
            layoutChain.layout();

            //Build gui
            sceneViewController = scope.ServiceProvider.GetRequiredService <SceneViewController>();
            var sceneStatsDisplayManager = scope.ServiceProvider.GetRequiredService <SceneStatsDisplayManager>();

            sceneStatsDisplayManager.StatsVisible = true;
            sceneViewController.createWindow("Camera 1", Vector3.UnitX * 100, Vector3.Zero, Vector3.Min, Vector3.Max, 0.0f, float.MaxValue, 100);

            lightManager = scope.ServiceProvider.GetRequiredService <SceneViewLightManager>();

            var sceneController = scope.ServiceProvider.GetRequiredService <SceneController>();

            sceneController.OnSceneLoaded    += SceneController_OnSceneLoaded;
            sceneController.OnSceneUnloading += SceneController_OnSceneUnloading;
            var scene = "Scenes\\TestLevel.sim.xml";

            if (VirtualFileSystem.Instance.fileExists(scene))
            {
                Logging.Log.Info($"Loading scene {scene}");
                sceneController.loadSceneDefinition("Scenes\\TestLevel.sim.xml");
            }
            else
            {
                Logging.Log.Info($"Cannot load scene {scene}");
            }
        }
Пример #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 void createOneWindow()
 {
     sceneViewController.closeAllWindows();
     sceneViewController.createWindow("Camera 1", Vector3.Backward * DefaultOrbitDistance, Vector3.Zero, Vector3.Min, Vector3.Max, 0.0f, float.MaxValue, 100);
 }
        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));
        }
        public static void createFromPresets(this SceneViewController controller, SceneViewWindowPresetSet presets, bool keepOldSettings = true)
        {
            //Capture current window configuration info
            List <Bookmark> currentWindowConfig = new List <Bookmark>();

            if (keepOldSettings)
            {
                SceneViewWindow activeWindow = controller.ActiveWindow;
                if (activeWindow != null)
                {
                    TransparencyController.ActiveTransparencyState = activeWindow.CurrentTransparencyState;
                    LayerState layerState = new LayerState();
                    layerState.captureState();
                    currentWindowConfig.Add(new Bookmark("", activeWindow.Translation, activeWindow.LookAt, layerState));
                }
                foreach (MDISceneViewWindow window in controller.MdiWindows)
                {
                    if (window != activeWindow)
                    {
                        TransparencyController.ActiveTransparencyState = window.CurrentTransparencyState;
                        LayerState layerState = new LayerState();
                        layerState.captureState();
                        currentWindowConfig.Add(new Bookmark("", window.Translation, window.LookAt, layerState));
                    }
                }
            }

            //Create windows
            int windowIndex = 0;
            int zOrder      = 100;
            int zOrderInc   = 10;

            controller.closeAllWindows();
            MDISceneViewWindow camera;
            MDISceneViewWindow toSelect = null;

            foreach (SceneViewWindowPreset preset in presets.getPresetEnum())
            {
                if (windowIndex < currentWindowConfig.Count)
                {
                    Bookmark bmk = currentWindowConfig[windowIndex++];
                    camera = controller.createWindow(preset.Name, bmk.CameraPosition.Translation, bmk.CameraPosition.LookAt, preset.BoundMin, preset.BoundMax, preset.OrbitMinDistance, preset.OrbitMaxDistance, zOrder, controller.findWindow(preset.ParentWindow), preset.WindowPosition);
                    TransparencyController.ActiveTransparencyState = camera.CurrentTransparencyState;
                    bmk.Layers.instantlyApply();
                }
                else
                {
                    camera = controller.createWindow(preset.Name, preset.Position, preset.LookAt, preset.BoundMin, preset.BoundMax, preset.OrbitMinDistance, preset.OrbitMaxDistance, zOrder, controller.findWindow(preset.ParentWindow), preset.WindowPosition);
                    Bookmark bmk = null;
                    if (BookmarksController != null)
                    {
                        bmk = BookmarksController.loadBookmark(String.Format("Cameras/{0}.bmk", camera.CurrentTransparencyState));

                        if (bmk != null)
                        {
                            camera.setPosition(bmk.CameraPosition, 0.0f);
                            TransparencyController.ActiveTransparencyState = camera.CurrentTransparencyState;
                            bmk.Layers.instantlyApply();
                        }
                    }
                }
                if (toSelect == null)
                {
                    toSelect = camera;
                }
                zOrder += zOrderInc;
            }
            if (toSelect != null)
            {
                controller.setActiveMdiWindow(toSelect);
            }
        }