Example #1
0
        public void Shutdown()
        {
            WorldSettings.Shutdown();
            WorldSettings = null;
            Camera        = null;

            foreach (IRenderer RenderAsset in Assets.Values)
            {
                RenderAsset.Shutdown();
            }

            foreach (SpatialGrid grid in navigationGrids)
            {
                grid?.Shutdown();
            }

            navigationGrids = null;
            translokatorGrid?.Shutdown();
            translokatorGrid = null;
            selectionBox.Shutdown();
            selectionBox = null;
            TranslationGizmo.Shutdown();
            TranslationGizmo = null;
            clouds.Shutdown();
            clouds = null;
            sky.Shutdown();
            sky    = null;
            Assets = null;
            D3D?.Shutdown();
            D3D = null;
        }
        public bool PreInit(IntPtr WindowHandle)
        {
            D3D = new DirectX11Class();
            if (!D3D.Init(WindowHandle))
            {
                MessageBox.Show("Failed to initialize DirectX11!");
                return(false);
            }

            Timer = new TimerClass();
            FPS   = new FPSClass();

            Timer.Init();
            FPS.Init();

            RenderStorageSingleton.Instance.Prefabs = new RenderPrefabs();
            if (!RenderStorageSingleton.Instance.ShaderManager.Init(D3D.Device))
            {
                MessageBox.Show("Failed to initialize Shader Manager!");
                return(false);
            }
            //this is backup!
            RenderStorageSingleton.Instance.TextureCache.Add(0, TextureLoader.LoadTexture(D3D.Device, D3D.DeviceContext, "texture.dds"));

            var structure = new M2TStructure();
            //import gizmo
            RenderModel model = new RenderModel();

            structure.ReadFromM2T("Resources/GizmoModel.m2t");
            model.ConvertMTKToRenderModel(structure);
            model.InitBuffers(D3D.Device, D3D.DeviceContext);
            model.DoRender = false;

            RenderModel sky = new RenderModel();

            structure = new M2TStructure();
            structure.ReadFromM2T("Resources/sky_backdrop.m2t");
            sky.ConvertMTKToRenderModel(structure);
            sky.InitBuffers(D3D.Device, D3D.DeviceContext);
            sky.DoRender = false;
            Assets.Add(1, sky);

            RenderModel clouds = new RenderModel();

            structure = new M2TStructure();
            structure.ReadFromM2T("Resources/weather_clouds.m2t");
            clouds.ConvertMTKToRenderModel(structure);
            clouds.InitBuffers(D3D.Device, D3D.DeviceContext);
            clouds.DoRender = false;
            Assets.Add(2, clouds);
            return(true);
        }
        public void Shutdown()
        {
            Camera = null;
            Timer  = null;
            Light  = null;

            foreach (KeyValuePair <int, IRenderer> model in Assets)
            {
                model.Value?.Shutdown();
            }

            Assets = null;
            D3D?.Shutdown();
            D3D = null;
        }
Example #4
0
        public bool Initialise(DirectX11Class D3D)
        {
            if (!ShaderManager.Init(D3D.Device))
            {
                MessageBox.Show("Failed to initialize Shader Manager!");
                return(false);
            }

            // Precache textures and thumbnails which will be reused pretty often.
            Instance.TextureCache.Add(0, TextureLoader.LoadTexture(D3D.Device, D3D.DeviceContext, "texture.dds"));
            Instance.TextureCache.Add(1, TextureLoader.LoadTexture(D3D.Device, D3D.DeviceContext, "default_n.dds"));

            Instance.TextureThumbnails.Add(0, TextureLoader.LoadThumbnail("Resources/Texture.dds"));
            Instance.TextureThumbnails.Add(1, TextureLoader.LoadThumbnail("Resource/MissingMaterial.dds"));

            isInit = true;
            return(true);
        }
Example #5
0
        public bool PreInit(IntPtr WindowHandle)
        {
            D3D = new DirectX11Class();
            if (!D3D.Init(WindowHandle))
            {
                MessageBox.Show("Failed to initialize DirectX11!");
            }
            Profile.Init();
            if (!RenderStorageSingleton.Instance.IsInitialised())
            {
                bool result    = RenderStorageSingleton.Instance.Initialise(D3D);
                var  structure = new M2TStructure();
                //import gizmo
                RenderModel gizmo = new RenderModel();
                structure.ReadFromM2T("Resources/GizmoModel.m2t");
                gizmo.ConvertMTKToRenderModel(structure);
                gizmo.InitBuffers(D3D.Device, D3D.DeviceContext);
                gizmo.DoRender   = true;
                TranslationGizmo = new GizmoTool(gizmo);

                sky       = new RenderModel();
                structure = new M2TStructure();
                structure.ReadFromM2T("Resources/sky_backdrop.m2t");
                sky.ConvertMTKToRenderModel(structure);
                sky.InitBuffers(D3D.Device, D3D.DeviceContext);

                clouds    = new RenderModel();
                structure = new M2TStructure();
                structure.ReadFromM2T("Resources/weather_clouds.m2t");
                clouds.ConvertMTKToRenderModel(structure);
                clouds.InitBuffers(D3D.Device, D3D.DeviceContext);
                clouds.DoRender = false;
            }

            selectionBox.SetColour(System.Drawing.Color.Red);
            selectionBox.Init(new BoundingBox(new Vector3(0.5f), new Vector3(-0.5f)));
            selectionBox.DoRender = false;
            return(true);
        }