void BimanualUntracked() { bimanualGesture = BimanualGestureType.Unknown; bimanualData = null; }
void PoseGestureUpdate() { Frame frame = leapServiceProvider.CurrentFrame; List <Hand> hands = frame.Hands; if (hands.Count > 0) { switch (hands.Count) { case 1: if (hands[0].IsLeft) { leftHand = hands[0]; rightHand = null; } else { leftHand = null; rightHand = hands[0]; } break; case 2: if (hands[0].IsRight) { leftHand = hands[1]; rightHand = hands[0]; } else { leftHand = hands[0]; rightHand = hands[1]; } break; } if (leftHand != null && leftHand.Id != 0) { if (leftHand.IsPinching()) { if (!isLeftHandPinching) { leftHandPinchStart = leftHand.PalmPosition.ToVector3(); } if (overridePinchStatus) { isLeftHandPinching = (leftHand.PinchStrength <= maxPinchStrength && leftHand.PinchStrength >= minPinchStrength) ? true : false; } else { isLeftHandPinching = true; } } else if (!leftHand.IsPinching()) { isLeftHandPinching = false; leftHandPinchStart = Vector3.negativeInfinity; } isLeftHandTracked = true; leftHandPose = handPoseRecognition.GetHandPose(leftHand); leftHandGesture = leftGestureRecognition.GetUnimanualGesture(leftHandPose); if (!leftHandGesture.Equals(UnimanualGestureType.Unknown.ToString())) { if (leftUnimanualData == null || leftUnimanualData.gesture != leftHandGesture) { Hand h = new Hand(); h = h.CopyFrom(leftHand); leftUnimanualData = new UnimanualData(leftHandGesture, h); } } else { leftUnimanualData = null; } } else { LeftUntracked(); } if (rightHand != null && rightHand.Id != 0) { if (rightHand.IsPinching()) { if (!isRightHandPinching) { righHandPinchStart = rightHand.PalmPosition.ToVector3(); } if (overridePinchStatus) { isRightHandPinching = (rightHand.PinchStrength <= maxPinchStrength && rightHand.PinchStrength >= minPinchStrength) ? true : false; } else { isRightHandPinching = true; } } else if (!rightHand.IsPinching()) { isRightHandPinching = false; righHandPinchStart = Vector3.negativeInfinity; } isRightHandTracked = true; rightHandPose = handPoseRecognition.GetHandPose(rightHand); rightHandGesture = rightGestureRecognition.GetUnimanualGesture(rightHandPose); if (!rightHandGesture.Equals(UnimanualGestureType.Unknown.ToString())) { if (rightUnimanualData == null || rightUnimanualData.gesture != rightHandGesture) { Hand h = new Hand(); h = h.CopyFrom(rightHand); rightUnimanualData = new UnimanualData(rightHandGesture, h); } } else { rightUnimanualData = null; } //EventUpdate UpdatePoseEvents(); } else { RightUntracked(); } if (hands.Count == 2 && leftHand != null && rightHand != null) { bimanualGesture = bimanualRecognition.GetBimanualGesture(leftHandGesture, rightHandGesture); if (!bimanualGesture.Equals(BimanualGestureType.Unknown.ToString())) { if (bimanualData == null || bimanualGesture != bimanualData.gesture) { Hand l = new Hand(); l = l.CopyFrom(leftHand); Hand r = new Hand(); r = r.CopyFrom(rightHand); bimanualData = new BimanualData(l, r, leftHandGesture, rightHandGesture, bimanualGesture); } } else { bimanualData = null; } } else { bimanualGesture = BimanualGestureType.Unknown; } } else { LeftUntracked(); RightUntracked(); BimanualUntracked(); } }