예제 #1
0
 public static int GetTipParentIndex(OVRPlugin.BoneId tip)
 {
     if (tip == OVRPlugin.BoneId.Hand_ThumbTip || tip == OVRPlugin.BoneId.Hand_MaxSkinnable)
     {
         return((int)OVRPlugin.BoneId.Hand_Thumb3);
     }
     else if (tip == OVRPlugin.BoneId.Hand_IndexTip)
     {
         return((int)OVRPlugin.BoneId.Hand_Index3);
     }
     else if (tip == OVRPlugin.BoneId.Hand_MiddleTip)
     {
         return((int)OVRPlugin.BoneId.Hand_Middle3);
     }
     else if (tip == OVRPlugin.BoneId.Hand_RingTip)
     {
         return((int)OVRPlugin.BoneId.Hand_Ring3);
     }
     else if (tip == OVRPlugin.BoneId.Hand_PinkyTip)
     {
         return((int)OVRPlugin.BoneId.Hand_Pinky3);
     }
     else
     {
         return((int)OVRPlugin.BoneId.Invalid);
     }
 }
예제 #2
0
 public static bool IsDistal(OVRPlugin.BoneId bone)
 {
     if (bone == OVRPlugin.BoneId.Hand_Thumb3)
     {
         return(true);
     }
     else if (bone == OVRPlugin.BoneId.Hand_Index3)
     {
         return(true);
     }
     else if (bone == OVRPlugin.BoneId.Hand_Middle3)
     {
         return(true);
     }
     else if (bone == OVRPlugin.BoneId.Hand_Ring3)
     {
         return(true);
     }
     else if (bone == OVRPlugin.BoneId.Hand_Pinky3)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #3
0
        public static OVRPlugin.BoneId GetTip(OVRPlugin.BoneId bi)
        {
            OVRPlugin.BoneId tip = OVRPlugin.BoneId.Invalid;
            switch (bi)
            {
            case OVRPlugin.BoneId.Hand_Thumb0:
            case OVRPlugin.BoneId.Hand_Thumb1:
            case OVRPlugin.BoneId.Hand_Thumb2:
            case OVRPlugin.BoneId.Hand_Thumb3:
            case OVRPlugin.BoneId.Hand_ThumbTip:
            {
                tip = OVRPlugin.BoneId.Hand_ThumbTip;
                break;
            }

            case OVRPlugin.BoneId.Hand_Index1:
            case OVRPlugin.BoneId.Hand_Index2:
            case OVRPlugin.BoneId.Hand_Index3:
            case OVRPlugin.BoneId.Hand_IndexTip:
            {
                tip = OVRPlugin.BoneId.Hand_IndexTip;
                break;
            }

            case OVRPlugin.BoneId.Hand_Middle1:
            case OVRPlugin.BoneId.Hand_Middle2:
            case OVRPlugin.BoneId.Hand_Middle3:
            case OVRPlugin.BoneId.Hand_MiddleTip:
            {
                tip = OVRPlugin.BoneId.Hand_MiddleTip;
                break;
            }

            case OVRPlugin.BoneId.Hand_Ring1:
            case OVRPlugin.BoneId.Hand_Ring2:
            case OVRPlugin.BoneId.Hand_Ring3:
            case OVRPlugin.BoneId.Hand_RingTip:
            {
                tip = OVRPlugin.BoneId.Hand_RingTip;
                break;
            }

            case OVRPlugin.BoneId.Hand_Pinky0:
            case OVRPlugin.BoneId.Hand_Pinky1:
            case OVRPlugin.BoneId.Hand_Pinky2:
            case OVRPlugin.BoneId.Hand_Pinky3:
            case OVRPlugin.BoneId.Hand_PinkyTip:
            {
                tip = OVRPlugin.BoneId.Hand_PinkyTip;
                break;
            }

            default:
            {
                tip = OVRPlugin.BoneId.Invalid;
                break;
            }
            }
            return(tip);
        }
예제 #4
0
    /// <summary>
    /// Gets the hand id associated with the index finger of the collider passed as parameter, if any
    /// </summary>
    /// <param name="collider">Collider of interest</param>
    /// <returns>0 if the collider represents the finger tip of left hand, 1 if it is the one of right hand, -1 if it is not an index fingertip</returns>
    public int GetFingerHandId(Collider collider, OVRPlugin.BoneId fingerId)
    {
        //Checking Oculus code, it is possible to see that physics capsules gameobjects always end with _CapsuleCollider
        if (collider.gameObject.name.Contains("_CapsuleCollider"))
        {
            //get the name of the bone from the name of the gameobject, and convert it to an enum value
            string           boneName = collider.gameObject.name.Substring(0, collider.gameObject.name.Length - 16);
            OVRPlugin.BoneId boneId   = (OVRPlugin.BoneId)System.Enum.Parse(typeof(OVRPlugin.BoneId), boneName);

            //if it is the tip of the Index
            if (boneId == fingerId)
            {
                //check if it is left or right hand, and change color accordingly.
                //Notice that absurdly, we don't have a way to detect the type of the hand
                //so we have to use the hierarchy to detect current hand
                if (collider.transform.IsChildOf(m_hands[0].hand.transform))
                {
                    return(0);
                }
                else if (collider.transform.IsChildOf(m_hands[1].hand.transform))
                {
                    return(1);
                }
            }
        }

        return(-1);
    }
예제 #5
0
        private IEnumerator AttachTriggerLogic()
        {
            while (!Hands.Instance.IsInitialized())
            {
                yield return(null);
            }

            Hand        properHand  = IsRightHandedTool ? Hands.Instance.RightHand : Hands.Instance.LeftHand;
            HandPhysics handPhysics = properHand.Physics;

            while (!handPhysics.IsInitialized)
            {
                yield return(null);
            }

            OVRPlugin.BoneId boneToTestCollisions = OVRPlugin.BoneId.Hand_Pinky3;
            switch (_fingerToFollow)
            {
            case OVRPlugin.HandFinger.Thumb:
                boneToTestCollisions = OVRPlugin.BoneId.Hand_Thumb3;
                break;

            case OVRPlugin.HandFinger.Index:
                boneToTestCollisions = OVRPlugin.BoneId.Hand_Index3;
                break;

            case OVRPlugin.HandFinger.Middle:
                boneToTestCollisions = OVRPlugin.BoneId.Hand_Middle3;
                break;

            case OVRPlugin.HandFinger.Ring:
                boneToTestCollisions = OVRPlugin.BoneId.Hand_Ring3;
                break;

            default:
                boneToTestCollisions = OVRPlugin.BoneId.Hand_Pinky3;
                break;
            }

            List <BoneCapsuleTriggerLogic> boneCapsuleTriggerLogic = new List <BoneCapsuleTriggerLogic>();
            List <CapsuleInfo>             boneCapsules            = handPhysics.GetCapsulesPerBone(boneToTestCollisions);

            foreach (var ovrCapsuleInfo in boneCapsules)
            {
                var boneCapsuleTrigger = ovrCapsuleInfo.gameObject.AddComponent <BoneCapsuleTriggerLogic>();
                ovrCapsuleInfo.CapsuleCollider.isTrigger = true;
                boneCapsuleTrigger.ToolTags = ToolTags;
                boneCapsuleTriggerLogic.Add(boneCapsuleTrigger);
            }

            _boneCapsuleTriggerLogic = boneCapsuleTriggerLogic.ToArray();
            // finger tip should have only one capsule
            if (boneCapsules.Count > 0)
            {
                _capsuleToTrack = boneCapsules[0];
            }

            _isInitialized = true;
        }
예제 #6
0
 public static bool IsDistalBone(OVRPlugin.BoneId bi)
 {
     return(bi == OVRPlugin.BoneId.Hand_Thumb3 ||
            bi == OVRPlugin.BoneId.Hand_Index3 ||
            bi == OVRPlugin.BoneId.Hand_Middle3 ||
            bi == OVRPlugin.BoneId.Hand_Ring3 ||
            bi == OVRPlugin.BoneId.Hand_Pinky3);
 }
예제 #7
0
 public void Init(Hand hand, OVRPlugin.BoneId bone,
                  Rigidbody rigidBody, CapsuleCollider capsuleCollider)
 {
     Hand              = hand;
     BoneIndex         = bone;
     CapsuleRigidBBody = rigidBody;
     CapsuleCollider   = capsuleCollider;
 }
예제 #8
0
 public static OVRPlugin.BoneId GetDistalBone(OVRPlugin.BoneId bi)
 {
     return(bi == OVRPlugin.BoneId.Hand_ThumbTip ? OVRPlugin.BoneId.Hand_Thumb3 :
            bi == OVRPlugin.BoneId.Hand_IndexTip ? OVRPlugin.BoneId.Hand_Index3 :
            bi == OVRPlugin.BoneId.Hand_MiddleTip ? OVRPlugin.BoneId.Hand_Middle3 :
            bi == OVRPlugin.BoneId.Hand_RingTip ? OVRPlugin.BoneId.Hand_Ring3 :
            bi == OVRPlugin.BoneId.Hand_PinkyTip ? OVRPlugin.BoneId.Hand_Pinky3 :
            OVRPlugin.BoneId.Invalid);
 }
예제 #9
0
        /// <summary>
        /// Return all of the capsules that cover a bone (there can be multiple).
        /// </summary>
        public List <CapsuleInfo> GetCapsulesPerBone(OVRPlugin.BoneId boneId)
        {
            List <CapsuleInfo> capsulesPerBone = new List <CapsuleInfo>();

            foreach (var ovrCapsuleInfo in _capsules)
            {
                if (ovrCapsuleInfo.BoneIndex == boneId)
                {
                    capsulesPerBone.Add(ovrCapsuleInfo);
                }
            }

            return(capsulesPerBone);
        }