private void GetHandState(OVRPlugin.Step step) { if (OVRPlugin.GetHandState(step, (OVRPlugin.Hand)HandType, ref _handState)) { IsTracked = (_handState.Status & OVRPlugin.HandStatus.HandTracked) != 0; IsSystemGestureInProgress = (_handState.Status & OVRPlugin.HandStatus.SystemGestureInProgress) != 0; IsPointerPoseValid = (_handState.Status & OVRPlugin.HandStatus.InputStateValid) != 0; IsDominantHand = (_handState.Status & OVRPlugin.HandStatus.DominantHand) != 0; PointerPose.localPosition = _handState.PointerPose.Position.FromFlippedZVector3f(); PointerPose.localRotation = _handState.PointerPose.Orientation.FromFlippedZQuatf(); HandScale = _handState.HandScale; HandConfidence = (TrackingConfidence)_handState.HandConfidence; IsDataValid = true; IsDataHighConfidence = IsTracked && HandConfidence == TrackingConfidence.High; } else { IsTracked = false; IsSystemGestureInProgress = false; IsPointerPoseValid = false; PointerPose.localPosition = Vector3.zero; PointerPose.localRotation = Quaternion.identity; HandScale = 1.0f; HandConfidence = TrackingConfidence.Low; IsDataValid = false; IsDataHighConfidence = false; } }
private void UpdatePose(OVRPlugin.Step renderStep) { if (!OVRPlugin.GetHandState(renderStep, HandType, ref _currentState)) { IsTracked = false; Confidence = 0; } else { IsTracked = (_currentState.Status & OVRPlugin.HandStatus.HandTracked) == OVRPlugin.HandStatus.HandTracked; if (IsTracked) { Confidence = _currentState.HandConfidence == OVRPlugin.TrackingConfidence.High ? 1 : 0.5f; } else { Confidence = 0; } // Update Pointer _pointer.position = _currentState.PointerPose.Position.FromFlippedZVector3f(); _pointer.rotation = _currentState.PointerPose.Orientation.FromFlippedZQuatf(); // _pointer.PointerStatusValid = // (_currentState.Status & OVRPlugin.HandStatus.InputStateValid) == OVRPlugin.HandStatus.InputStateValid; } UpdateSkeletonPose(_currentState); }
void Update() { try { if (m_Hand == null || !m_Hand.IsTracked || !m_Hand.IsDataHighConfidence) { ChangePinchStateToTrue(TherapyData.PinchType.None); return; } OVRPlugin.GetHandState(OVRPlugin.Step.Physics, whichHand, ref state); //LateralTestsAndPinchDebuging(); if (m_Hand.GetFingerIsPinching(OVRHand.HandFinger.Index)) { OVRPlugin.Quatf index = state.BoneRotations[(int)OVRSkeleton.BoneId.Hand_Index3]; OVRPlugin.Quatf thumb = state.BoneRotations[(int)OVRSkeleton.BoneId.Hand_Thumb3]; float angle = Vector3.Angle(new Vector3(index.x, index.y, index.z), new Vector3(thumb.x, thumb.y, thumb.z)); if (angle < 70) // Tip Pinch { if (m_Hand.GetFingerIsPinching(OVRHand.HandFinger.Middle)) // 3 finger are pinching { ChangePinchStateToTrue(TherapyData.PinchType.Tip3); } else { ChangePinchStateToTrue(TherapyData.PinchType.Tip2); } } else if (angle > 70) // Pad Pinch { if (m_Hand.GetFingerIsPinching(OVRHand.HandFinger.Middle)) // 3 finger are pinching { ChangePinchStateToTrue(TherapyData.PinchType.Pad3); } else { ChangePinchStateToTrue(TherapyData.PinchType.Pad2); } } } else// Not pinching at all { ChangePinchStateToTrue(TherapyData.PinchType.None); } } catch (Exception e) { MainController.PrintToLog(e.ToString(), MainController.LogType.Error); //m_debugText.text = e.ToString(); } }
private float?RetrieveHandScale() { if (IsTracking) { OVRPlugin.Hand handeness = ovrSkeleton.GetSkeletonType() == OVRSkeleton.SkeletonType.HandLeft ? OVRPlugin.Hand.HandLeft : OVRPlugin.Hand.HandRight; OVRPlugin.HandState handState = new OVRPlugin.HandState(); if (OVRPlugin.GetHandState(OVRPlugin.Step.Render, handeness, ref handState)) { return(handState.HandScale); } } return(null); }
private void PollAndSendHandTrackingData(OVRPlugin.Step renderStep, OVRPlugin.Hand handType) { OVRPlugin.HandState handState = default(OVRPlugin.HandState); if (OVRPlugin.GetHandState(renderStep, handType, ref handState)) { try { SendDataUDP(XmlSerialize.Serialize(HandRelatedDataContainer.AsHandData( new HandData(renderStep, handType, handState) ))); } catch (Exception e) { Debug.Log($"Unable to send hand data: {e.ToString()}"); } } }
private void GetHandState(OVRPlugin.Step step) { if (OVRPlugin.GetHandState(step, (OVRPlugin.Hand)HandType, ref _handState)) { IsTracked = (_handState.Status & OVRPlugin.HandStatus.HandTracked) != 0; IsSystemGestureInProgress = (_handState.Status & OVRPlugin.HandStatus.SystemGestureInProgress) != 0; IsPointerPoseValid = (_handState.Status & OVRPlugin.HandStatus.InputStateValid) != 0; PointerPose.localPosition = _handState.PointerPose.Position.FromFlippedZVector3f(); PointerPose.localRotation = _handState.PointerPose.Orientation.FromFlippedZQuatf(); HandScale = _handState.HandScale; HandConfidence = (TrackingConfidence)_handState.HandConfidence; _isInitialized = true; } else { _isInitialized = false; } }
private float GetUpdatedHandScale(Hand hand) { if (IsTracking(hand)) { var skeleton = hand == Hand.left ? _ovrSkeletonLeft : _ovrSkeletonRight; OVRPlugin.Hand handeness = skeleton.GetSkeletonType() == OVRSkeleton.SkeletonType.HandLeft ? OVRPlugin.Hand.HandLeft : OVRPlugin.Hand.HandRight; var handState = hand == Hand.left ? _handStateLeft : _handStateRight; if (OVRPlugin.GetHandState(OVRPlugin.Step.Render, handeness, ref handState)) { return(handState.HandScale); } else { return(1f); } } else { return(1f); } }
private void UpdatePose(OVRPlugin.Step renderStep) { OVRPlugin.Hand h = OVRPlugin.Hand.HandRight; if (m_controller == OVRInput.Controller.LTouch) { h = OVRPlugin.Hand.HandLeft; } if (!OVRPlugin.GetHandState(renderStep, h, ref _currentState)) { IsTracked = false; } else { IsTracked = (_currentState.Status & OVRPlugin.HandStatus.HandTracked) == OVRPlugin.HandStatus.HandTracked; } if (!IsTracked) { transform.GetChild(0).gameObject.SetActive(true); UpdateCapTouchStates(); m_pointBlend = InputValueRateChange(m_isPointing, m_pointBlend); m_thumbsUpBlend = InputValueRateChange(m_isGivingThumbsUp, m_thumbsUpBlend); float flex = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, m_controller); bool collisionEnabled = m_grabber.grabbedObject == null && flex >= THRESH_COLLISION_FLEX; CollisionEnable(collisionEnabled); UpdateAnimStates(); } else { transform.GetChild(0).gameObject.SetActive(false); } }
private void GetHandState(OVRPlugin.Step step) { if (OVRPlugin.GetHandState(step, (OVRPlugin.Hand)HandType, ref _handState)) { IsTracked = (_handState.Status & OVRPlugin.HandStatus.HandTracked) != 0; IsSystemGestureInProgress = (_handState.Status & OVRPlugin.HandStatus.SystemGestureInProgress) != 0; IsPointerPoseValid = (_handState.Status & OVRPlugin.HandStatus.InputStateValid) != 0; PointerPose.localPosition = _handState.PointerPose.Position.FromFlippedZVector3f(); PointerPose.localRotation = _handState.PointerPose.Orientation.FromFlippedZQuatf(); HandScale = _handState.HandScale; HandConfidence = (TrackingConfidence)_handState.HandConfidence; _isInitialized = true; } else { #if UNITY_EDITOR //in editor don't change _isInitialized - this could cause feeders adding data at invalid moment (depending on call order) - which will result in no hands being visible return; #endif _isInitialized = false; } }
private void UpdatePose(OVRPlugin.Step renderStep) { if (!OVRPlugin.GetHandState(renderStep, HandType, ref _currentState)) { IsTracked = false; HandConfidence = Hand.HandTrackingConfidence.None; ScaledAlpha = _confidenceFader.NextAlphaValue(HandConfidence); } else { IsTracked = (_currentState.Status & OVRPlugin.HandStatus.HandTracked) == OVRPlugin.HandStatus.HandTracked; if (IsTracked) { HandConfidence = OVRPluginConfidenceToHand(_currentState.HandConfidence); } else { HandConfidence = Hand.HandTrackingConfidence.None; } // Fade hand according to confidence. ScaledAlpha = _confidenceFader.NextAlphaValue(HandConfidence); // Update Pointer _pointer.PointerPosition = _currentState.PointerPose.Position.FromFlippedZVector3f(); _pointer.PointerOrientation = _currentState.PointerPose.Orientation.FromFlippedZQuatf(); _pointer.PointerStatusValid = (_currentState.Status & OVRPlugin.HandStatus.InputStateValid) == OVRPlugin.HandStatus.InputStateValid; } if (HandMesh) { HandMesh.UpdatePose(); } if (Skeleton) { Skeleton.UpdatePose(_currentState); } }
void Update() { data.Length = 0; OVRInput.Controller activeController = OVRInput.GetActiveController(); string activeControllerName = activeController.ToString(); data.AppendFormat("Active: {0}\n", activeControllerName); string connectedControllerNames = OVRInput.GetConnectedControllers().ToString(); data.AppendFormat("Connected: {0}\n", connectedControllerNames); data.AppendFormat("PrevConnected: {0}\n", prevConnected); controllers.Update(); controllers.AppendToStringBuilder(ref data); prevConnected = connectedControllerNames; Vector3 pos = OVRInput.GetLocalControllerPosition(activeController); data.AppendFormat("Position: ({0:F2}, {1:F2}, {2:F2})\n", pos.x, pos.y, pos.z); Quaternion rot = OVRInput.GetLocalControllerRotation(activeController); data.AppendFormat("Orientation: ({0:F2}, {1:F2}, {2:F2}, {3:F2})\n", rot.x, rot.y, rot.z, rot.w); data.AppendFormat("HandTrackingEnabled: {0}\n", OVRPlugin.GetHandTrackingEnabled()); bool result_hs_LH = OVRPlugin.GetHandState(OVRPlugin.Step.Render, OVRPlugin.Hand.HandLeft, ref hs_LH); data.AppendFormat("LH HS Query Res: {0}\n", result_hs_LH); data.AppendFormat("LH HS Status: {0}\n", hs_LH.Status); data.AppendFormat("LH HS Pose: {0}\n", hs_LH.RootPose); data.AppendFormat("LH HS HandConf: {0}\n", hs_LH.HandConfidence); bool result_hs_RH = OVRPlugin.GetHandState(OVRPlugin.Step.Render, OVRPlugin.Hand.HandRight, ref hs_RH); data.AppendFormat("RH HS Query Res: {0}\n", result_hs_RH); data.AppendFormat("RH HS Status: {0}\n", hs_RH.Status); data.AppendFormat("RH HS Pose: {0}\n", hs_RH.RootPose); data.AppendFormat("RH HS HandConf: {0}\n", hs_RH.HandConfidence); data.AppendFormat("LH Skel Query Res: {0}\n", result_skel_LH); data.AppendFormat("LH Skel Type: {0}\n", skel_LH.Type); data.AppendFormat("LH Skel NumBones: {0}\n", skel_LH.NumBones); data.AppendFormat("RH Skel Query Res: {0}\n", result_skel_RH); data.AppendFormat("RH Skel Type: {0}\n", skel_RH.Type); data.AppendFormat("RH Skel NumBones: {0}\n", skel_RH.NumBones); data.AppendFormat("LH Mesh Query Res: {0}\n", result_mesh_LH); data.AppendFormat("LH Mesh Type: {0}\n", mesh_LH.Type); data.AppendFormat("LH Mesh NumVers: {0}\n", mesh_LH.NumVertices); data.AppendFormat("RH Mesh Query Res: {0}\n", result_mesh_RH); data.AppendFormat("RH Mesh Type: {0}\n", mesh_RH.Type); data.AppendFormat("RH Mesh NumVers: {0}\n", mesh_RH.NumVertices); for (int i = 0; i < monitors.Count; i++) { monitors[i].Update(); monitors[i].AppendToStringBuilder(ref data); } if (uiText != null) { uiText.text = data.ToString(); } }