10using System.Collections;
36 [Tooltip(
"The interval in seconds at which to check this detector's conditions.")]
45 [Tooltip(
"The hand model to watch. Set automatically if detector is on a hand.")]
52 [Tooltip(
"The finger to observe.")]
71 [Header(
"Direction Settings")]
72 [Tooltip(
"How to treat the target direction.")]
80 [Tooltip(
"The target direction.")]
87 [Tooltip(
"A target object(optional). Use PointingType.AtTarget")]
95 [Tooltip(
"The angle in degrees from the target direction at which to turn on.")]
104 [Tooltip(
"The angle in degrees from the target direction at which to turn off.")]
111 [Tooltip(
"Draw this detector's Gizmos, if any. (Gizmos must be on in Unity edtor, too.)")]
114 private IEnumerator watcherCoroutine;
116 private void OnValidate(){
122 private void Awake () {
123 watcherCoroutine = fingerPointingWatcher();
126 private void OnEnable () {
127 StartCoroutine(watcherCoroutine);
130 private void OnDisable () {
131 StopCoroutine(watcherCoroutine);
135 private IEnumerator fingerPointingWatcher() {
139 int selectedFinger = selectedFingerOrdinal();
144 targetDirection = selectedDirection(hand.Fingers[selectedFinger].TipPosition.ToVector3());
145 fingerDirection = hand.Fingers[selectedFinger].Bone(Bone.BoneType.TYPE_DISTAL).Direction.ToVector3();
146 float angleTo =
Vector3.Angle(fingerDirection, targetDirection);
154 yield
return new WaitForSeconds(
Period);
158 private Vector3 selectedDirection(Vector3 tipPosition){
161 Quaternion cameraRot = Camera.main.transform.rotation;
162 float cameraYaw = cameraRot.eulerAngles.y;
176 private int selectedFingerOrdinal(){
178 case Finger.FingerType.TYPE_INDEX:
180 case Finger.FingerType.TYPE_MIDDLE:
182 case Finger.FingerType.TYPE_PINKY:
184 case Finger.FingerType.TYPE_RING:
186 case Finger.FingerType.TYPE_THUMB:
194 private void OnDrawGizmos () {
203 Vector3 fingerDirection = finger.Bone(Bone.BoneType.TYPE_DISTAL).Direction.ToVector3();
204 Utils.DrawCone(finger.TipPosition.ToVector3(), fingerDirection,
OnAngle, finger.Length, innerColor);
205 Utils.DrawCone(finger.TipPosition.ToVector3(), fingerDirection,
OffAngle, finger.Length,
LimitColor);
207 Gizmos.DrawRay(finger.TipPosition.ToVector3(), selectedDirection(finger.TipPosition.ToVector3()));
The Finger class represents a tracked finger.
FingerType
Enumerates the names of the fingers.
List< Finger > Fingers
The list of Finger objects detected in this frame that are attached to this hand, given in order from...
virtual void Deactivate()
PointingType PointingType
Finger.FingerType FingerName
Vector3 PointingDirection
abstract Hand GetLeapHand()