private void GestureListener() { //not editable when building if (this.Lock) { return; } else { controller = new Controller(); Frame frame = _leapProvider.CurrentFrame; List <Hand> hands = frame.Hands; Hand leftHand = new Hand(); bool leftHandExist = false; Hand rightHand = new Hand(); bool rightHandExist = false; foreach (Hand hand in hands) { if (hand.IsLeft) { leftHand = hand; leftHandExist = true; } else { rightHand = hand; rightHandExist = true; } } //One-Hand Gestures for Left Hand if (leftHandExist) { //LeapGestureModel.State stateGrabLH = gestureGrabLH.Check(leftHand, null, Time.deltaTime); //LeapGestureModel.State stateGrabbingLH = gestureGrabbingLH.Check(leftHand, null, Time.deltaTime); LeapGestureModel.State statePinchLH = gesturePinchLH.Check(leftHand, null, Time.deltaTime); //LeapGestureModel.State statePinchingLH = gesturePinchingLH.Check(leftHand, null, Time.deltaTime); //LeapGestureModel.State stateTappingLH = gestureTappingLH.Check(leftHand, null, Time.deltaTime); LeapGestureModel.State stateHoveringLH = gestureHoveringLH.Check(leftHand, null, Time.deltaTime); /* * if (stateGrabLH == LeapGestureModel.State.End) * { * OneHandGrab(0); * } * if (stateGrabbingLH == LeapGestureModel.State.InProcess) * { * OneHandGrabbing(0); * } * if (stateGrabbingLH == LeapGestureModel.State.End) * { * OneHandEndGrabbing(0); * }*/ if (statePinchLH == LeapGestureModel.State.End) { OneHandPinch(0); }/* * if (statePinchingLH == LeapGestureModel.State.InProcess) * { * //OneHandPinching(0); * } * if (statePinchingLH== LeapGestureModel.State.End) * { * //OneHandEndPinching(0); * } * if (stateTappingLH == LeapGestureModel.State.InProcess) * { * //OneHandTapping(0); * } * if (stateTappingLH == LeapGestureModel.State.End) * { * // OneHandEndTapping(0); * }*/ if (stateHoveringLH == LeapGestureModel.State.InProcess) { OneHandHovering(0); } } //One-Hand Gestures for Right Hand if (rightHandExist) { //LeapGestureModel.State stateGrabRH = gestureGrabRH.Check(null, rightHand, Time.deltaTime); //LeapGestureModel.State stateGrabbingRH = gestureGrabbingRH.Check(null, rightHand, Time.deltaTime); LeapGestureModel.State statePinchRH = gesturePinchRH.Check(null, rightHand, Time.deltaTime); //LeapGestureModel.State statePinchingRH = gesturePinchingRH.Check(null, rightHand, Time.deltaTime); //LeapGestureModel.State stateTappingRH = gestureTappingRH.Check(null, rightHand, Time.deltaTime); LeapGestureModel.State stateHoveringRH = gestureHoveringRH.Check(null, rightHand, Time.deltaTime); /*if (stateGrabRH == LeapGestureModel.State.End) * { * OneHandGrab(1); * } * if (stateGrabbingRH == LeapGestureModel.State.InProcess) * { * OneHandGrabbing(1); * } * if (stateGrabbingRH == LeapGestureModel.State.End) * { * OneHandEndGrabbing(1); * }*/ if (statePinchRH == LeapGestureModel.State.End) { OneHandPinch(1); } /*if (statePinchingRH == LeapGestureModel.State.InProcess) * { * //OneHandPinching(1); * } * if (statePinchingRH == LeapGestureModel.State.End) * { * //OneHandEndPinching(1); * } * if (stateTappingRH == LeapGestureModel.State.InProcess) * { * //OneHandTapping(1); * } * if (stateTappingRH == LeapGestureModel.State.End) * { * //OneHandEndTapping(1); * }*/ if (stateHoveringRH == LeapGestureModel.State.InProcess) { OneHandHovering(1); } } if (leftHandExist && rightHandExist) { LeapGestureModel.State stateSplit = gestureSplit.Check(leftHand, rightHand, Time.deltaTime); if (stateSplit == LeapGestureModel.State.End) { handle.moveObjectTo(UnityVectorExtension.ToVector3(leftHand.PalmPosition)); if (!oldVersion) { bin.moveObjectTo(UnityVectorExtension.ToVector3(rightHand.PalmPosition)); } } } if (!leftHandExist && !rightHandExist) { OneHandHovering(2); } } }
protected void GestureListener() { //not editable when building if (this.Lock) { return; } else { controller = new Controller(); Frame frame = controller.Frame(); List <Hand> hands = frame.Hands; Hand leftHand = new Hand(); bool leftHandExist = false; Hand rightHand = new Hand(); bool rightHandExist = false; foreach (Hand hand in hands) { if (hand.IsLeft) { leftHand = hand; leftHandExist = true; } else { rightHand = hand; rightHandExist = true; } } if (dupActived) { //Two-Hands Gestures if (leftHandExist & rightHandExist) { if (gestureClap.Check(leftHand, rightHand, Time.deltaTime) == LeapGestureModel.State.End) { TwoHandsClap(); } } //One-Hand Gestures for Left Hand else if (leftHandExist & !rightHandExist) { LeapGestureModel.State stateRightSwapLH = gestureRightSwapLH.Check(leftHand, null, Time.deltaTime); LeapGestureModel.State stateLeftSwapLH = gestureLeftSwapLH.Check(leftHand, null, Time.deltaTime); LeapGestureModel.State stateUpLongSwapLH = gestureUpLongSwapLH.Check(leftHand, null, Time.deltaTime); LeapGestureModel.State stateDownLongSwapLH = gestureDownLongSwapLH.Check(leftHand, null, Time.deltaTime); LeapGestureModel.State stateGrabLH = gestureGrabLH.Check(leftHand, null, Time.deltaTime); LeapGestureModel.State stateGrabbingLH = gestureGrabbingLH.Check(leftHand, null, Time.deltaTime); if (stateRightSwapLH == LeapGestureModel.State.End) { OneHandRightSwap(); } if (stateLeftSwapLH == LeapGestureModel.State.End) { OneHandLeftSwap(); }/* * if ((gestureUpSwapLH.Check(leftHand, null, Time.deltaTime) == LeapGestureModel.State.End)) * { * OneHandUpSwap(); * } * if ((gestureDownSwapLH.Check(leftHand, null, Time.deltaTime) == LeapGestureModel.State.End)) * { * OneHandDownSwap(); * }*/ if (stateUpLongSwapLH == LeapGestureModel.State.InProcess) { if (stateGrabbingLH == LeapGestureModel.State.InProcess) { OneHandUpGrabbing((GestureUpLongSwap)gestureUpLongSwapLH); } else { OneHandUpSwap((GestureUpLongSwap)gestureUpLongSwapLH); } } if (stateDownLongSwapLH == LeapGestureModel.State.InProcess) { if (stateGrabbingLH == LeapGestureModel.State.InProcess) { OneHandDownGrabbing((GestureDownLongSwap)gestureDownLongSwapLH); } else { OneHandDownSwap((GestureDownLongSwap)gestureDownLongSwapLH); } } if (stateGrabLH == LeapGestureModel.State.End) { OneHandGrab(); } } //One0Hand Gestures for Right Hand else if (!leftHandExist & rightHandExist) { LeapGestureModel.State stateRightSwapRH = gestureRightSwapRH.Check(null, rightHand, Time.deltaTime); LeapGestureModel.State stateLeftSwapRH = gestureLeftSwapRH.Check(null, rightHand, Time.deltaTime); LeapGestureModel.State stateUpLongSwapRH = gestureUpLongSwapRH.Check(null, rightHand, Time.deltaTime); LeapGestureModel.State stateDownLongSwapRH = gestureDownLongSwapRH.Check(null, rightHand, Time.deltaTime); LeapGestureModel.State stateGrabRH = gestureGrabRH.Check(null, rightHand, Time.deltaTime); LeapGestureModel.State stateGrabbingRH = gestureGrabbingRH.Check(null, rightHand, Time.deltaTime); if (stateRightSwapRH == LeapGestureModel.State.End) { OneHandRightSwap(); } if (stateLeftSwapRH == LeapGestureModel.State.End) { OneHandLeftSwap(); }/* * if ((gestureUpSwapRH.Check(null, rightHand, Time.deltaTime) == LeapGestureModel.State.End)) * { * OneHandUpSwap(); * } * if ((gestureDownSwapRH.Check(null, rightHand, Time.deltaTime) == LeapGestureModel.State.End)) * { * OneHandDownSwap(); * }*/ if (stateUpLongSwapRH == LeapGestureModel.State.InProcess) { if (stateGrabbingRH == LeapGestureModel.State.InProcess) { OneHandUpGrabbing((GestureUpLongSwap)gestureUpLongSwapRH); } else { OneHandUpSwap((GestureUpLongSwap)gestureUpLongSwapRH); } } if (stateDownLongSwapRH == LeapGestureModel.State.InProcess) { if (stateGrabbingRH == LeapGestureModel.State.InProcess) { OneHandDownGrabbing((GestureDownLongSwap)gestureDownLongSwapRH); } else { OneHandDownSwap((GestureDownLongSwap)gestureDownLongSwapRH); } } if (stateGrabRH == LeapGestureModel.State.End) { OneHandGrab(); } } } else { if (leftHandExist & rightHandExist) { //check gesture models states if (gestureSplit.Check(leftHand, rightHand, Time.deltaTime) == LeapGestureModel.State.End) { TwoHandsSplit(); } } } } }