public static OVRPlugin.SkeletonType GetSkeletonTypeFromHandType(OVRPlugin.Hand hand) { return(hand == OVRPlugin.Hand.HandLeft ? OVRPlugin.SkeletonType.HandLeft : hand == OVRPlugin.Hand.HandRight ? OVRPlugin.SkeletonType.HandRight : OVRPlugin.SkeletonType.None); }
public static OVRPlugin.MeshType GetHandMeshTypeFromOVRHandType(OVRPlugin.Hand hand) { return(hand == OVRPlugin.Hand.HandLeft ? OVRPlugin.MeshType.HandLeft : hand == OVRPlugin.Hand.HandRight ? OVRPlugin.MeshType.HandRight : OVRPlugin.MeshType.None); }
internal void SetHand(string hand) { switch (hand.ToLower()) { case "left": if (rightGrabber != null && leftGrabber != null) { rightGrabber.enabled = false; leftGrabber.enabled = true; } whichHand = OVRPlugin.Hand.HandLeft; m_Hand = m_LeftHand; break; case "right": if (rightGrabber != null && leftGrabber != null) { leftGrabber.enabled = false; rightGrabber.enabled = true; } whichHand = OVRPlugin.Hand.HandRight; m_Hand = m_RightHand; break; default: MainController.PrintToLog("Hand wasn't set correctly.", MainController.LogType.Error); SetHand("Right"); break; } }
public void InitHand(OVRPlugin.Hand hand) { var handReflection = GetHandReflection(hand); var _pointerPoseGO = new GameObject(); handReflection.PointerPoseGo.Set(_pointerPoseGO); handReflection.PointerPose.Set(_pointerPoseGO.transform); }
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 IEnumerator InitializeMeshAndSend(OVRPlugin.Hand hand) { var meshType = GetHandMeshTypeFromOVRHandType(hand); if (OVRPlugin.GetMesh(meshType, out var mesh)) { try { var meshDataJson = XmlSerialize.Serialize(HandRelatedDataContainer.AsMeshData( new MeshData(meshType, mesh) )); StartCoroutine(SendDataTCP(meshDataJson)); //mesh data is too big for single UDP packet } catch (Exception e) { Debug.LogError($"Unable to send mesh data: {e.ToString()}"); } } yield return(new WaitForSeconds(WaitNSecondsBetweenHandDataInitializationIfNotReady)); }
private OVRHandReflection GetHandReflection(OVRPlugin.Hand hand) { OVRHandReflection handReflection; switch (hand) { case OVRPlugin.Hand.HandLeft: handReflection = _leftHandReflection; break; case OVRPlugin.Hand.HandRight: handReflection = _rightHandReflection; break; case OVRPlugin.Hand.None: default: throw new ArgumentOutOfRangeException(); } return(handReflection); }
private IEnumerator InitializeSkeletonAndSend(OVRPlugin.Hand hand) { var skeletonType = GetSkeletonTypeFromHandType(hand); if (OVRPlugin.GetSkeleton(skeletonType, out var skeleton)) { try { var skeletonDataJson = XmlSerialize.Serialize(HandRelatedDataContainer.AsSkeletonData( new SkeletonData(skeleton, skeletonType) )); StartCoroutine(SendDataTCP(skeletonDataJson)); //skeleton data is too big for single UDP packet yield break; } catch (Exception e) { Debug.Log($"Unable to send skeleton ({hand.ToString()})data: {e.ToString()}"); } } yield return(new WaitForSeconds(WaitNSecondsBetweenHandDataInitializationIfNotReady)); }
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); } }
public HandData(OVRPlugin.Step step, OVRPlugin.Hand hand, OVRPlugin.HandState handState) { Step = step; Hand = hand; HandState = handState; }