// resets the gesture-data state for the given extra gesture public bool ResetGesture(LeapExtraGestures.ExtraGestures gesture) { int index = GetGestureIndex(gesture); if(index < 0) return false; LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index]; gestureData.state = 0; gestureData.jointId = 0; gestureData.progress = 0f; gestureData.complete = false; gestureData.cancelled = false; gestureData.startTrackingAtTime = Time.realtimeSinceStartup + LeapExtraGestures.Constants.MinTimeBetweenGestures; extraGesturesData[index] = gestureData; return true; }
// return the index of extra gesture in the list, or -1 if not found private int GetGestureIndex(LeapExtraGestures.ExtraGestures gesture) { int listSize = extraGesturesData.Count; for(int i = 0; i < listSize; i++) { if(extraGesturesData[i].gesture == gesture) return i; } return -1; }
// returns true, if the given extra gesture is complete public bool IsGestureComplete(LeapExtraGestures.ExtraGestures gesture, bool bResetOnComplete) { int index = GetGestureIndex(gesture); if(index >= 0) { LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index]; if(bResetOnComplete && gestureData.complete) { ResetGesture(gesture); return true; } return gestureData.complete; } return false; }
// returns true, if the given extra gesture is in the list of detected extra gestures public bool IsGestureDetected(LeapExtraGestures.ExtraGestures gesture) { int index = GetGestureIndex(gesture); return index >= 0; }
// returns the normalized velocity of the given extra gesture public Vector3 GetGestureVelocity(LeapExtraGestures.ExtraGestures gesture) { int index = GetGestureIndex(gesture); if(index >= 0) { LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index]; if(gestureData.completeTime > 0) { Vector3 gestureVel = gestureData.gestureDir / gestureData.completeTime; return gestureVel.normalized; } } return Vector3.zero; }
// returns true, if the given extra gesture is cancelled public bool IsGestureCancelled(LeapExtraGestures.ExtraGestures gesture) { int index = GetGestureIndex(gesture); if(index >= 0) { LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index]; return gestureData.cancelled; } return false; }
// returns the normalized screen position of the given extra gesture public Vector3 GetGestureScreenPos(LeapExtraGestures.ExtraGestures gesture) { int index = GetGestureIndex(gesture); if(index >= 0) { LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index]; return gestureData.screenPos; } return Vector3.zero; }
// returns the progress in range [0, 1] of the given extra gesture public float GetGestureProgress(LeapExtraGestures.ExtraGestures gesture) { int index = GetGestureIndex(gesture); if(index >= 0) { LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index]; return gestureData.progress; } return 0f; }
// returns the normalized direction of the given extra gesture public Vector3 GetGestureDirection(LeapExtraGestures.ExtraGestures gesture) { int index = GetGestureIndex(gesture); if(index >= 0) { LeapExtraGestures.ExtraGestureData gestureData = extraGesturesData[index]; return gestureData.gestureDir.normalized; } return Vector3.zero; }
// adds a gesture to the list of detected extra gestures public void DetectGesture(LeapExtraGestures.ExtraGestures gesture) { int index = GetGestureIndex(gesture); if(index >= 0) DeleteGesture(gesture); LeapExtraGestures.ExtraGestureData gestureData = new LeapExtraGestures.ExtraGestureData(); gestureData.gesture = gesture; gestureData.state = 0; gestureData.jointId = 0; gestureData.progress = 0f; gestureData.complete = false; gestureData.cancelled = false; extraGesturesData.Add(gestureData); }
// deletes the given gesture from the list of detected extra gestures public bool DeleteGesture(LeapExtraGestures.ExtraGestures gesture) { int index = GetGestureIndex(gesture); if(index < 0) return false; extraGesturesData.RemoveAt(index); return true; }