xna 触控操作 备忘

 private void HandleInput()

        {

            while (TouchPanel.IsGestureAvailable)

            {

                GestureSample gestureSample = TouchPanel.ReadGesture();

                switch (gestureSample.GestureType)

                {

                    case GestureType.FreeDrag:

                        rotationXAmount += gestureSample.Delta.X;

                        rotationYAmount -= gestureSample.Delta.Y;

                        break;



                    case GestureType.Pinch:

                        float gestureValue = 0;

                        float minFOV = 60;

                        float maxFOV = 30;

                        float gestureLengthToZoomScale = 10;



                        Vector2 gestureDiff = gestureSample.Position - gestureSample.Position2;

                        gestureValue = gestureDiff.Length() / gestureLengthToZoomScale;



                        if (null != prevLength) // Skip the first pinch event

                            cameraFOV -= gestureValue - prevLength.Value;



                        cameraFOV = MathHelper.Clamp(cameraFOV, maxFOV, minFOV);



                        prevLength = gestureValue;

                        break;



                    case GestureType.PinchComplete:

                        prevLength = null;

                        break;

                    default:

                        break;

                }

            }

        }


windows phone xna 中 通过手势来旋转模型的矩阵.

你可能感兴趣的:(操作)