/****************************** * Hand Guesture Variables */ /********************************* Swipe Event ****************************************/ public void TrackingSwipeGesture(SkeletonPoint currentPoint) { //get current currentGesture = new GesturePoint() { X = currentPoint.X, Y = currentPoint.Y, Z = currentPoint.Z, T = DateTime.Now }; // if curr.x is less than spine.x - 0.1 // assign start point if ((currentGesture.Z < Kernel.spine.Position.Z - 0.7 && currentGesture.Z > Kernel.spine.Position.Z) || (currentGesture.X < Kernel.spine.Position.X - 0.1) ) { startGesture = currentGesture; return; } if (((currentGesture.Y > Kernel.hipCenter.Position.Y && currentGesture.Y < Kernel.head.Position.Y)) && (currentGesture.Z > Kernel.spine.Position.Z - 0.5 && currentGesture.Z < Kernel.spine.Position.Z) && (currentGesture.X > Kernel.spine.Position.X - 0.4 || currentGesture.X < Kernel.spine.Position.X + 0.1)) { if ((currentGesture.T - startGesture.T).Milliseconds <= swipeTime) { //judge gesture // seccussful gesture if ((currentGesture.X - startGesture.X < 1 && currentGesture.X - startGesture.X > 0.6) && (Math.Abs(currentGesture.Y - startGesture.Y) < 0.3) && (Math.Abs(currentGesture.Z - startGesture.Z) < 0.2) ) { startGesture = currentGesture; removeAllBottles(); } } } }
public void TrackingSwipeGesture(SkeletonPoint currentPoint) { //get current currentGesture = new GesturePoint() { X = currentPoint.X, Y = currentPoint.Y, Z = currentPoint.Z, T = DateTime.Now }; // if curr.x is less than spine.x - 0.1 // assign start point //Console.WriteLine("x: " + currentGesture.X + "z: " + currentGesture.Z); //Console.WriteLine("spine: " + Kernel.spine.Position.Z); if ((currentGesture.Z < Kernel.spine.Position.Z - 0.7 && currentGesture.Z > Kernel.spine.Position.Z) || (currentGesture.X > Kernel.spine.Position.X + 0.1) ) { //Console.WriteLine("start point"); startGesture = currentGesture; return; } // valid gesture range //Console.WriteLine("1"); //Console.WriteLine("2"); if (((currentGesture.Y > Kernel.hipCenter.Position.Y && currentGesture.Y < Kernel.head.Position.Y)) && (currentGesture.Z > Kernel.spine.Position.Z - 0.7 && currentGesture.Z < Kernel.spine.Position.Z) && (currentGesture.X < Kernel.spine.Position.X + 0.4 || currentGesture.X > Kernel.spine.Position.X - 0.1)) { // Console.WriteLine("3"); // valid time duration if ((currentGesture.T - startGesture.T).Milliseconds <= swipeTime) { //judge gesture // seccussful gesture // Console.WriteLine("ohyeah"); if ((currentGesture.X - startGesture.X > -1 && currentGesture.X - startGesture.X < -0.6) && (Math.Abs(currentGesture.Y - startGesture.Y) < 0.3) && (Math.Abs(currentGesture.Z - startGesture.Z) < 0.2) ) { //Console.WriteLine("ohyeah"); // assign current gesture to start startGesture = currentGesture; // do things you want GameWindow.kinect.SkeletonFrameReady -= new EventHandler<SkeletonFrameReadyEventArgs>(SkeletonFrame_Ready); GameWindow gameWindow = new GameWindow(); gameWindow.Show(); (this as Window).Close(); } } } }