/*--------------------------------------------------------------------------------------------*/ protected virtual void UpdateCursorsWithFinger(Hand pLeapHand, Finger pLeapFinger) { CursorType cursorType = GetFingerCursorType(pLeapHand.IsLeft, pLeapFinger.Type); if (!CursorDataProvider.HasCursorData(cursorType)) { return; } Bone distalBone = pLeapFinger.Bone(Bone.BoneType.TYPE_DISTAL); Vector3 tipWorldPos = pLeapFinger.TipPosition.ToVector3(); Vector3 boneWorldPos = distalBone.Center.ToVector3(); Vector3 extendedWorldPos = tipWorldPos; if (ExtendFingertipDistance != 0) { extendedWorldPos += (tipWorldPos - boneWorldPos).normalized * ExtendFingertipDistance; } ICursorDataForInput data = CursorDataProvider.GetCursorDataForInput(cursorType); data.SetWorldPosition(extendedWorldPos); data.SetWorldRotation(distalBone.Basis.CalculateRotation() * RotationFix); data.SetSize(pLeapFinger.Width); data.SetUsedByInput(true); }
/*--------------------------------------------------------------------------------------------*/ private void UpdateDataForSize(ICursorDataForInput pData, HoverInputVive.ControlState pState) { float prog = GetInputSourceProgress(CursorSizeInput, pState, 0.5f); pData.SetSize(Mathf.Lerp(MinSize, MaxSize, prog)); }
/*--------------------------------------------------------------------------------------------*/ protected virtual void UpdateCursorsWithFinger(Hand pLeapHand, Finger pLeapFinger) { CursorType cursorType = GetFingerCursorType(pLeapHand.IsLeft, pLeapFinger.Type); if (!CursorDataProvider.HasCursorData(cursorType)) { return; } Transform leapTx = LeapControl.transform; Vector tipPos = (UseStabilizedPositions ? pLeapFinger.StabilizedTipPosition: pLeapFinger.TipPosition); Bone distalBone = pLeapFinger.Bone(Bone.BoneType.TYPE_DISTAL); Vector3 tipWorldPos = leapTx.TransformPoint(tipPos.ToUnityScaled()); Vector3 boneWorldPos = leapTx.TransformPoint(distalBone.Center.ToUnityScaled()); Vector3 extendedWorldPos = tipWorldPos; if (ExtendFingertipDistance != 0) { extendedWorldPos += (tipWorldPos - boneWorldPos).normalized * ExtendFingertipDistance; } ICursorDataForInput data = CursorDataProvider.GetCursorDataForInput(cursorType); data.SetWorldPosition(extendedWorldPos); data.SetWorldRotation(leapTx.rotation * distalBone.Basis.Rotation() * RotationFix); data.SetSize(pLeapFinger.Width * UnityVectorExtension.INPUT_SCALE); data.SetUsedByInput(true); }
/*--------------------------------------------------------------------------------------------*/ private void UpdateCursorWithDevice(Transform pDeviceTx, SteamVR_Controller.Device pDevice, Info pInfo, CursorType pCursorType) { if (!CursorDataProvider.HasCursorData(pCursorType)) { return; } ICursorDataForInput data = CursorDataProvider.GetCursorDataForInput(pCursorType); data.SetUsedByInput(pDevice.valid); if (!pDevice.valid) { return; } Vector2 touchAxis = pDevice.GetAxis(EVRButtonId.k_EButton_SteamVR_Touchpad); Vector2 triggerAxis = pDevice.GetAxis(EVRButtonId.k_EButton_SteamVR_Trigger); bool isTouch = pDevice.GetTouch(EVRButtonId.k_EButton_SteamVR_Touchpad); float sizeProg = (isTouch ? touchAxis.x * 2 + 1 : 0.5f); Vector3 worldOffset = pDeviceTx.TransformVector(pInfo.LocalPosition); data.SetWorldPosition(pDeviceTx.position + worldOffset); data.SetWorldRotation(pDeviceTx.rotation * Quaternion.Euler(pInfo.LocalRotation)); data.SetSize(Mathf.Lerp(pInfo.MinSize, pInfo.MaxSize, sizeProg)); data.SetTriggerStrength(triggerAxis.x); }
/*--------------------------------------------------------------------------------------------*/ protected virtual void UpdateCursorsWithPalm(Hand pLeapHand) { CursorType cursorType = (pLeapHand.IsLeft ? CursorType.LeftPalm : CursorType.RightPalm); if (!CursorDataProvider.HasCursorData(cursorType)) { return; } Vector palmPos = (UseStabilizedPositions ? pLeapHand.StabilizedPalmPosition : pLeapHand.PalmPosition); ICursorDataForInput data = CursorDataProvider.GetCursorDataForInput(cursorType); data.SetWorldPosition(palmPos.ToVector3()); data.SetWorldRotation(pLeapHand.Basis.CalculateRotation() * RotationFix); data.SetSize(pLeapHand.PalmWidth); data.SetTriggerStrength(pLeapHand.GrabStrength); data.SetUsedByInput(true); }
/*--------------------------------------------------------------------------------------------*/ protected virtual void UpdateCursorsWithPalm(Hand pLeapHand) { CursorType cursorType = (pLeapHand.IsLeft ? CursorType.LeftPalm : CursorType.RightPalm); if (!CursorDataProvider.HasCursorData(cursorType)) { return; } Transform leapTx = LeapControl.transform; Vector palmPos = (UseStabilizedPositions ? pLeapHand.StabilizedPalmPosition : pLeapHand.PalmPosition); ICursorDataForInput data = CursorDataProvider.GetCursorDataForInput(cursorType); data.SetWorldPosition(leapTx.TransformPoint(palmPos.ToUnityScaled())); data.SetWorldRotation(leapTx.rotation * pLeapHand.Basis.Rotation() * RotationFix); data.SetSize(pLeapHand.PalmWidth * UnityVectorExtension.INPUT_SCALE); data.SetTriggerStrength(pLeapHand.GrabStrength); data.SetUsedByInput(true); }