public ImageRenderer(MedicalController controller, SceneViewController sceneViewController, IdleHandler idleHandler) { this.controller = controller; this.sceneViewController = sceneViewController; this.idleHandler = idleHandler; TransparencyController.createTransparencyState(TransparencyStateName); OgreResourceGroupManager.getInstance().createResourceGroup(RenderTextureResourceGroup); }
private bool queueBackgroundImageLoad(String source, IntPtr rocketTexture, ref Vector2i size) { try { //On main thread, load image info var streamPtr = OgreResourceGroupManager.getInstance().openResource(source, "Rocket.Common", true); int width, height; ImageUtility.ImageFormat format = ImageUtility.GetImageInfo(streamPtr.Value, out width, out height); size = new Vector2i(width, height); ThreadManager.RunInBackground(() => { //Process the image itself in a background thread Image image = new Image(); try { image.load(streamPtr.Value, format.ToString().ToLowerInvariant()); ThreadManager.invoke(() => { //Commit the texture to ogre and alert libRocket we are done loading, back in the main thread TexturePtr texture = null; try { texture = TextureManager.getInstance().loadImage(source, "Rocket.Common", image); } catch (OgreException) { } finally { RenderInterfaceOgre3D_finishTextureLoad(rocketTexture, texture != null ? texture.HeapSharedPtr : IntPtr.Zero); if (image != null) { image.Dispose(); } if (texture != null) { texture.Dispose(); } RocketInterface.Instance.fireTextureLoaded(); } }); } finally { if (streamPtr != null) { streamPtr.Dispose(); } } }); return(true); } catch (OgreException ex) { return(false); } }
public void link(PluginManager pluginManager) { //Temp, load resources from fs //C:\Development\openvrtest\Install\media\textures VirtualFileSystem.Instance.addArchive("C:/Development/openvrtest/Install/media"); OgreResourceGroupManager.getInstance().addResourceLocation("ShadersDX11/GuiResource_Gui", "EngineArchive", "Vr", false); OgreResourceGroupManager.getInstance().addResourceLocation("ShadersDX11", "EngineArchive", "Vr", false); OgreResourceGroupManager.getInstance().addResourceLocation("textures", "EngineArchive", "Vr", true); OgreResourceGroupManager.getInstance().initializeAllResourceGroups(); //var ogreRoot = pluginManager.GlobalScope.Resolve<Root>(); //ogreFramework = new OgreFramework(); //ogreFramework.Init(ogreRoot); }
public VirtualTextureManager(int numPhysicalTextures, IntSize2 physicalTextureSize, int texelsPerPage, int largestRealTextureSize, CompressedTextureSupport textureFormat, int stagingBufferCount, IntSize2 feedbackBufferSize, ulong maxCacheSizeBytes, bool texturesArePagedOnDisk) { uploadedIndirectionTextures = new HashSet <byte>(); toUploadList = new List <StagingBufferSet>(stagingBufferCount); this.physicalTextureSize = physicalTextureSize; this.texelsPerPage = texelsPerPage; this.pageSizeLog2 = (float)Math.Log(texelsPerPage, 2.0); if (!OgreResourceGroupManager.getInstance().resourceGroupExists(VirtualTextureManager.ResourceGroup)) { OgreResourceGroupManager.getInstance().createResourceGroup(VirtualTextureManager.ResourceGroup); } //Determine actual runtime texture formats by just creating a simple one quickly. testTexture = TextureManager.getInstance().createManual("TestTexture__VTRESERVED", VirtualTextureManager.ResourceGroup, TextureType.TEX_TYPE_2D, 1, 1, 1, 0, PixelFormat.PF_A8R8G8B8, TextureUsage.TU_STATIC, null, false, 0); IndirectionTexture.BufferFormat = testTexture.Value.Format; switch (textureFormat) { case CompressedTextureSupport.DXT_BC4_BC5: case CompressedTextureSupport.DXT: padding = 4; break; default: padding = 1; break; } this.textureFormat = textureFormat; opaqueFeedbackBuffer = new FeedbackBuffer(this, feedbackBufferSize, 0, 0x1); transparentFeedbackBuffer = new FeedbackBuffer(this, feedbackBufferSize, 1, 0x2); int highestMip = 0; for (highestMip = 0; largestRealTextureSize >> highestMip >= texelsPerPage; ++highestMip) { } textureLoader = new TextureLoader(this, physicalTextureSize, texelsPerPage, padding, stagingBufferCount, numPhysicalTextures, highestMip, maxCacheSizeBytes, texturesArePagedOnDisk); sharedFeedbackParameters = GpuProgramManager.Instance.createSharedParameters("__VirtualTexturingFeedbackSharedParams"); sharedFeedbackParameters.Value.addNamedConstant("mipSampleBias", GpuConstantType.GCT_FLOAT1); PerformanceMonitor.addValueProvider("NumTexturePageUploads", () => lastNumTexturesUploaded.ToString()); }
/// <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)); }