/*--------------------------------------------------------------------------------------------*/ 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); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private ICursorDataForInput GetData(HoverCursorDataProvider pCursorDataProv) { if (!pCursorDataProv.HasCursorData(Type)) { return(null); } return(pCursorDataProv.GetCursorDataForInput(Type)); }
/*--------------------------------------------------------------------------------------------*/ 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); }