コード例 #1
0
        public void FrameMove()
        {
            if (keysEnabled[keySave] && keys[keySave])
            {
                keysEnabled[keySave] = false;
                viewer.SaveToPng("sample.png");
            }
            if (keysEnabled[keyMotion] && keys[keyMotion])
            {
                keysEnabled[keyMotion] = false;
                viewer.MotionEnabled   = !viewer.MotionEnabled;
            }
            if (keysEnabled[keyShadow] && keys[keyShadow])
            {
                keysEnabled[keyShadow] = false;
                viewer.ShadowShown     = !viewer.ShadowShown;
            }
            if (keysEnabled[keySprite] && keys[keySprite])
            {
                keysEnabled[keySprite] = false;
                viewer.SpriteShown     = !viewer.SpriteShown;
            }
            if (keysEnabled[keyFigure] && keys[keyFigure])
            {
                keysEnabled[keyFigure] = false;
                viewer.NextFigure();
            }
            if (keysEnabled[keyDelete] && keys[keyDelete])
            {
                keysEnabled[keyDelete] = false;

                if (keys[(int)Keys.ControlKey])
                {
                    viewer.ClearFigureList();
                }
                else
                {
                    viewer.RemoveSelectedFigure();
                }
            }
            if (keysEnabled[keyCameraReset] && keys[keyCameraReset])
            {
                keysEnabled[keyCameraReset] = false;
                viewer.Camera.Reset();
                viewer.Camera.SetTranslation(0.0f, +10.0f, +44.0f);
            }
            if (keysEnabled[keyCenter] && keys[keyCenter])
            {
                keysEnabled[keyCenter] = false;
                viewer.Camera.ResetTranslation();
                Figure fig;
                if (viewer.TryGetFigure(out fig))
                {
                    viewer.Camera.SetCenter(fig.Center + fig.Translation);
                }
            }
            if (keysEnabled[keyFigureForm] && keys[keyFigureForm])
            {
                keys[keyFigureForm]        = false;
                keysEnabled[keyFigureForm] = true;
                // stale KeyUp event
                fig_form.Show();
                fig_form.Activate();
            }

            float keyL    = 0.0f;
            float keyR    = 0.0f;
            float keyU    = 0.0f;
            float keyD    = 0.0f;
            float keyPush = 0.0f;
            float keyPull = 0.0f;
            float keyZRol = 0.0f;

            if (keys[(int)Keys.Left])
            {
                keyL = 2.0f;
            }
            if (keys[(int)Keys.Right])
            {
                keyR = 2.0f;
            }
            if (keys[(int)Keys.PageUp])
            {
                keyU = 2.0f;
            }
            if (keys[(int)Keys.PageDown])
            {
                keyD = 2.0f;
            }
            if (keys[(int)Keys.Up])
            {
                keyPush = 1.0f;
            }
            if (keys[(int)Keys.Down])
            {
                keyPull = 1.0f;
            }
            if (keys[(int)Keys.A])
            {
                keyZRol = -2.0f;
            }
            if (keys[(int)Keys.D])
            {
                keyZRol = +2.0f;
            }

            if (Control.ModifierKeys == Keys.Shift)
            {
                Figure fig;
                if (viewer.TryGetFigure(out fig))
                {
                    fig.Move(keyR - keyL, keyU - keyD, keyPull - keyPush);
                }
            }
            else
            {
                viewer.Camera.Move(keyR - keyL, keyU - keyD, keyPull - keyPush);
                viewer.Camera.RotZ(DegreeToRadian(keyZRol));
            }
        }
コード例 #2
0
        public void FrameMove()
        {
            if (keysEnabled[keySave] && keys[keySave])
            {
                keysEnabled[keySave] = false;
                if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                {
                    record.Start();
                }
                else
                {
                    SaveToPng();
                }
            }
            if (keysEnabled[keyMotion] && keys[keyMotion])
            {
                keysEnabled[keyMotion] = false;
                viewer.MotionEnabled   = !viewer.MotionEnabled;
            }
            if (keysEnabled[keyProjection] && keys[keyProjection])
            {
                keysEnabled[keyProjection] = false;
                SwitchProjectionMode();
            }
            if (keysEnabled[keyAmbient] && keys[keyAmbient])
            {
                keysEnabled[keyAmbient] = false;
                SwitchRenderMode(RenderMode.Ambient);
            }
            if (keysEnabled[keyDepthMap] && keys[keyDepthMap])
            {
                keysEnabled[keyDepthMap] = false;
                SwitchRenderMode(RenderMode.DepthMap);
            }
            if (keysEnabled[keyNormalMap] && keys[keyNormalMap])
            {
                keysEnabled[keyNormalMap] = false;
                SwitchRenderMode(RenderMode.NormalMap);
            }
            if (keysEnabled[keyOcclusion] && keys[keyOcclusion])
            {
                keysEnabled[keyOcclusion] = false;
                SwitchRenderMode(RenderMode.Occlusion);
            }
            if (keysEnabled[keyDiffusion] && keys[keyDiffusion])
            {
                keysEnabled[keyDiffusion] = false;
                SwitchRenderMode(RenderMode.Diffusion);
            }
            if (keysEnabled[keyShadow] && keys[keyShadow])
            {
                keysEnabled[keyShadow] = false;
                SwitchRenderMode(RenderMode.Shadow);
            }
            if (keysEnabled[keyConfigForm] && keys[keyConfigForm])
            {
                keys[keyConfigForm]        = false;
                keysEnabled[keyConfigForm] = true;
                // stale KeyUp event
                configForm.Show();
                configForm.Activate();
            }
            if (keysEnabled[keyFigure] && keys[keyFigure])
            {
                keysEnabled[keyFigure] = false;
                viewer.NextFigure();
            }
            if (keysEnabled[keyDelete] && keys[keyDelete])
            {
                keysEnabled[keyDelete] = false;

                if (keys[(int)Keys.ControlKey])
                {
                    viewer.ClearFigureList();
                }
                else
                {
                    viewer.RemoveSelectedFigure();
                }
            }
            if (keysEnabled[keyCameraReset] && keys[keyCameraReset])
            {
                keysEnabled[keyCameraReset] = false;
                viewer.Camera.Reset();
                viewer.Camera.SetTranslation(0.0f, +10.0f, +44.0f);
            }
            if (keysEnabled[keyCenter] && keys[keyCenter])
            {
                keysEnabled[keyCenter] = false;
                viewer.Camera.ResetTranslation();
                Figure fig;
                if (viewer.TryGetFigure(out fig))
                {
                    viewer.Camera.SetCenter(fig.Center + fig.Translation);
                }
            }
            if (keysEnabled[keyFigureForm] && keys[keyFigureForm])
            {
                keys[keyFigureForm]        = false;
                keysEnabled[keyFigureForm] = true;
                // stale KeyUp event
                figureForm.Show();
                figureForm.Activate();
            }

            float keyL    = 0.0f;
            float keyR    = 0.0f;
            float keyU    = 0.0f;
            float keyD    = 0.0f;
            float keyPush = 0.0f;
            float keyPull = 0.0f;

            if (keys[(int)Keys.Left])
            {
                keyL = 2.0f;
            }
            if (keys[(int)Keys.Right])
            {
                keyR = 2.0f;
            }
            if (keys[(int)Keys.PageUp])
            {
                keyU = 2.0f;
            }
            if (keys[(int)Keys.PageDown])
            {
                keyD = 2.0f;
            }
            if (keys[(int)Keys.Up])
            {
                keyPush = 1.0f;
            }
            if (keys[(int)Keys.Down])
            {
                keyPull = 1.0f;
            }

            if (Control.ModifierKeys == Keys.Shift)
            {
                Figure fig;
                if (viewer.TryGetFigure(out fig))
                {
                    fig.Move(keyR - keyL, keyU - keyD, keyPull - keyPush);
                }
            }
            else
            {
                viewer.Camera.Move(keyR - keyL, keyU - keyD, keyPull - keyPush);
            }
        }
コード例 #3
0
        void RenderFocused()
        {
            KeyboardState currentKeyboardState = keyboard.GetCurrentState();

            if (!keyboardState.IsPressed(keySave) && currentKeyboardState.IsPressed(keySave))
            {
                viewer.SaveToBitmap("sample.png");
            }

            if (!keyboardState.IsPressed(keyMotion) && currentKeyboardState.IsPressed(keyMotion))
            {
                viewer.MotionEnabled = !viewer.MotionEnabled;
            }
            if (!keyboardState.IsPressed(keyFigure) && currentKeyboardState.IsPressed(keyFigure))
            {
                viewer.figures.NextFigure();
            }
            if (!keyboardState.IsPressed(keyDelete) && currentKeyboardState.IsPressed(keyDelete))
            {
                if (currentKeyboardState.IsPressed(Key.LeftControl) || currentKeyboardState.IsPressed(Key.RightControl))
                {
                    viewer.figures.ClearFigureList();
                }
                else
                {
                    viewer.figures.RemoveSelectedFigure();
                }
            }
            if (!keyboardState.IsPressed(keyCameraReset) && currentKeyboardState.IsPressed(keyCameraReset))
            {
                viewer.Camera.Reset();
                viewer.Camera.SetTranslation(tso_config.Position);
            }
            if (!keyboardState.IsPressed(keyCenter) && currentKeyboardState.IsPressed(keyCenter))
            {
                viewer.Camera.ResetTranslation();
                Figure fig;
                if (viewer.figures.TryGetFigure(out fig))
                {
                    viewer.Camera.SetCenter(fig.Center + fig.Translation);
                }
            }
            if (!keyboardState.IsPressed(keyFigureForm) && currentKeyboardState.IsPressed(keyFigureForm))
            {
                fig_form.Show();
                fig_form.Activate();
            }

            float keyL    = 0.0f;
            float keyR    = 0.0f;
            float keyU    = 0.0f;
            float keyD    = 0.0f;
            float keyPush = 0.0f;
            float keyPull = 0.0f;
            float keyZRol = 0.0f;

            if (currentKeyboardState.IsPressed(Key.Left))
            {
                keyL = 0.01f;
            }
            if (currentKeyboardState.IsPressed(Key.Right))
            {
                keyR = 0.01f;
            }
            if (currentKeyboardState.IsPressed(Key.PageUp))
            {
                keyU = 0.01f;
            }
            if (currentKeyboardState.IsPressed(Key.PageDown))
            {
                keyD = 0.01f;
            }
            if (currentKeyboardState.IsPressed(Key.Up))
            {
                keyPush = 0.5f;
            }
            if (currentKeyboardState.IsPressed(Key.Down))
            {
                keyPull = 0.5f;
            }
            if (currentKeyboardState.IsPressed(Key.A))
            {
                keyZRol = -1.0f;
            }
            if (currentKeyboardState.IsPressed(Key.D))
            {
                keyZRol = +1.0f;
            }

            if (Control.ModifierKeys == Keys.Shift)
            {
                Figure fig;
                if (viewer.figures.TryGetFigure(out fig))
                {
                    fig.Move(keyR - keyL, keyU - keyD, keyPull - keyPush);
                }
            }
            else
            {
                viewer.Camera.RotateYawPitchRoll(keyL - keyR, keyU - keyD, DegreeToRadian(keyZRol));
                viewer.Camera.MoveView(0, 0, keyPull - keyPush);
            }

            keyboardState = currentKeyboardState;
        }
コード例 #4
0
ファイル: TSOForm.cs プロジェクト: xvok16/TDCGExplorer
        public void FrameMove()
        {
            if (keysEnabled[keySave] && keys[keySave])
            {
                keysEnabled[keySave] = false;
                viewer.SaveToBitmap("sample.bmp");
            }
            if (keysEnabled[keyMotion] && keys[keyMotion])
            {
                keysEnabled[keyMotion] = false;
                viewer.SwitchMotionEnabled();
            }
            if (keysEnabled[keyShadow] && keys[keyShadow])
            {
                keysEnabled[keyShadow] = false;
                viewer.SwitchShadowShown();
            }
            if (keysEnabled[keySprite] && keys[keySprite])
            {
                keysEnabled[keySprite] = false;
                viewer.SwitchSpriteShown();
            }
            if (keysEnabled[keyFigure] && keys[keyFigure])
            {
                keysEnabled[keyFigure] = false;
                viewer.NextFigure();
            }
            if (keysEnabled[keyDelete] && keys[keyDelete])
            {
                keysEnabled[keyDelete] = false;

                if (keys[(int)Keys.ControlKey])
                {
                    viewer.ClearFigureList();
                }
                else
                {
                    viewer.RemoveSelectedFigure();
                }
            }
            if (keysEnabled[keyCameraReset] && keys[keyCameraReset])
            {
                keysEnabled[keyCameraReset] = false;
                camera.Reset();
                Figure fig;
                if (viewer.TryGetFigure(out fig))
                {
                    camera.SetCenter(fig.Center);
                }
            }
            if (keysEnabled[keyFigureForm] && keys[keyFigureForm])
            {
                keys[keyFigureForm]        = false;
                keysEnabled[keyFigureForm] = true;
                // stale KeyUp event
                fig_form.Show();
                fig_form.Activate();
            }

            float keyL    = 0.0f;
            float keyR    = 0.0f;
            float keyU    = 0.0f;
            float keyD    = 0.0f;
            float keyPush = 0.0f;
            float keyPull = 0.0f;
            float keyZRol = 0.0f;

            if (keys[(int)Keys.Left])
            {
                keyL = 2.0f;
            }
            if (keys[(int)Keys.Right])
            {
                keyR = 2.0f;
            }
            if (keys[(int)Keys.PageUp])
            {
                keyU = 2.0f;
            }
            if (keys[(int)Keys.PageDown])
            {
                keyD = 2.0f;
            }
            if (keys[(int)Keys.Up])
            {
                keyPush = 1.0f;
            }
            if (keys[(int)Keys.Down])
            {
                keyPull = 1.0f;
            }
            if (keys[(int)Keys.A])
            {
                keyZRol = -2.0f;
            }
            if (keys[(int)Keys.D])
            {
                keyZRol = +2.0f;
            }

            camera.Move(keyR - keyL, keyU - keyD, keyPull - keyPush);
            camera.RotZ(DegreeToRadian(keyZRol));
        }