public void Initialize(HandTracker handTracker, IVRMLoadable vrmLoadable) { _handTracker = handTracker; _vrmLoadable = vrmLoadable; _vrmLoadable.VrmLoaded += OnVrmLoaded; _vrmLoadable.VrmDisposing += OnVrmDisposing; }
public ImageBaseHandIkGenerator( MonoBehaviour coroutineResponder, HandTracker handTracker, ImageBaseHandIkGeneratorSetting setting, IVRMLoadable vrmLoadable) : base(coroutineResponder) { _setting = setting; _handTracker = handTracker; vrmLoadable.VrmLoaded += info => { var animator = info.animator; _head = animator.GetBoneTransform(HumanBodyBones.Head); _hips = animator.GetBoneTransform(HumanBodyBones.Hips); var hipsPos = _hips.position; var rightUpperArmPos = animator.GetBoneTransform(HumanBodyBones.RightUpperArm).position; var rightWristPos = animator.GetBoneTransform(HumanBodyBones.RightHand).position; _rightHandHipOffsetWhenNotTrack = rightUpperArmPos + Quaternion.AngleAxis(-aPoseArmDownAngleDeg, Vector3.forward) * (rightWristPos - rightUpperArmPos) - hipsPos + aPoseArmPositionOffset; var leftUpperArmPos = animator.GetBoneTransform(HumanBodyBones.LeftUpperArm).position; var leftWristPos = animator.GetBoneTransform(HumanBodyBones.LeftHand).position; _leftHandHipOffsetWhenNotTrack = leftUpperArmPos + Quaternion.AngleAxis(aPoseArmDownAngleDeg, Vector3.forward) * (leftWristPos - leftUpperArmPos) - hipsPos + aPoseArmPositionOffset; _rightHandRotWhenNotTrack = Quaternion.Euler(0, 0, -aPoseArmDownAngleDeg); _leftHandRotWhenNotTrack = Quaternion.Euler(0, 0, aPoseArmDownAngleDeg); _hasModel = true; }; vrmLoadable.VrmDisposing += () => { _hasModel = false; _head = null; _hips = null; }; }