Esempio n. 1
0
        public override float GetFingerValue(HandType hand, FingerName finger)
        {
            var value = 0f;
            //value = (hand == HandType.right) ? right.fingers[(int)finger]:left.fingers[(int)finger];
            SteamVR_Input_Sources source = (hand == HandType.right) ? SteamVR_Input_Sources.RightHand : SteamVR_Input_Sources.LeftHand;

            switch (finger)
            {
            case FingerName.Thumb:
                value = thumb.GetAxis(source);
                break;

            case FingerName.Index:
                value = index.GetAxis(source);
                break;

            case FingerName.Middle:
                value = middle.GetAxis(source);
                break;

            case FingerName.Ring:
                value = ring.GetAxis(source);
                break;

            case FingerName.Pinky:
                value = pinky.GetAxis(source);
                break;

            default:
                break;
            }
            return(value);
        }
Esempio n. 2
0
        public AvatarMask this[FingerName i]
        {
            get
            {
                AvatarMask mask = thumbAvatarMask;
                switch ((int)i)
                {
                case 0:
                    mask = thumbAvatarMask;
                    break;

                case 1:
                    mask = indexAvatarMask;
                    break;

                case 2:
                    mask = middleAvatarMask;
                    break;

                case 3:
                    mask = ringAvatarMask;
                    break;

                case 4:
                    mask = pinkyAvatarMask;
                    break;
                }
                return(mask);
            }
        }
Esempio n. 3
0
        static BodyPart ToHumanPart(FingerName finger, BodySide side)
        {
            var isLeft = side == BodySide.Left;

            if (finger == FingerName.Thumb)
            {
                return(isLeft ? BodyPart.FingerThumbL : BodyPart.FingerThumbR);
            }
            if (finger == FingerName.Index)
            {
                return(isLeft ? BodyPart.FingerIndexL : BodyPart.FingerIndexR);
            }
            if (finger == FingerName.Middle)
            {
                return(isLeft ? BodyPart.FingerMiddleL : BodyPart.FingerMiddleR);
            }
            if (finger == FingerName.Ring)
            {
                return(isLeft ? BodyPart.FingerRingL : BodyPart.FingerRingR);
            }
            if (finger == FingerName.Pinky)
            {
                return(isLeft ? BodyPart.FingerPinkyL : BodyPart.FingerPinkyR);
            }
            throw new ArgumentException("Unknown finger=" + finger + " and side=" + side);
        }
        protected void RotFingerToLocal(FingerName fingerName, int index, Vector3 fwLoc, Vector3 upLoc, Func <double, double> func = null)
        {
            var finger = _fingers[fingerName][index];
            var posRot = _human.Initial.Fingers[_side][fingerName][index];

            _actions.Add(new ItemRotation
            {
                Rotate =
                    move.Rotate(finger.localRotation * v3.fw, finger.localRotation * v3.up,
                                posRot.rotation * fwLoc, posRot.rotation * fwLoc.GetRealUp(upLoc), func),
                Item = finger
            });
        }
Esempio n. 5
0
        public override bool GetFinger(HandType hand, FingerName finger)
        {
            bool value = false;
            SteamVR_Input_Sources source = (hand == HandType.right) ? SteamVR_Input_Sources.RightHand : SteamVR_Input_Sources.LeftHand;

            switch (finger)
            {
            case FingerName.Trigger:
                value = trigger.GetLastState(source);
                break;

            case FingerName.Grip:
                value = grip.GetLastState(source);
                break;

            default:
                break;
            }
            return(value);
        }
        public bool IsGrab()
        {
            for (int fingerNum = 0; fingerNum < fingers.Length; fingerNum++)
            {
                FingerName fingerName = (FingerName)fingerNum;
                if (fingerName == FingerName.Thumb ||
                    fingerName == FingerName.Pinky)
                {
                    continue;
                }

                for (int segmentNum = 0; segmentNum < fingers[fingerNum].flexSensorRaw.Length; segmentNum++)
                {
                    float flex = (float)fingers[fingerNum].flexSensorRaw[segmentNum];

                    FlexSensorSegment flexSensorSegment = (FlexSensorSegment)segmentNum;
                    if (flexSensorSegment == FlexSensorSegment.Proximal)
                    {
                        // MCP need to more testing

                        //if (fingerName == FingerName.Pinky)
                        //    continue;

                        //// MCP
                        //if (flex < 0.1f)
                        //    return false;
                    }
                    else
                    {
                        // PIP or IP
                        if (flex < 0.5f)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Esempio n. 7
0
        public FingerChain(
            FingerName finger, BodySide side, Transform model, Transform parent,
            Transform srcJoin0, Transform srcJoin1, Transform srcJoin2, Vector3 upDirInWorld, double lastJoinDist)
            : base(ToHumanPart(finger, side))
        {
            _finger = finger;
            _side   = side;
            _model  = model;
            var sideSuffix = side == BodySide.Left ? "L" : "R";

            _root          = new GameObject(finger + sideSuffix + HolderSuffix).transform;
            _handle        = new GameObject(finger + sideSuffix + HandleSuffix).transform;
            _root.position = srcJoin0.position;
            _root.rotation = Quaternion.LookRotation((srcJoin1.position - _root.position).normalized, upDirInWorld);
            _root.SetParent(parent);

            _canChangeRotation = false;

            _join0           = WrapInHolder(_root, srcJoin0, srcJoin1.position, upDirInWorld);
            _join1           = WrapInHolder(_join0, srcJoin1, srcJoin2.position, upDirInWorld);
            _join2           = WrapInHolder(_join1, srcJoin2, srcJoin2.position + srcJoin2.forward, upDirInWorld);
            _allJoins        = new [] { _join0, _join1, _join2 };
            _len0            = distance.Between(_join0.position, _join1.position);
            _len1            = distance.Between(_join1.position, _join2.position);
            _len2            = (float)lastJoinDist;
            _length          = _len0 + _len1 + _len2;
            _handle.position = _join2.position + _join2.forward * _len2;
            _handle.SetParent(_root);
            _iniLocalPos = _handle.localPosition;
            _iniModelPos = _handle.position.AsLocalPoint(_model);
            _iniLocalFw  = _handle.localRotation * v3.fw;
            _iniLocalUp  = _handle.localRotation * v3.up;
            _iniLocalRot = _handle.localRotation;
            _iniModelRot = lookAt(_handle.forward.AsLocalDir(_model), _handle.up.AsLocalDir(_model));
            _iniModelFw  = _iniModelRot * v3.fw;
            _iniModelUp  = _iniModelRot * v3.up;
            _lengths     = new[] { _len0, _len1, _len2 };
        }
Esempio n. 8
0
 public float this[FingerName index]
 {
     get { return(fingers[(int)index].Weight); }
     set { fingers[(int)index].Weight = value; }
 }
Esempio n. 9
0
 public abstract bool GetFinger(HandType handType, FingerName finger);
Esempio n. 10
0
 public abstract float GetFingerValue(HandType hand, FingerName finger);