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); }
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 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 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); } }
public static bool GetNodeStatePropertyQuaternion(Node nodeType, NodeStatePropertyType propertyType, OVRPlugin.Node ovrpNodeType, OVRPlugin.Step stepType, out Quaternion retQuat) { retQuat = Quaternion.identity; switch (propertyType) { case NodeStatePropertyType.Orientation: if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus) { retQuat = OVRPlugin.GetNodePose(ovrpNodeType, stepType).ToOVRPose().orientation; return(true); } #if UNITY_2017_1_OR_NEWER if (GetUnityXRNodeStateQuaternion(nodeType, NodeStatePropertyType.Orientation, out retQuat)) { return(true); } #endif break; } return(false); }
public static bool GetNodeStatePropertyVector3(Node nodeType, NodeStatePropertyType propertyType, OVRPlugin.Node ovrpNodeType, OVRPlugin.Step stepType, out Vector3 retVec) { retVec = Vector3.zero; switch (propertyType) { case NodeStatePropertyType.Acceleration: if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus) { retVec = OVRPlugin.GetNodeAcceleration(ovrpNodeType, stepType).FromFlippedZVector3f(); return(true); } #if UNITY_2017_1_OR_NEWER if (GetUnityXRNodeStateVector3(nodeType, NodeStatePropertyType.Acceleration, out retVec)) { return(true); } #endif break; case NodeStatePropertyType.AngularAcceleration: if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus) { retVec = OVRPlugin.GetNodeAngularAcceleration(ovrpNodeType, stepType).FromFlippedZVector3f(); return(true); } #if UNITY_2017_2_OR_NEWER if (GetUnityXRNodeStateVector3(nodeType, NodeStatePropertyType.AngularAcceleration, out retVec)) { return(true); } #endif break; case NodeStatePropertyType.Velocity: if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus) { retVec = OVRPlugin.GetNodeVelocity(ovrpNodeType, stepType).FromFlippedZVector3f(); return(true); } #if UNITY_2017_1_OR_NEWER if (GetUnityXRNodeStateVector3(nodeType, NodeStatePropertyType.Velocity, out retVec)) { return(true); } #endif break; case NodeStatePropertyType.AngularVelocity: if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus) { retVec = OVRPlugin.GetNodeAngularVelocity(ovrpNodeType, stepType).FromFlippedZVector3f(); return(true); } #if UNITY_2017_2_OR_NEWER if (GetUnityXRNodeStateVector3(nodeType, NodeStatePropertyType.AngularVelocity, out retVec)) { return(true); } #endif break; case NodeStatePropertyType.Position: if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus) { retVec = OVRPlugin.GetNodePose(ovrpNodeType, stepType).ToOVRPose().position; return(true); } #if UNITY_2017_1_OR_NEWER if (GetUnityXRNodeStateVector3(nodeType, NodeStatePropertyType.Position, out retVec)) { return(true); } #endif break; } return(false); }
public static Vector3 GetNodeStateProperty(Node nodeType, NodeStatePropertyType propertyType, OVRPlugin.Node ovrpNodeType, OVRPlugin.Step stepType) { switch (propertyType) { case NodeStatePropertyType.Acceleration: #if UNITY_2017_1_OR_NEWER return(GetUnityXRNodeState(nodeType, NodeStatePropertyType.Acceleration)); #else return(OVRPlugin.GetNodeAcceleration(ovrpNodeType, stepType).FromFlippedZVector3f()); #endif case NodeStatePropertyType.AngularAcceleration: #if UNITY_2017_2_OR_NEWER return(GetUnityXRNodeState(nodeType, NodeStatePropertyType.AngularAcceleration)); #else return(OVRPlugin.GetNodeAngularAcceleration(ovrpNodeType, stepType).FromFlippedZVector3f() * Mathf.Rad2Deg); #endif case NodeStatePropertyType.Velocity: #if UNITY_2017_1_OR_NEWER return(GetUnityXRNodeState(nodeType, NodeStatePropertyType.Velocity)); #else return(OVRPlugin.GetNodeVelocity(ovrpNodeType, stepType).FromFlippedZVector3f()); #endif case NodeStatePropertyType.AngularVelocity: #if UNITY_2017_2_OR_NEWER return(GetUnityXRNodeState(nodeType, NodeStatePropertyType.AngularVelocity)); #else return(OVRPlugin.GetNodeAngularVelocity(ovrpNodeType, stepType).FromFlippedZVector3f() * Mathf.Rad2Deg); #endif } return(Vector3.zero); }
public HandData(OVRPlugin.Step step, OVRPlugin.Hand hand, OVRPlugin.HandState handState) { Step = step; Hand = hand; HandState = handState; }