예제 #1
0
        static void OnMouseMove(GlfwWindowPtr window, double posx, double posy)
        {
            if (Settings.Window.IsFocused)
            {
                double CenterX = Settings.Window.X + Settings.Window.Width / 2;
                double CenterY = Settings.Window.Y + Settings.Window.Height / 2;

                MainCamera.AddRotation((float)(CenterX - posx), (float)(CenterY - posy));
                Glfw.SetCursorPos(window, CenterX, CenterY);
            }
        }
예제 #2
0
        static void OnUpdateFrame()
        {
            // Проверяем нажатия клавиш каждый кадр, а не по прерыванию!
            KeybrdState = KeyboardState.GetState(Window);

            float camMoveSens = 5.0f * FPS.Period;
            float camRotateSens = 200.0f * FPS.Period;
            float MoveX = 0.0f, MoveY = 0.0f, MoveZ = 0.0f,
                  RotateX = 0.0f, RotateY = 0.0f;

            if (KeybrdState[Key.W])
            {
                MoveY += camMoveSens;
            }
            if (KeybrdState[Key.A])
            {
                MoveX -= camMoveSens;
            }
            if (KeybrdState[Key.S])
            {
                MoveY -= camMoveSens;
            }
            if (KeybrdState[Key.D])
            {
                MoveX += camMoveSens;
            }
            if (KeybrdState[Key.E])
            {
                MoveZ += camMoveSens;
            }
            if (KeybrdState[Key.Q])
            {
                MoveZ -= camMoveSens;
            }

            if (MoveX != 0 || MoveY != 0 || MoveZ != 0)
            {
                MainCamera.Move(MoveX, MoveY, MoveZ);
            }

            if (KeybrdState[Key.Left])
            {
                RotateX += camRotateSens;
            }
            if (KeybrdState[Key.Right])
            {
                RotateX -= camRotateSens;
            }
            if (KeybrdState[Key.Up])
            {
                RotateY += camRotateSens;
            }
            if (KeybrdState[Key.Down])
            {
                RotateY -= camRotateSens;
            }

            if (RotateX != 0 || RotateY != 0)
            {
                MainCamera.AddRotation(RotateX, RotateY);
            }

            SkyBox.Position = MainCamera.Position;
        }