Пример #1
0
    public void updateInfo(Hand hand)
    {
        _lastTimeUpdated = Time.time;
        _leapHand        = hand;

        foreach (Finger finger in hand.Fingers)
        {
            Dictionary <Finger.FingerJoint, InteractionPoint> fingerPoints;
            if (!_fingerPointMap.TryGetValue(finger.Type, out fingerPoints))
            {
                fingerPoints = new Dictionary <Finger.FingerJoint, InteractionPoint>();
                _fingerPointMap[finger.Type] = fingerPoints;
            }

            for (int i = 0; i < 4; i++)
            {
                Finger.FingerJoint jointType = (Finger.FingerJoint)i;

                Vector3 jointPosition = HandInfo.unityPos(finger.JointPosition(jointType));

                InteractionPoint point;
                if (!fingerPoints.TryGetValue(jointType, out point))
                {
                    point = new InteractionPoint();
                    fingerPoints[jointType] = point;
                }

                point.update(jointPosition);
            }
        }

        Vector3 palmPoint = HandInfo.unityPos(hand.PalmPosition);

        Matrix  basis  = hand.Basis;
        Vector3 xBasis = HandInfo.unityDir(basis.xBasis) * PALM_BASIS_WEIGHT;
        Vector3 yBasis = HandInfo.unityDir(basis.yBasis) * PALM_BASIS_WEIGHT;
        Vector3 zBasis = HandInfo.unityDir(basis.zBasis) * PALM_BASIS_WEIGHT;

        _basisPoints[0].update(palmPoint + xBasis);
        _basisPoints[1].update(palmPoint + yBasis);
        _basisPoints[2].update(palmPoint + zBasis);
        _basisPoints[3].update(palmPoint - xBasis);
        _basisPoints[4].update(palmPoint - yBasis);
        _basisPoints[5].update(palmPoint - zBasis);

        _closeObjects.Clear();
        Collider[] colliders = Physics.OverlapSphere(palmPoint, HandInfo.unityLength(0.25f), InteractionController.instance.grabbableLayer);
        foreach (Collider c in colliders)
        {
            _closeObjects.Add(c.gameObject);
        }
    }