예제 #1
0
    public static Vector3 smoothedPalm(Hand hand)
    {
        Vector3 palmPos = 0.5f * HandControllerUtil.toUnitySpace(hand.PalmPosition);

        foreach (Finger finger in hand.Fingers)
        {
            palmPos += 0.1f * HandControllerUtil.toUnitySpace(finger.TipPosition);
        }
        return(palmPos);
    }
예제 #2
0
    private void updateLeapTouches()
    {
        Frame frame = HandControllerUtil.handController.GetFrame();

        Dictionary <int, LeapTouch> newTouches = new Dictionary <int, LeapTouch>();

        foreach (Hand hand in frame.Hands)
        {
            foreach (Finger finger in hand.Fingers)
            {
                LeapTouch leapTouch = new LeapTouch();
                leapTouch.fingerId = finger.Id;

                leapTouch.position = HandControllerUtil.toUnitySpace(finger.TipPosition);

                if (!doesTouch(leapTouch))
                {
                    continue;
                }

                if (finger.Type != Finger.FingerType.TYPE_INDEX)
                {
                    continue;
                }

                LeapTouch previousTouch;
                if (!_leapTouches.TryGetValue(finger.Id, out previousTouch))
                {
                    leapTouch.phase = TouchPhase.Began;
                }
                else
                {
                    leapTouch.phase = TouchPhase.Moved;
                }

                newTouches[finger.Id] = leapTouch;
            }
        }

        foreach (var pair in _leapTouches)
        {
            //If we have been tracking a non-ended touch and it is not present in the new frame, generate a touch-ended touch
            if (pair.Value.phase != TouchPhase.Ended && !newTouches.ContainsKey(pair.Key))
            {
                LeapTouch endingTouch = new LeapTouch();
                endingTouch.fingerId = pair.Key;
                endingTouch.position = pair.Value.position;
                endingTouch.phase    = TouchPhase.Ended;
                newTouches[pair.Key] = endingTouch;
            }
        }

        _leapTouches = newTouches;
    }
예제 #3
0
    public static float reachDistance(Hand hand, Vector3 center)
    {
        float distance = Vector3.Distance(HandControllerUtil.toUnitySpace(hand.PalmPosition), center);

        foreach (Finger finger in hand.Fingers)
        {
            distance = Mathf.Max(distance, Vector3.Distance(HandControllerUtil.toUnitySpace(finger.TipPosition), center));
        }

        return(distance);
    }
예제 #4
0
            protected override float getRawValue()
            {
                Vector3 palmNorm = HandControllerUtil.toUnityDir(_infoCalculator._hand.PalmNormal);

                //Rough surface normal
                Vector3 internalNorm = _infoCalculator._closestPointToPalm - _infoCalculator._palmPos;

                if (_infoCalculator._palmToSurfaceDistance < 0)
                {
                    internalNorm = -internalNorm;
                }

                return(Vector3.Angle(palmNorm, internalNorm) < _settings.maxPalmToSurfaceAngle ? 0.0f : 1.0f);
            }
예제 #5
0
        private float signedTipDistToSurface(Finger finger)
        {
            Vector3 tip = HandControllerUtil.toUnitySpace(finger.TipPosition);

            return(_targetVolume.signedDistanceToW2W(tip));
        }
예제 #6
0
 private void calculatePalmDistanceToSurface()
 {
     _palmPos               = HandControllerUtil.toUnitySpace(_hand.PalmPosition);
     _closestPointToPalm    = _targetVolume.closestPointOnSurfaceW2W(_palmPos);
     _palmToSurfaceDistance = Vector3.Distance(_closestPointToPalm, _palmPos);
 }
예제 #7
0
 public static float reachDistance(Hand hand)
 {
     return(reachDistance(hand, HandControllerUtil.head()));
 }