private void OnTranslationGesture(object state, MovementHandlerEventArgs args) { _vector = args.KinectCoordinates; /*/ Game.GraphicsDevice.Viewport.Project(ConvertRealWorldPoint(args.KinectCoordinates), Matrix.CreatePerspectiveFieldOfView(1,Game.GraphicsDevice.Viewport.AspectRatio, 1, 10), Matrix.CreateLookAt(new Vector3(0, 0, 5f), Vector3.Zero, Vector3.Up), Matrix.Identity); //*/ }
private void OnRotateGesture(object state, MovementHandlerEventArgs args) { const float DistanceBetweenHands = 0.1f; // if (!(args.Skeleton.Joints[JointID.HandLeft].Position.Y > args.Skeleton.Joints[JointID.HipLeft].Position.Y && args.Skeleton.Joints[JointID.HandRight].Position.Y > args.Skeleton.Joints[JointID.HipRight].Position.Y)) { _startXBottomRotation = _startXTopRotation = _startYLeftRotation = _startYRightRotation = _startZLeftRotation = _startZRightRotation = false; return; } //*/ if (args.Joint == JointID.HandRight) { _startYRightRotation = //args.KinectCoordinates.Z < args.Skeleton.Joints[JointID.ShoulderRight].Position.Z - 0.3 && args.KinectCoordinates.Z < args.Skeleton.Joints[JointID.HandLeft].Position.Z - DistanceBetweenHands; _startYLeftRotation = false; } else { _startYLeftRotation = //args.KinectCoordinates.Z < args.Skeleton.Joints[JointID.ShoulderLeft].Position.Z - 0.3 && args.KinectCoordinates.Z < args.Skeleton.Joints[JointID.HandRight].Position.Z - DistanceBetweenHands; _startYRightRotation = false; } if (args.Joint == JointID.HandRight) { _startZRightRotation = args.KinectCoordinates.Y >= args.Skeleton.Joints[JointID.WristRight].Position.Y && args.KinectCoordinates.Y > args.Skeleton.Joints[JointID.HandLeft].Position.Y + DistanceBetweenHands; _startZLeftRotation = false; } else { _startZLeftRotation = args.KinectCoordinates.Y >= args.Skeleton.Joints[JointID.WristLeft].Position.Y && args.KinectCoordinates.Y > args.Skeleton.Joints[JointID.HandRight].Position.Y + DistanceBetweenHands; _startZRightRotation = false; } }
private void OnScale(object state, MovementHandlerEventArgs args) { bool handsAbove = false, handsSided = false; if ((args.Joint == JointID.HandRight && args.KinectCoordinates.Y > args.Skeleton.Joints[JointID.HandLeft].Position.Y + 0.1) || (args.Joint == JointID.HandRight && args.KinectCoordinates.Y < args.Skeleton.Joints[JointID.HandLeft].Position.Y - 0.1) || (args.Joint == JointID.HandLeft && args.KinectCoordinates.Y > args.Skeleton.Joints[JointID.HandRight].Position.Y - 0.1) || (args.Joint == JointID.HandLeft && args.KinectCoordinates.Y < args.Skeleton.Joints[JointID.HandRight].Position.Y + 0.1)) { handsAbove = true; } if ((args.Joint == JointID.HandRight && args.KinectCoordinates.X > args.Skeleton.Joints[JointID.HandLeft].Position.X + 0.1) || (args.Joint == JointID.HandLeft && args.KinectCoordinates.X < args.Skeleton.Joints[JointID.HandRight].Position.X - 0.3)) { handsSided = true; } if (handsSided && handsAbove) { _fullScale = true; _lateralScale = false; _topScale = false; } else if (handsSided) { _lateralScale = true; _fullScale = false; _topScale = false; } else if (handsAbove) { _topScale = true; _fullScale = false; _lateralScale = false; } if (_fullScale) _distanceBetweenHands = (float) Math.Sqrt( Math.Pow(args.Skeleton.Joints[JointID.HandLeft].Position.X - args.Skeleton.Joints[JointID.HandRight].Position.X, 2) + Math.Pow(args.Skeleton.Joints[JointID.HandLeft].Position.Y - args.Skeleton.Joints[JointID.HandRight].Position.Y, 2)); else if (_lateralScale) _distanceBetweenHands = Math.Abs(args.Skeleton.Joints[JointID.HandRight].Position.X - args.Skeleton.Joints[JointID.HandLeft].Position.X); else if (_topScale) _distanceBetweenHands = Math.Abs(args.Skeleton.Joints[JointID.HandRight].Position.Y - args.Skeleton.Joints[JointID.HandLeft].Position.Y); }
private void HandleMouseEvent(object state, MovementHandlerEventArgs args) { MouseCoordinates = new Vector2((args.KinectCoordinates.X * 1000) + 400, (args.KinectCoordinates.Y * -1000) + 320); }