void Update() { if (handInterface != null) { if (hideWithInterface) { SetVisibility(handInterface.ShowHand()); } if (!testFingers) { boneRotationValues = handInterface.GetValues(); } } if (isVisible) { SetTracked(); SetPhysics(); if ((resetOnPositionOffset && wristPosOffset > maxPosOffsetValue) || (resetOnRotationOffset && wristRotOffset > maxRotOffsetValue)) { SnapToTracked(); } } }
public HandBoneValues GetValues() { HandBoneValues providedData = default; var data = DataProvider.GetSkeletonPoseData(); goodData = (!hideWhenDataIsNotValid || data.IsDataValid) && (!hideWhenDataIsNotHighConfidence || data.IsDataHighConfidence); if (goodData) { List <HandBoneValues.BoneRotValue> retrievedData = new List <HandBoneValues.BoneRotValue>(); BoneId[] allBoneIds = (BoneId[])System.Enum.GetValues(typeof(BoneId)); for (int i = 0; i < allBoneIds.Length; i++) { if (i < (int)BoneId.Hand_MaxSkinnable) { var currentBoneId = allBoneIds[i]; retrievedData.Add(new HandBoneValues.BoneRotValue() { id = currentBoneId, //localRotation = data.BoneRotations[(int)currentBoneId].FromFlippedZQuatf() //Maybe this or the FromQuatf function can be used for blender models? localRotation = data.BoneRotations[(int)currentBoneId].FromFlippedXQuatf() * ((currentBoneId == BoneId.Hand_WristRoot) ? wristFixupRotation : Quaternion.identity) }); } } providedData.bones = retrievedData.ToArray(); } return(providedData); }
void Update() { if (handInterface != null && !testFingers) { boneRotationValues = handInterface.GetValues(); } SetTracked(); SetPhysics(); if ((resetOnPositionOffset && wristPosOffset > maxPosOffsetValue) || (resetOnRotationOffset && wristRotOffset > maxRotOffsetValue)) { SnapToTracked(); } }
public HandBoneValues GetValues() { HandBoneValues providedData = default; float thumbValue = 0; float indexValue = 0; float gripValue = 0; #region Get values from controllers if (handType == OVRHand.Hand.HandLeft) { thumbValue = OVRInput.Get(OVRInput.RawNearTouch.LThumbButtons, OVRInput.Controller.All) ? 1 : 0; if (indexFromNearTouch) { indexValue = OVRInput.Get(OVRInput.RawNearTouch.LIndexTrigger, OVRInput.Controller.All) ? 1 : 0; } else { indexValue = OVRInput.Get(OVRInput.RawAxis1D.LIndexTrigger, OVRInput.Controller.All); } gripValue = OVRInput.Get(OVRInput.RawAxis1D.LHandTrigger, OVRInput.Controller.All); } else if (handType == OVRHand.Hand.HandRight) { thumbValue = OVRInput.Get(OVRInput.RawNearTouch.RThumbButtons, OVRInput.Controller.All) ? 1 : 0; if (indexFromNearTouch) { indexValue = OVRInput.Get(OVRInput.RawNearTouch.RIndexTrigger, OVRInput.Controller.All) ? 1 : 0; } else { indexValue = OVRInput.Get(OVRInput.RawAxis1D.RIndexTrigger, OVRInput.Controller.All); } gripValue = OVRInput.Get(OVRInput.RawAxis1D.RHandTrigger, OVRInput.Controller.All); } #endregion #region Lerp values if (lerpThumb) { thumbValue = Mathf.Lerp(previousThumbValue, thumbValue, Time.deltaTime * thumbLerp); previousThumbValue = thumbValue; } if (lerpIndex) { indexValue = Mathf.Lerp(previousIndexValue, indexValue, Time.deltaTime * indexLerp); previousIndexValue = indexValue; } if (lerpGrip) { gripValue = Mathf.Lerp(previousGripValue, gripValue, Time.deltaTime * gripLerp); previousGripValue = gripValue; } #endregion #region Spread values across knuckles var thumbKnuckleValues = SpreadValue(thumbValue, 3); var indexKnuckleValues = SpreadValue(indexValue, 3); var gripKnuckleValues = SpreadValue(gripValue, 3); #endregion #region Create returned data providedData.bones = new HandBoneValues.BoneRotValue[] { new HandBoneValues.BoneRotValue() { id = BoneId.Hand_WristRoot, localRotation = Quaternion.Euler(wristEuler) }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Thumb1, value = thumbKnuckleValues[0] * (pinchOnClose ? THUMB_PINCH[0] : THUMB_CLOSE[0]) }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Thumb2, value = thumbKnuckleValues[1] * (pinchOnClose ? THUMB_PINCH[1] : THUMB_CLOSE[1]) }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Thumb3, value = thumbKnuckleValues[2] * (pinchOnClose ? THUMB_PINCH[2] : THUMB_CLOSE[2]) }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Index1, value = indexKnuckleValues[0] * (pinchOnClose ? INDEX_PINCH[0] : 1) }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Index2, value = indexKnuckleValues[1] * (pinchOnClose ? INDEX_PINCH[1] : 1) }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Index3, value = indexKnuckleValues[2] * (pinchOnClose ? INDEX_PINCH[2] : 1) }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Middle1, value = gripKnuckleValues[0] }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Middle2, value = gripKnuckleValues[1] }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Middle3, value = gripKnuckleValues[2] }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Ring1, value = gripKnuckleValues[0] }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Ring2, value = gripKnuckleValues[1] }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Ring3, value = gripKnuckleValues[2] }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Pinky1, value = gripKnuckleValues[0] }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Pinky2, value = gripKnuckleValues[1] }, new HandBoneValues.BoneRotValue() { id = BoneId.Hand_Pinky3, value = gripKnuckleValues[2] }, }; #endregion return(providedData); }