Пример #1
0
        void Update()
        {
            if (_handController == null || !_handController.GetLeapController().IsConnected)
            {
                return;
            }

            var h = (Type == HandType.Left) ? Hands.Left : Hands.Right;

            if (h == null)
            {
                return;
            }
            if (h.Confidence < 0.7f)
            {
                return;
            }

            Direction.Invoke(h.Direction.ToQuaternion());
            Position.Invoke(h.PalmPosition.ToVector3());
            Fist.Invoke(Hands.GetFistStrength(h));

            foreach (var f in h.Fingers)
            {
                _fingers [(int)f.Type].Invoke(f);
            }
        }
Пример #2
0
    protected override void UpdateState()
    {
        if (_armController == null || !_armController.GetLeapController().IsConnected)
        {
            return;
        }

        if (_type != Type)
        {
            _type = Type;
            _resetOrientation();
        }

        var h = (Type == TxBodyInput.SideType.Left) ? Hands.Left : Hands.Right;

        if (h == null)
        {
            return;
        }

        if (h.Confidence < MinimumConfidence)
        {
            return;
        }

        bool flip = true;// (Type == TxBodyInput.SideType.Right);

        var q = h.Arm.Rotation.ToQuaternion(flip);
        var e = q.eulerAngles;

        _arm.Elbow.Position = h.Arm.ElbowPosition.ToVector3();
//             _arm.elbow.Rotation = Quaternion.Euler(0, 0, e.z) ;
//             _arm.forearm.Rotation = Quaternion.Euler(e.x, e.y, 0) ;
//             Quaternion invRot = Quaternion.Inverse(q);

        _arm.wrist.Position = _armController.transform.TransformPoint(h.Arm.WristPosition.ToVector3());
        q = h.Rotation.ToQuaternion(flip);
        _arm.wrist.Rotation = _armController.transform.TransformRotation(q);
        Quaternion invRot;

        invRot = Quaternion.Inverse(q);

        foreach (var f in FingerMap)
        {
            //  Vector3 fingerBase= h.Finger(f.Value).
            var src  = h.Fingers[f.Value];
            var dst  = _arm.hand.Fingers[f.Key];
            var invR = Quaternion.Inverse(src.Bone(Bone.BoneType.TYPE_METACARPAL).Rotation.ToQuaternion(flip) * Reorintation);
            foreach (var j in FingerJointsMap)
            {
                //    _arm.Fingers[f.Key].Joints[j.Key].Position = h.Finger(f.Value).bones[j.Value].Direction.ToQuaternion();
                q = src.Bone((Bone.BoneType)(j.Value)).Rotation.ToQuaternion(flip);
                dst.Joints[j.Key].Rotation = invR * q;
                invR = Quaternion.Inverse(q);
            }
        }

        Arm.Invoke(_arm);
        Hand.Invoke(_arm.hand);
        Fist.Invoke(Hands.GetFistStrength(h));
        Provider.Invoke(_armController);
    }