コード例 #1
0
 protected virtual void ResetFingerRotation(FingerBones fBones)
 {
     for (int i = 0; i < QuickHumanTrait.NUM_BONES_PER_FINGER; i++)
     {
         fBones[i].localRotation = Quaternion.identity;
     }
 }
コード例 #2
0
        protected virtual void UpdateFingers()
        {
            for (int i = 0; i < 5; i++)
            {
                QuickHumanFingers f      = _humanFingers[i];
                FingerBones       fBones = _fingerBoneTransforms[f];
                QuickFingerPose   fPose  = new QuickFingerPose();

                //Close factor
                for (int j = 0; j < 3; j++)
                {
                    if (i == 0 && _blendThumbUp > 0)
                    {
                        fPose.SetCloseFactor(j, Mathf.Lerp(_handPoseNeutral[i].GetCloseFactor(j), _handPoseThumbUp[i].GetCloseFactor(j), _blendThumbUp));
                    }
                    else if (i == 1 && _blendPoint > 0)
                    {
                        fPose.SetCloseFactor(j, Mathf.Lerp(_handPoseNeutral[i].GetCloseFactor(j), 0, _blendPoint));
                    }
                    else
                    {
                        fPose.SetCloseFactor(j, Mathf.Lerp(_handPoseNeutral[i].GetCloseFactor(j), _handPoseClosed[i].GetCloseFactor(j), _closeFactor));
                    }
                }

                //Separation factor
                if (i == 0 && _blendThumbUp > 0)
                {
                    fPose._separation = Mathf.Lerp(_handPoseNeutral[i]._separation, _handPoseThumbUp[i]._separation, _blendThumbUp);
                }
                else
                {
                    fPose._separation = Mathf.Lerp(_handPoseNeutral[i]._separation, _handPoseClosed[i]._separation, _closeFactor);
                }

                if (fBones.CheckTransforms())
                {
                    ResetFingerRotation(fBones);
                    UpdateFingerClose(f, fPose, fBones);
                    UpdateFingerSeparation(f, fPose, fBones);
                }
            }
        }
コード例 #3
0
        protected virtual void UpdateFingerSeparation(QuickHumanFingers f, QuickFingerPose fPose, FingerBones fBones)
        {
            Vector3 rotAxis  = fBones.GetRotAxisSeparate();
            float   t        = (fPose._separation + 1) / 2.0f;
            float   maxAngle = GetMaxAngleSeparation(f);
            float   rotAngle = Mathf.Lerp(-maxAngle, maxAngle, t);

            fBones[0].Rotate(rotAxis, rotAngle, Space.Self);
        }
コード例 #4
0
        protected virtual void UpdateFingerClose(QuickHumanFingers f, QuickFingerPose fPose, FingerBones fBones)
        {
            Vector3 rotAxis = fBones.GetRotAxisClose();

            GetAngleLimitsClose(f, out float minAngle, out float maxAngle);

            for (int i = 0; i < 3; i++)
            {
                float rotAngle = Mathf.Lerp(minAngle, maxAngle, fPose.GetCloseFactor(i));
                fBones[i].Rotate(rotAxis, rotAngle, Space.Self);
            }
        }
コード例 #5
0
        public static Transform GetFingerBone(Animator rig, bool isLeft, Finger finger, FingerBones bone)
        {
            if (rig == null)
            {
                return(null);
            }

            int offset = 0;

            if (isLeft)
            {
                offset = 24;
            }
            else
            {
                offset = 39;
            }

            offset += (int)finger * 3 + (int)bone;

            return(rig.GetBoneTransform((HumanBodyBones)offset));
        }
コード例 #6
0
 public static Transform GetFingerBone(HandTarget handTarget, Finger finger, FingerBones bone)
 {
     return(GetFingerBone(handTarget.humanoid.avatarRig, handTarget.isLeft, finger, bone));
 }