Ejemplo n.º 1
0
        public void OnKeyDown(object sender, KeyboardKeyEventArgs args)
        {
            switch (args.Key)
            {
            case Key.H:
                cameraHelp = (cameraHelp) ? false : true;
                break;

            case Key.Tab:

                if (camera == globalCamera)
                {
                    camera = robotCamera;
                    robotCamera.Attach(someRobot);
                }
                else if (camera == robotCamera)
                {
                    camera = lightCamera1;
                }
                else if (camera == lightCamera1)
                {
                    camera = lightCamera2;
                }
                else if (camera == lightCamera2)
                {
                    camera = lightCamera3;
                }
                else if (camera == lightCamera3)
                {
                    camera = lightCamera4;
                }
                else if (camera == lightCamera4)
                {
                    camera = rmcUnitCamera;
                }
                else if (camera == rmcUnitCamera)
                {
                    camera = globalCamera;
                }
                break;

            case Key.F:
                if (Keyboard[Key.ControlLeft])
                {
                    /* toggle fullscreen */

                    if (this.WindowState == WindowState.Fullscreen)
                    {
                        this.WindowState = WindowState.Normal;
                    }
                    else
                    {
                        this.WindowState = WindowState.Fullscreen;
                    }
                }
                else
                {
                    /* toggle light */
                    camera.PerformActions(Camera.Action.TOGGLE_LIGHT);
                }
                break;

            case Key.Number5:
                if (ambientLights)
                {
                    ambientLights = false;
                    setGlobalAmbientLight(0.0f, 0.0f, 0.0f, 1.0f);
                }
                else
                {
                    ambientLights = true;
                    setGlobalAmbientLight(0.2f, 0.2f, 0.2f, 1.0f);
                }
                break;

            case Key.Number6:
                if (bottomLeftCornerLight)
                {
                    bottomLeftCornerLight = true;
                    GL.Disable(EnableCap.Light0);
                }
                else
                {
                    bottomLeftCornerLight = true;
                    GL.Enable(EnableCap.Light0);
                }
                break;

            case Key.Number7:
                if (bottomRightCornerLight)
                {
                    bottomRightCornerLight = true;
                    GL.Disable(EnableCap.Light1);
                }
                else
                {
                    bottomRightCornerLight = true;
                    GL.Enable(EnableCap.Light1);
                }
                break;

            case Key.Number8:
                if (topRightCornerLight)
                {
                    topRightCornerLight = true;
                    GL.Disable(EnableCap.Light2);
                }
                else
                {
                    topRightCornerLight = true;
                    GL.Enable(EnableCap.Light2);
                }
                break;

            case Key.Number9:
                if (topLeftCornerLight)
                {
                    topLeftCornerLight = true;
                    GL.Disable(EnableCap.Light3);
                }
                else
                {
                    topLeftCornerLight = true;
                    GL.Enable(EnableCap.Light3);
                }
                break;

            case Key.Number0:
                if (allPostLights)
                {
                    allPostLights = false;
                    GL.Disable(EnableCap.Light3);
                    GL.Disable(EnableCap.Light2);
                    GL.Disable(EnableCap.Light1);
                    GL.Disable(EnableCap.Light0);
                }
                else
                {
                    allPostLights = true;
                    GL.Enable(EnableCap.Light3);
                    GL.Enable(EnableCap.Light2);
                    GL.Enable(EnableCap.Light1);
                    GL.Enable(EnableCap.Light0);
                }
                break;

            case Key.J:
                camera.PerformActions(Camera.Action.TILT_LEFT | Camera.Action.ACTIVE);
                break;

            case Key.L:
                camera.PerformActions(Camera.Action.TILT_RIGHT | Camera.Action.ACTIVE);
                break;

            case Key.I:
                camera.PerformActions(Camera.Action.TILT_UP | Camera.Action.ACTIVE);
                break;

            case Key.K:
                camera.PerformActions(Camera.Action.TILT_DOWN | Camera.Action.ACTIVE);
                break;

            case Key.B:
                SkyBoxSphere.ChangeEnvironment();
                break;

            case Key.Minus:
                if (fovyscale > 2)
                {
                    fovyscale--;                             // Zoom out.

                    Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / fovyscale, Width / (float)Height, 1.0f, /*64.0f*/ 120.0f);
                    GL.MatrixMode(MatrixMode.Projection);
                    GL.LoadMatrix(ref projection);
                }
                break;

            case Key.Plus:
                if (fovyscale < 10)
                {
                    fovyscale++;                             // Zoom in.

                    Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / fovyscale, Width / (float)Height, 1.0f, /*64.0f*/ 120.0f);
                    GL.MatrixMode(MatrixMode.Projection);
                    GL.LoadMatrix(ref projection);
                }
                break;
            }
        }