/// <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()); }
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)); }
private IEnumerable <IdleStatus> finishInitialization() { splashScreen.updateStatus(10, "Loading Solution"); yield return(IdleStatus.Ok); //Load the config file and set the resource root up. VirtualFileSystem.Instance.addArchive(solution.ResourceRoot); resourceController = new ResourceController(this); solution.loadExternalFiles(this); MyGUIPlugin.ResourceManager.Instance.load("Anomaly.Resources.AnomalyImagesets.xml"); //Initialize controllers instanceBuilder = new InstanceBuilder(); sceneController.initialize(this); sceneController.OnSceneLoaded += sceneController_OnSceneLoaded; sceneController.OnSceneUnloading += sceneController_OnSceneUnloading; simObjectController = new SimObjectController(this); fixedUpdate = new FullSpeedUpdateListener(sceneController); mainTimer.addUpdateListener(fixedUpdate); splashScreen.updateStatus(60, "Creating GUI"); yield return(IdleStatus.Ok); propertiesEditor = new PropertiesEditor("Properties", "Anomaly.GUI.Properties", false); guiManager.addManagedDialog(propertiesEditor); interfaceRenderer = new EditInterfaceRendererController(pluginManager.RendererPlugin, mainTimer, sceneController, propertiesEditor); solutionWindow = new SolutionWindow(); guiManager.addManagedDialog(solutionWindow); mainObjectEditor = new PropertiesEditor("Object Editor", "Anomaly.GUI.ObjectEditor", true); mainObjectEditor.AllowedDockLocations = DockLocation.Floating; mainObjectEditor.CurrentDockLocation = DockLocation.Floating; guiManager.addManagedDialog(mainObjectEditor); solutionController = new SolutionController(solution, solutionWindow, this, propertiesEditor); //Initialize the windows propertiesEditor.AutoExpand = true; //Create GUI consoleWindow = new LogWindow(); guiManager.addManagedDialog(consoleWindow); Log.Default.addLogListener(consoleWindow); debugVisualizer = new DebugVisualizer(pluginManager, sceneController); guiManager.addManagedDialog(debugVisualizer); if (File.Exists(AnomalyConfig.WindowsFile)) { ConfigFile configFile = new ConfigFile(AnomalyConfig.WindowsFile); configFile.loadConfigFile(); guiManager.loadSavedUI(configFile, new Version("1.0.0.0")); //Show Windows Default solutionWindow.Visible = true; propertiesEditor.Visible = true; consoleWindow.Visible = true; debugVisualizer.Visible = true; } else { //Show Windows Default solutionWindow.Visible = true; propertiesEditor.showRelativeTo(solutionWindow, WindowAlignment.Right); consoleWindow.Visible = true; debugVisualizer.Visible = true; } yield return(IdleStatus.Ok); splashScreen.updateStatus(80, "Building Scene"); buildScene(); yield return(IdleStatus.Ok); splashScreen.updateStatus(100, "Loaded"); splashScreen.hide(); yield return(IdleStatus.Ok); if (FullyLoaded != null) { FullyLoaded.Invoke(this); } }
public MedicalController(NativeOSWindow mainWindow) { //Create the log. logListener = new LogFileListener(); logListener.openLogFile(MedicalConfig.LogFile); Log.Default.addLogListener(logListener); Log.ImportantInfo("Running from directory {0}", FolderFinder.ExecutableFolder); //Create pluginmanager pluginManager = new PluginManager(MedicalConfig.ConfigFile, services); //Configure the filesystem VirtualFileSystem archive = VirtualFileSystem.Instance; //Setup microcode cache load OgreInterface.MicrocodeCachePath = Path.Combine(FolderFinder.LocalPrivateDataFolder, "ShaderCache.mcc"); OgreInterface.AllowMicrocodeCacheLoad = MedicalConfig.LastShaderVersion == UnifiedMaterialBuilder.Version; OgreInterface.TrackMemoryLeaks = MedicalConfig.TrackMemoryLeaks; MedicalConfig.LastShaderVersion = UnifiedMaterialBuilder.Version; MyGUIInterface.EventLayerKey = EventLayers.Gui; MyGUIInterface.CreateGuiGestures = MedicalConfig.EnableMultitouch && PlatformConfig.TouchType == TouchType.Screen; MyGUIInterface.TrackMemoryLeaks = MedicalConfig.TrackMemoryLeaks; RuntimePlatformInfo.addPath(MedicalConfig.OpenGLESEmulatorPath); //Configure plugins pluginManager.OnConfigureDefaultWindow = delegate(out WindowInfo defaultWindow) { //Setup main window defaultWindow = new WindowInfo(mainWindow, "Primary"); defaultWindow.Fullscreen = MedicalConfig.EngineConfig.Fullscreen; defaultWindow.MonitorIndex = 0; if (MedicalConfig.EngineConfig.Fullscreen) { mainWindow.setSize(MedicalConfig.EngineConfig.HorizontalRes, MedicalConfig.EngineConfig.VerticalRes); mainWindow.ExclusiveFullscreen = true; defaultWindow.Width = MedicalConfig.EngineConfig.HorizontalRes; defaultWindow.Height = MedicalConfig.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.Gui; GuiFrameworkCamerasInterface.TouchType = PlatformConfig.TouchType; GuiFrameworkCamerasInterface.PanKey = PlatformConfig.PanKey; GuiFrameworkEditorInterface.ToolsEventLayers = EventLayers.Tools; 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(BEPUikInterface).Assembly); pluginManager.addPluginAssembly(typeof(SimulationPlugin).Assembly); pluginManager.addPluginAssembly(typeof(GuiFrameworkInterface).Assembly); pluginManager.addPluginAssembly(typeof(RocketWidgetInterface).Assembly); pluginManager.addPluginAssembly(typeof(GuiFrameworkCamerasInterface).Assembly); pluginManager.addPluginAssembly(typeof(GuiFrameworkEditorInterface).Assembly); pluginManager.addPluginAssembly(typeof(GuiFrameworkDebuggingInterface).Assembly); pluginManager.initializePlugins(); performanceMetricTimer = new NativeSystemTimer(); PerformanceMonitor.setupEnabledState(performanceMetricTimer); //Intialize the platform BulletInterface.Instance.ShapeMargin = 0.005f; systemTimer = new NativeSystemTimer(); mainTimer = new NativeUpdateTimer(systemTimer); if (OgreConfig.VSync && MedicalConfig.EngineConfig.FPSCap < 300) { //Use a really high 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 = 300; } else { mainTimer.FramerateCap = MedicalConfig.EngineConfig.FPSCap; } inputHandler = new NativeInputHandler(mainWindow, MedicalConfig.EnableMultitouch); eventManager = new EventManager(inputHandler, Enum.GetValues(typeof(EventLayers))); eventUpdate = new EventUpdateListener(eventManager); mainTimer.addUpdateListener(eventUpdate); pluginManager.setPlatformInfo(mainTimer, eventManager); medicalUpdate = new MedicalUpdate(this); mainTimer.addUpdateListener(medicalUpdate); //Initialize controllers medicalScene = new MedicalSceneController(pluginManager); frameClearManager = new FrameClearManager(OgreInterface.Instance.OgrePrimaryWindow.OgreRenderTarget); SoundConfig.initialize(MedicalConfig.ConfigFile); GuiFrameworkInterface.Instance.handleCursors(mainWindow); SoundPluginInterface.Instance.setResourceWindow(mainWindow); TouchMouseGuiForwarder = new TouchMouseGuiForwarder(eventManager, inputHandler, systemTimer, mainWindow, EventLayers.Last); TouchMouseGuiForwarder.ForwardTouchesAsMouse = PlatformConfig.ForwardTouchAsMouse; var myGuiKeyboard = new MyGUIOnscreenKeyboardManager(TouchMouseGuiForwarder); var rocketKeyboard = new RocketWidgetOnscreenKeyboardManager(TouchMouseGuiForwarder); }