/// <summary> /// Returns the euler rotation in degrees for the right hand or Vector3.zero if it is unavailable /// </summary> public Vector3 GetRightHandNormal() { SDK_BaseGestureLibrary currentLibrary = VRTK.VRTK_SDK_Bridge.GetHandSDK().GetGestureLibrary(); if (currentLibrary == null) { Debug.LogWarning("Unable to find gesture library for current Hand SDK"); return(Vector3.zero); } else { return(currentLibrary.GetHandNormal(SDK_BaseGestureLibrary.Hand.Right)); } }
public virtual bool GetBoolValue(BasicGesture givenGesture, SDK_BaseGestureLibrary.Hand handIndex) { SDK_BaseGestureLibrary currentLibrary = VRTK.VRTK_SDK_Bridge.GetHandSDK().GetGestureLibrary(); if (currentLibrary == null) { // preventing a null exception, but this really should use some error handling // since currently it doesn't differentiate between a gesture not happening and a hand not existing // does not print a warning because it would flood the log return(false); } switch (givenGesture) { case BasicGesture.IsThumbBent: return(currentLibrary.IsFingerBent(handIndex, SDK_BaseGestureLibrary.Finger.Thumb)); case BasicGesture.IsIndexFingerBent: return(currentLibrary.IsFingerBent(handIndex, SDK_BaseGestureLibrary.Finger.Index)); case BasicGesture.IsMiddleFingerBent: return(currentLibrary.IsFingerBent(handIndex, SDK_BaseGestureLibrary.Finger.Middle)); case BasicGesture.IsRingFingerBent: return(currentLibrary.IsFingerBent(handIndex, SDK_BaseGestureLibrary.Finger.Ring)); case BasicGesture.IsPinkyFingerBent: return(currentLibrary.IsFingerBent(handIndex, SDK_BaseGestureLibrary.Finger.Pinky)); case BasicGesture.IsHandOpen: return(currentLibrary.IsHandOpen(handIndex)); case BasicGesture.IsHandClosed: return(currentLibrary.IsHandClosed(handIndex)); case BasicGesture.IsHandPinching: return(currentLibrary.IsHandPinched(handIndex)); default: return(false); } }
public override bool IsConditionOccuring(SDK_BaseGestureLibrary.Hand specificHand, AdvancedGesture advancedGestureInfo) { SDK_BaseGestureLibrary currentLibrary = VRTK.VRTK_SDK_Bridge.GetHandSDK().GetGestureLibrary(); if (currentLibrary == null) { Debug.LogWarning("No gesture library detected for the current Hand SDK"); return(false); } Vector3 palmNormal = currentLibrary.GetHandNormal(specificHand); if (palmNormal == Vector3.zero) { // hand tracking lost return(false); } // otherVec is a normal vector that will be compared to the palm vector Vector3 otherVec; Quaternion rotationToUse = Quaternion.Euler(eulerRotationFromOtherVector); if (otherVectorToUse == OtherVector.World) { switch (otherVectorDirection) { case VectorType.Forward: { otherVec = rotationToUse * Vector3.forward; break; } case VectorType.Up: { otherVec = rotationToUse * Vector3.up; break; } default: { otherVec = rotationToUse * Vector3.up; break; } } } else if (otherVectorToUse == OtherVector.Hmd) { Transform hmd = VRTK_SDK_Bridge.GetHeadset(); switch (otherVectorDirection) { case VectorType.Forward: { otherVec = hmd.TransformDirection(rotationToUse * Vector3.forward); break; } case VectorType.Up: { otherVec = hmd.TransformDirection(rotationToUse * Vector3.up); break; } default: { otherVec = hmd.TransformDirection(rotationToUse * Vector3.up); break; } } } else { // for whatever reason, otherVec is undefined. return false return(false); } float dotProduct = Vector3.Dot(otherVec, palmNormal); // close to 1 -> similar direction if (dotProduct >= 1 - tolerance) { return(true); } else { return(false); } }