Exemplo n.º 1
0
        public override void Init()
        {
            Content.ContentPath = "Data";

            SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);


            RootScene = new Graphics.Interface.InterfaceScene(this);

            RootScene.Add(windowsCursor);
            RootScene.Add(rawInputCursor);
            RootScene.Add(new Graphics.Interface.TextBox
            {
                Position   = new Vector2(10, 10),
                Text       = "Windows",
                Size       = new Vector2(100, 20),
                Background = null,
                TextAnchor = Orientation.Right
            });
            RootScene.Add(windowsKeyboard);
            RootScene.Add(new Graphics.Interface.TextBox
            {
                Position   = new Vector2(10, 30),
                Text       = "Raw",
                Size       = new Vector2(100, 20),
                Background = null,
                TextAnchor = Orientation.Right
            });
            RootScene.Add(rawInputKeyboard);
            RootScene.Add(rawInputKeyboardTextbox);
            RootScene.Add(windowsKeyboardTextbox);

            InterfaceRenderer = new Graphics.Interface.InterfaceRenderer9(Device9)
            {
                Scene        = (Graphics.Interface.InterfaceScene)RootScene,
                StateManager = new Device9StateManager(Device9)
            };
            InterfaceRenderer.Initialize(this);

            rawInputDevice = new Graphics.RawInput();
            rawInputDevice.RegisterKeyboard(Application.MainWindow.Handle, false);
            rawInputDevice.RegisterMouse(Application.MainWindow.Handle);
            rawInputDevice.KeyDown      += new System.Windows.Forms.KeyEventHandler(rawInputDevice_KeyDown);
            rawInputDevice.KeyUp        += new System.Windows.Forms.KeyEventHandler(rawInputDevice_KeyUp);
            rawInputDevice.MouseMove    += new System.Windows.Forms.MouseEventHandler(rawInputDevice_MouseMove);
            rawInputDevice.MousePosition = LocalMousePosition;
            stopwatch.Start();
        }
        void Setup()
        {
            Scene = new Scene();
            GameState = GameState.Playing;
            InterfaceIngameScene = new Scene();
            Scene.View = InterfaceIngameScene.View = Program.Instance;
            Scene.Camera = InterfaceIngameScene.Camera = new LookatSphericalCamera()
            {
                Lookat = new Vector3(0, 0, 0),
                Position = new Vector3(10, 10, 10),
                FOV = Program.Settings.CameraFOV,
                ZFar = 20,
                ZNear = Program.Settings.CameraZNear,
                AspectRatio = Program.Instance.AspectRatio
            };
            CameraController = new CameraController { Camera = (LookatSphericalCamera)Scene.Camera };
            Scene.EntityAdded += scene_EntityAdded;

            Program.Instance.Interface.Layer1.AddChild(
                SceneControl = new GameSceneControl
                {
                    InnerScene = Scene,
                    Size = Program.Instance.Interface.Size
                });

            InterfaceIngameRenderer = new Graphics.Interface.InterfaceRenderer9(Program.Instance.Device9)
            {
                Scene = InterfaceIngameScene,
                StateManager = Program.Instance.StateManager,
            };
            InterfaceIngameRenderer.Initialize(Scene.View);

            if (Program.Settings.OutputPNGSequence)
                Directory.CreateDirectory(OutputPNGSequencePath);

            if (Program.Settings.UseDummyRenderer)
            {
                throw new NotSupportedException("Dummy renderer is no longer supported.");
            }
            else
            {
                Renderer = new Graphics.Renderer.Renderer(Program.Instance.Device9)
                {
                    Scene = Scene,
                    StateManager = Program.Instance.StateManager,
                    Settings = Program.Settings.RendererSettings,
                };
                SceneRendererConnector = new SortedTestSceneRendererConnector
                {
                    Scene = Scene,
                    Renderer = Renderer
                };
            }

            Graphics.Renderer.Results result = Renderer.Initialize(Scene.View);
            SceneRendererConnector.Initialize();
            if (result == Graphics.Renderer.Results.OutOfVideoMemory)
            {
                System.Windows.Forms.MessageBox.Show(Locale.Resource.ErrorOutOfVideoMemory);
                Application.Log("User ran out of video memory according to renderer. This is probably due to having too high shadow quality.");
                System.Windows.Forms.Application.Exit();
            }

            RendererSettingsController = new RendererSettingsController();

            var s = Program.Settings.GraphicsDeviceSettings.Resolution;
            Program.Instance.Interface.Layer1.AddChild(Interface = new Interface.Interface
            {
                Size = new Vector2(s.Width, s.Height),
                Visible = false
            });
        }
Exemplo n.º 3
0
        void Setup()
        {
            Scene                = new Scene();
            GameState            = GameState.Playing;
            InterfaceIngameScene = new Scene();
            Scene.View           = InterfaceIngameScene.View = Program.Instance;
            Scene.Camera         = InterfaceIngameScene.Camera = new LookatSphericalCamera()
            {
                Lookat      = new Vector3(0, 0, 0),
                Position    = new Vector3(10, 10, 10),
                FOV         = Program.Settings.CameraFOV,
                ZFar        = 20,
                ZNear       = Program.Settings.CameraZNear,
                AspectRatio = Program.Instance.AspectRatio
            };
            CameraController = new CameraController {
                Camera = (LookatSphericalCamera)Scene.Camera
            };
            Scene.EntityAdded += scene_EntityAdded;

            Program.Instance.Interface.Layer1.AddChild(
                SceneControl = new GameSceneControl
            {
                InnerScene = Scene,
                Size       = Program.Instance.Interface.Size
            });

            InterfaceIngameRenderer = new Graphics.Interface.InterfaceRenderer9(Program.Instance.Device9)
            {
                Scene        = InterfaceIngameScene,
                StateManager = Program.Instance.StateManager,
            };
            InterfaceIngameRenderer.Initialize(Scene.View);

            if (Program.Settings.OutputPNGSequence)
            {
                Directory.CreateDirectory(OutputPNGSequencePath);
            }

            if (Program.Settings.UseDummyRenderer)
            {
                throw new NotSupportedException("Dummy renderer is no longer supported.");
            }
            else
            {
                Renderer = new Graphics.Renderer.Renderer(Program.Instance.Device9)
                {
                    Scene        = Scene,
                    StateManager = Program.Instance.StateManager,
                    Settings     = Program.Settings.RendererSettings,
                };
                SceneRendererConnector = new SortedTestSceneRendererConnector
                {
                    Scene    = Scene,
                    Renderer = Renderer
                };
            }

            Graphics.Renderer.Results result = Renderer.Initialize(Scene.View);
            SceneRendererConnector.Initialize();
            if (result == Graphics.Renderer.Results.OutOfVideoMemory)
            {
                System.Windows.Forms.MessageBox.Show(Locale.Resource.ErrorOutOfVideoMemory);
                Application.Log("User ran out of video memory according to renderer. This is probably due to having too high shadow quality.");
                System.Windows.Forms.Application.Exit();
            }

            RendererSettingsController = new RendererSettingsController();

            var s = Program.Settings.GraphicsDeviceSettings.Resolution;

            Program.Instance.Interface.Layer1.AddChild(Interface = new Interface.Interface
            {
                Size    = new Vector2(s.Width, s.Height),
                Visible = false
            });
        }