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);
        }
Beispiel #2
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);
        }