示例#1
0
        public static void Update(GameTime gameTime, IEditorCamera camera)
        {
            mouseLastState    = mouseState;
            keyboardLastState = keyboardState;
            mouseState        = Mouse.GetState();
            keyboardState     = Keyboard.GetState();

            KeyboardEvents(gameTime, camera);
            MouseEvents(camera);
        }
示例#2
0
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     _imGuiRenderer = new ImGuiRenderer(this);
     _imGuiRenderer.RebuildFontAtlas();
     SetupDarkStyle();
     Camera        = new PerspectiveCamera(new Vector3(-10, 5, -15), Vector3.Zero);
     _renderer     = new Renderer.Renderer(Camera);
     CurrentFolder = AppContext.BaseDirectory;
     base.Initialize();
 }
示例#3
0
        private static void KeyboardEvents(GameTime gameTime, IEditorCamera perspectiveCamera)
        {
            //if (DebugScreen.ConsoleOpen) return;

            float delta = (float)gameTime.ElapsedGameTime.TotalMilliseconds * 60 / 1000;

            Vector3 direction = perspectiveCamera.Forward;

            direction.Normalize();

            Vector3 normal = Vector3.Cross(direction, perspectiveCamera.Up);

            float amount = 0.8f * delta;

            float amountNormal = 0.2f * delta;

            if (keyboardState.IsKeyDown(Keys.W))
            {
                perspectiveCamera.Transform.Position += direction * amount;
            }

            if (keyboardState.IsKeyDown(Keys.S))
            {
                perspectiveCamera.Transform.Position -= direction * amount;
            }

            if (keyboardState.IsKeyDown(Keys.D))
            {
                perspectiveCamera.Transform.Position += normal * amountNormal;
            }

            if (keyboardState.IsKeyDown(Keys.A))
            {
                perspectiveCamera.Transform.Position -= normal * amountNormal;
            }
        }
示例#4
0
        private static void MouseEvents(IEditorCamera perspectiveCamera)
        {
            float mouseAmount = 0.01f;

            Vector3 direction = perspectiveCamera.Forward;

            direction.Normalize();

            Vector3 normal = Vector3.Cross(direction, perspectiveCamera.Up);

            if (mouseState.RightButton == ButtonState.Pressed)
            {
                float y = mouseState.Y - mouseLastState.Y;
                float x = mouseState.X - mouseLastState.X;

                y *= GameSettings.g_screenheight / 800.0f;
                x *= GameSettings.g_screenwidth / 1280.0f;

                perspectiveCamera.Forward += x * mouseAmount * normal;

                perspectiveCamera.Forward -= y * mouseAmount * perspectiveCamera.Up;
                perspectiveCamera.Forward.Normalize();
            }
        }
示例#5
0
 public Renderer(IEditorCamera perspectiveCamera)
 {
     _perspectiveCamera = perspectiveCamera;
 }