protected virtual void ResetFingerRotation(FingerBones fBones) { for (int i = 0; i < QuickHumanTrait.NUM_BONES_PER_FINGER; i++) { fBones[i].localRotation = Quaternion.identity; } }
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); } } }
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); }
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); } }
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)); }
public static Transform GetFingerBone(HandTarget handTarget, Finger finger, FingerBones bone) { return(GetFingerBone(handTarget.humanoid.avatarRig, handTarget.isLeft, finger, bone)); }