private bool ThumbDetected() { //※メモ 親指は他の指と異なり特殊でまっすぐ伸びているか?の判定+親指の向きで判定する。 var jointedHand = HandJointUtils.FindHand(handType); //Get TargetHamd if (jointedHand.TryGetJoint(TrackedHandJoint.Palm, out MixedRealityPose PalmPose)) { MixedRealityPose ThumbTipPose, ThumbDistalPose, ThumbProximalPose; //Get finger Joint Deta if (jointedHand.TryGetJoint(TrackedHandJoint.ThumbTip, out ThumbTipPose) && jointedHand.TryGetJoint(TrackedHandJoint.ThumbDistalJoint, out ThumbDistalPose) && jointedHand.TryGetJoint(TrackedHandJoint.ThumbProximalJoint, out ThumbProximalPose)) { Vector3 finger1 = ThumbProximalPose.Position - PalmPose.Position; Vector3 finger2 = ThumbDistalPose.Position - ThumbProximalPose.Position; Vector3 finger3 = ThumbTipPose.Position - ThumbProximalPose.Position; float c = Vector3.Angle(PalmPose.Position, finger1); float d = Vector3.Angle(finger1, finger2); float e = Vector3.Angle(finger2, finger3); float aba = (Mathf.Abs(d) + Mathf.Abs(e) / 2); text.text = aba.ToString(); if (aba < thumbThreshold) { return(true); } } } return(false); }
private bool middlefingerDetected() { var jointedHand = HandJointUtils.FindHand(handType); if (jointedHand.TryGetJoint(TrackedHandJoint.Palm, out MixedRealityPose PalmPose)) { MixedRealityPose middleTipsPose, middleDistalPose, middleKnucklePose, middleMiddlePose; if (jointedHand.TryGetJoint(TrackedHandJoint.MiddleTip, out middleTipsPose) && jointedHand.TryGetJoint(TrackedHandJoint.MiddleDistalJoint, out middleDistalPose) && jointedHand.TryGetJoint(TrackedHandJoint.MiddleKnuckle, out middleKnucklePose) && jointedHand.TryGetJoint(TrackedHandJoint.MiddleMiddleJoint, out middleMiddlePose)) { Vector3 finger1 = middleKnucklePose.Position - PalmPose.Position; Vector3 finger2 = middleMiddlePose.Position - middleKnucklePose.Position; Vector3 finger3 = middleDistalPose.Position - middleMiddlePose.Position; Vector3 finger4 = middleTipsPose.Position - middleDistalPose.Position; float c = Vector3.Angle(PalmPose.Position, finger1); float d = Vector3.Angle(finger1, finger2); float e = Vector3.Angle(finger2, finger3); float f = Vector3.Angle(finger3, finger4); float aba = (Mathf.Abs(d) + Mathf.Abs(e) + Mathf.Abs(f)) / 3; if (aba < middleThreshold) { return(true); } } } return(false); }
// Update is called once per frame void Update() { if (HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexKnuckle, hs.leftHanded ? Handedness.Left : Handedness.Right, out MixedRealityPose po1) && HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexTip, hs.leftHanded ? Handedness.Left : Handedness.Right, out MixedRealityPose po2) && HandJointUtils.TryGetJointPose(TrackedHandJoint.PinkyKnuckle, hs.leftHanded ? Handedness.Left : Handedness.Right, out MixedRealityPose po3) && HandJointUtils.TryGetJointPose(TrackedHandJoint.ThumbTip, hs.leftHanded ? Handedness.Left : Handedness.Right, out MixedRealityPose po4) && HandJointUtils.TryGetJointPose(TrackedHandJoint.ThumbProximalJoint, hs.leftHanded ? Handedness.Left : Handedness.Right, out MixedRealityPose po5)) { locked = hs.locked; if (!locked) { // Set to green material (unlocked) GetComponent <MeshRenderer>().material = unlockedMaterial; // Set plane position to hand pos = po1.Position; transform.position = pos; // Set rotation of plane Vector3 a = po2.Position - po1.Position; Vector3 b = po3.Position - po1.Position; normal = Vector3.Cross(a, b).normalized; transform.up = normal; plane = new Plane(normal, pos); } else { // Set to red material (locked) GetComponent <MeshRenderer>().material = lockedMaterial; transform.position = pos + plane.GetDistanceToPoint(po1.Position) * normal.normalized; } } }
private bool indexfingerDetected() { var jointedHand = HandJointUtils.FindHand(handType); if (jointedHand.TryGetJoint(TrackedHandJoint.Palm, out MixedRealityPose PalmPose)) { //各関節のpose MixedRealityPose indexTipPose, indexDistalPose, IndexKnucklePose, indexMiddlePose; if (jointedHand.TryGetJoint(TrackedHandJoint.IndexTip, out indexTipPose) && jointedHand.TryGetJoint(TrackedHandJoint.IndexDistalJoint, out indexDistalPose) && jointedHand.TryGetJoint(TrackedHandJoint.IndexMiddleJoint, out indexMiddlePose) && jointedHand.TryGetJoint(TrackedHandJoint.IndexKnuckle, out IndexKnucklePose)) { Vector3 finger1 = IndexKnucklePose.Position - PalmPose.Position; Vector3 finger2 = indexMiddlePose.Position - IndexKnucklePose.Position; Vector3 finger3 = indexDistalPose.Position - indexMiddlePose.Position; Vector3 finger4 = indexTipPose.Position - indexDistalPose.Position; float c = Vector3.Angle(PalmPose.Position, finger1); float d = Vector3.Angle(finger1, finger2); float e = Vector3.Angle(finger2, finger3); float f = Vector3.Angle(finger3, finger4); float aba = (Mathf.Abs(d) + Mathf.Abs(e) + Mathf.Abs(f)) / 3; if (aba < indexThreshold) { return(true); } } } return(false); }
private void SetTransform(TrackedHandJoint joint, Transform toBindTo, Handedness handedness = Handedness.Left) { if (HandJointUtils.TryGetJointPose(joint, handedness, out MixedRealityPose trackedDigit)) { toBindTo.position = trackedDigit.Position; toBindTo.rotation = trackedDigit.Rotation; } }
public void Update() { if (HandJointUtils.TryGetJointPose(TrackedHandJoint.Wrist, Handedness.Any, out MixedRealityPose pose)) { Vector3 positionOfWrist = pose.Position; IMixedRealityHand whichHand = HandJointUtils.FindHand(Handedness.Any); } }
void Update() { if (PhotonNetwork.IsConnected) { if (_deskzone.IsInside) { if (_pointer != null && _pointer.enabled) { _pointer.enabled = !_pointer.enabled; PhotonNetwork.RaiseEvent((byte)TargetManager.EventCode.POINTING, null, RaiseEventOptions.Default, SendOptions.SendReliable); } HandleWarpzoneGazing(); } else { if (!_deskzone.IsInside && Input.GetKey(KeyCode.Mouse0) && HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexMiddleJoint, Handedness.Right, out MixedRealityPose pose)) { var startPos = pose.Position; var endPos = startPos + 50 * pose.Forward; if (_pointer == null) { var go = new GameObject("Pointer"); go.transform.parent = transform; go.transform.localPosition = Vector3.zero; _pointer = go.AddComponent <LineRenderer>(); _pointer.endWidth = 0.05f; _pointer.startWidth = 0.05f; _pointer.material = PointingMaterial; _pointer.SetPosition(0, startPos); _pointer.SetPosition(1, endPos); } _pointer.SetPosition(0, Vector3.Lerp(_pointer.GetPosition(0), startPos, 0.05f)); _pointer.SetPosition(1, Vector3.Lerp(_pointer.GetPosition(1), endPos, 0.05f)); PhotonNetwork.RaiseEvent((byte)TargetManager.EventCode.POINTING, new object[] { PhotonNetwork.LocalPlayer.ActorNumber, _virtualCity.transform.InverseTransformPoint(startPos), _virtualCity.transform.InverseTransformPoint(endPos) }, RaiseEventOptions.Default, SendOptions.SendReliable); _pointer.enabled = true; } else { if (_pointer != null && _pointer.enabled) { _pointer.enabled = !_pointer.enabled; PhotonNetwork.RaiseEvent((byte)TargetManager.EventCode.POINTING, new object[] { PhotonNetwork.LocalPlayer.ActorNumber }, RaiseEventOptions.Default, SendOptions.SendReliable); } } } HandleWarpzoneMoving(); } }
/// <summary> /// Returns curl of thumb finger ranging from 0 to 1. 1 if thumb finger curled/closer to wrist. 0 if the finger is not curled. /// </summary> /// <param name="handedness">Handedness to query joint pose against.</param> /// <returns> Float ranging from 0 to 1. 0 if thumb finger is straight/not curled, 1 if thumb finger is curled</returns> public static float ThumbFingerCurl(Handedness handedness) { if (HandJointUtils.TryGetJointPose(TrackedHandJoint.PinkyKnuckle, handedness, out var pinkyKnuckle) && HandJointUtils.TryGetJointPose(TrackedHandJoint.ThumbTip, handedness, out var thumbTip) && HandJointUtils.TryGetJointPose(TrackedHandJoint.ThumbProximalJoint, handedness, out var thumbKnuckle)) { return(CalculateCurl(pinkyKnuckle.Position, thumbKnuckle.Position, thumbTip.Position)); } return(0.0f); }
/// <summary> /// Returns curl of pinky finger ranging from 0 to 1. 1 if pinky finger curled/closer to wrist. 0 if the finger is not curled. /// </summary> /// <param name="handedness">Handedness to query joint pose against.</param> /// <returns> Float ranging from 0 to 1. 0 if pinky finger is straight/not curled, 1 if pinky finger is curled</returns> public static float PinkyFingerCurl(Handedness handedness) { if (HandJointUtils.TryGetJointPose(TrackedHandJoint.Wrist, handedness, out var wristPose) && HandJointUtils.TryGetJointPose(TrackedHandJoint.PinkyTip, handedness, out var fingerTipPose) && HandJointUtils.TryGetJointPose(TrackedHandJoint.PinkyKnuckle, handedness, out var fingerKnucklePose)) { return(CalculateCurl(wristPose.Position, fingerKnucklePose.Position, fingerTipPose.Position)); } return(0.0f); }
public static float CalculateIndexPinch(Handedness handedness) { HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexTip, handedness, out var indexPose); HandJointUtils.TryGetJointPose(TrackedHandJoint.ThumbTip, handedness, out var thumbPose); Vector3 distanceVector = indexPose.Position - thumbPose.Position; float indexThumbSqrMagnitude = distanceVector.sqrMagnitude; float pinchStrength = Mathf.Clamp(1 - indexThumbSqrMagnitude / IndexThumbSqrMagnitudeThreshold, 0.0f, 1.0f); return(pinchStrength); }
public void AddItemPrefab(int prefab_index) { Vector3 RightIndexTipPosition = Vector3.zero; if (HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexTip, Handedness.Right, out MixedRealityPose poseRightIndexTip)) { RightIndexTipPosition = poseRightIndexTip.Position; } GameObject itemPrefab; itemPrefab = Instantiate(_itemsPrefabs[prefab_index], this.transform.position, Quaternion.identity) as GameObject; }
/// <summary> /// Returns true if middle finger tip is closer to wrist than middle knuckle joint. /// </summary> /// <param name="hand">Hand to query joint pose against.</param> /// <returns></returns> public static bool IsMiddleGrabbing(Handedness hand) { if (HandJointUtils.TryGetJointPose(TrackedHandJoint.Wrist, hand, out var wristPose) && HandJointUtils.TryGetJointPose(TrackedHandJoint.MiddleTip, hand, out var indexTipPose) && HandJointUtils.TryGetJointPose(TrackedHandJoint.MiddleKnuckle, hand, out var indexKnucklePose)) { // compare wrist-knuckle to wrist-tip Vector3 wristToIndexTip = indexTipPose.Position - wristPose.Position; Vector3 wristToIndexKnuckle = indexKnucklePose.Position - wristPose.Position; return(wristToIndexKnuckle.sqrMagnitude >= wristToIndexTip.sqrMagnitude); } return(false); }
/// <summary> /// Returns true if middle thumb tip is closer to pinky knuckle than thumb knuckle joint. /// </summary> /// <param name="hand">Hand to query joint pose against.</param> /// <returns></returns> public static bool IsThumbGrabbing(Handedness hand) { if (HandJointUtils.TryGetJointPose(TrackedHandJoint.PinkyKnuckle, hand, out var pinkyKnucklePose) && HandJointUtils.TryGetJointPose(TrackedHandJoint.ThumbTip, hand, out var thumbTipPose) && HandJointUtils.TryGetJointPose(TrackedHandJoint.ThumbProximalJoint, hand, out var thumbKnucklePose)) { // compare pinkyKnuckle-ThumbKnuckle to pinkyKnuckle-ThumbTip Vector3 pinkyKnuckleToThumbTip = thumbTipPose.Position - pinkyKnucklePose.Position; Vector3 pinkyKnuckleToThumbKnuckle = thumbKnucklePose.Position - pinkyKnucklePose.Position; return(pinkyKnuckleToThumbKnuckle.sqrMagnitude >= pinkyKnuckleToThumbTip.sqrMagnitude); } return(false); }
void Update() { indexTipObj.GetComponent <Renderer>().enabled = false; thumbTipObj.GetComponent <Renderer>().enabled = false; nerfGunObj.GetComponent <Renderer>().enabled = false; knuckleObj.GetComponent <Renderer>().enabled = false; if (HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexTip, Handedness.Right, out pose)) { indexTipObj.transform.position = pose.Position; indexTipObj.GetComponent <Renderer>().enabled = true; } if (HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexKnuckle, Handedness.Right, out pose)) { knuckleObj.transform.position = pose.Position; knuckleObj.GetComponent <Renderer>().enabled = true; nerfGunObj.transform.position = knuckleObj.transform.position; nerfGunObj.transform.Translate(-0.08f, 0.03f, 0); nerfGunObj.GetComponent <Renderer>().enabled = true; } if (HandJointUtils.TryGetJointPose(TrackedHandJoint.ThumbTip, Handedness.Right, out pose)) { thumbTipObj.transform.position = pose.Position; thumbTipObj.GetComponent <Renderer>().enabled = true; } if (HandJointUtils.TryGetJointPose(TrackedHandJoint.Wrist, Handedness.Right, out pose)) { nerfGunObj.transform.rotation = pose.Rotation; nerfGunObj.transform.Rotate(0, -70, 175); nerfGunObj.GetComponent <Renderer>().enabled = true; } // if trigger is pulled, shoot if (thumbTipObj.GetComponent <TriggerListener>().triggerPulled&& HandJointUtils.TryGetJointPose(TrackedHandJoint.ThumbTip, Handedness.Right, out pose)) { nerfGunComponent.FireDart(nerfGunObj.transform.position); } }
void Update() { if (curInterval++ < interval) { return; } curInterval = 0; // track the position of hands, which denotes a slicing plane, and sample plane from the NRRD texture if (HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexKnuckle, leftHanded ? Handedness.Left : Handedness.Right, out MixedRealityPose po1) && HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexTip, leftHanded ? Handedness.Left : Handedness.Right, out MixedRealityPose po2) && HandJointUtils.TryGetJointPose(TrackedHandJoint.PinkyKnuckle, leftHanded ? Handedness.Left : Handedness.Right, out MixedRealityPose po3)) { var p1 = ct.TransformWorldCoords(po1.Position); var p2 = ct.TransformWorldCoords(po2.Position); var p3 = ct.TransformWorldCoords(po3.Position); if (p1.x < -0.5 || 0.5 < p1.x || p1.y < -0.5 || 0.5 < p1.y || p1.z < -0.5 || 0.5 < p1.z || p2.x < -0.5 || 0.5 < p2.x || p2.y < -0.5 || 0.5 < p2.y || p2.z < -0.5 || 0.5 < p2.z || p3.x < -0.5 || 0.5 < p3.x || p3.y < -0.5 || 0.5 < p3.y || p3.z < -0.5 || 0.5 < p3.z) { return; } var plane = leftHanded ? new Plane(p1, p3, p2) : new Plane(p1, p2, p3); var orig = plane.ClosestPointOnPlane(Vector3.zero); var dy = (p2 - p1).normalized; var dx = Vector3.Cross(dy, plane.normal); if (enableReferencePlane) { if (!referencePlane) { referencePlane = GameObject.CreatePrimitive(PrimitiveType.Plane); referencePlane.GetComponent <Transform>().SetParent(ct.gameObject.GetComponent <Transform>()); referencePlane.GetComponent <Transform>().localScale = new Vector3(0.02f, 0.02f, 0.02f); } referencePlane.GetComponent <Transform>().up = plane.normal; referencePlane.GetComponent <Transform>().localPosition = p2; } ct.Slice(orig, dx, dy, tex); } }
private bool HanddirDetected() { var jointedHand = HandJointUtils.FindHand(handType); if (jointedHand.TryGetJoint(TrackedHandJoint.Palm, out MixedRealityPose palmPose)) { if (facingThreshold < Vector3.Angle(palmPose.Up, CameraCache.Main.transform.forward)) { // Debug.Log(palmPose.Up); return(true); } } return(false); }
public GameObject[] GetHandsToRecord() { GameObject[] hands = new GameObject[2]; if (HandJointUtils.FindHand(Handedness.Left) != null) { hands[0] = HandJointUtils.FindHand(Handedness.Left).Visualizer.GameObjectProxy; } if (HandJointUtils.FindHand(Handedness.Right) != null) { hands[1] = HandJointUtils.FindHand(Handedness.Right).Visualizer.GameObjectProxy; } return(hands); }
// Update is called once per frame void Update() { if (_view.IsMine) { if (!_deskzone.IsInside && HandJointUtils.TryGetJointPose(TrackedHandJoint.Wrist, IsRight? Handedness.Right : Handedness.Left, out MixedRealityPose pose)) { _transform.localScale = Vector3.one; _transform.position = pose.Position; _transform.rotation = pose.Rotation; } else { _transform.localScale = new Vector3(0.001f, 0.001f, 0.001f); } } }
// Start is called before the first frame update void Awake() { RPCRuntimeUPDShortcut = UtilityExtentions.GetRPCShortcut("RPCRuntimeReceiveData"); if (RootTransform.root != null) { transform.SetParent(RootTransform.root.transform); } var tmp = (TrackedHandJoint[])System.Enum.GetValues(typeof(TrackedHandJoint)); _jointNameListArray = new TrackedHandJoint[tmp.Length - 2]; for (int i = 0, j = 0; i < tmp.Length; i++) { if ((i != (int)TrackedHandJoint.None) && (i != (int)TrackedHandJoint.Palm)) { _jointNameListArray[j++] = tmp[i]; } } _mixedRealityHand = HandJointUtils.FindHand(Hand); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; // init the fade state setMeshEnabled(false); // force to hide the mesh at the start _handStateFading.SetState(HandStateFading.FadeState.Hide); Debug.Assert(localTargetFPS != 0); Debug.Assert(clientTargetFPS != 0); localUpdateFrameRate = (int)(systemFPS / (float)localTargetFPS); clientSendFrameRate = (int)(systemFPS / (float)clientTargetFPS); clientUpdateFrameRate = (int)(systemFPS / (float)lerpTargetFPS); if (localUpdateFrameRate == 0 || clientSendFrameRate == 0 || clientUpdateFrameRate == 0) { //prevent divide by zero on the modulus divs below Debug.Log("FATAL Div by Zero! Local: " + localUpdateFrameRate.ToString() + " Send: " + clientSendFrameRate.ToString() + " Client: " + clientUpdateFrameRate.ToString()); } }
// Update is called once per frame void Update() { MixedRealityPose pose; // determine if any of the index tip fingers are tracked if (HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexTip, Handedness.Any, out pose)) { BoundingBox[] collection = gameObject.GetComponentsInChildren <BoundingBox>(); // find closest collection float distance = ActivationDistance; BoundingBox activeBox = null; foreach (BoundingBox item in collection) { float dist = Vector3.Distance(item.gameObject.transform.position, pose.Position); if (dist < distance) { distance = dist; activeBox = item; } } if (activeBox != null) { contextMenu.SetActive(true); contextMenuBar.Target = activeBox; } else { contextMenu.SetActive(false); } } else { contextMenu.SetActive(false); gameObject.GetComponent <GridObjectCollection>().UpdateCollection(); } }
public IEnumerator TestUseSourcePoseDataAsFallback() { TestHand rightHand = new TestHand(Handedness.Right); yield return(rightHand.Show(Vector3.zero)); yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); PokePointer pokePointer = PointerUtils.GetPointer <PokePointer>(Handedness.Right); Assert.IsNotNull(pokePointer); pokePointer.UseSourcePoseAsFallback = true; SpherePointer grabPointer = PointerUtils.GetPointer <SpherePointer>(Handedness.Right); Assert.IsNotNull(grabPointer); grabPointer.UseSourcePoseAsFallback = true; // Setting the pointer's pose action to a new input action is functionally equivalent to ensuring that an event is never raised of the pointer's desired pose action // This makes it so it will have to use the source pose data as a fallback pokePointer.PoseAction = new MixedRealityInputAction(); grabPointer.PoseAction = new MixedRealityInputAction(); yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); yield return(rightHand.Hide()); yield return(rightHand.Show(Vector3.zero)); yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); // The source pose is centered on the palm MixedRealityPose palmPose; HandJointUtils.TryGetJointPose(TrackedHandJoint.Palm, Handedness.Right, out palmPose); // This offset value is derived from the PokePointer's sourcePoseOffset property float pokePointerOffset = 0.075f; TestUtilities.AssertAboutEqual(pokePointer.Position, grabPointer.Position + pokePointer.transform.forward * pokePointerOffset, "pointer was not in the expected position"); TestUtilities.AssertAboutEqual(grabPointer.Position, palmPose.Position, "pointer was not in the expected position"); }
// Update is called once per frame void Update() { CameraTrans = CameraObject.transform; //DetectRighitHandWrist if (HandJointUtils.TryGetJointPose(TrackedHandJoint.Palm, handednesstype, out MixedRealityPose pose)) { float localrotx = CameraTrans.transform.rotation.eulerAngles.x - pose.Rotation.eulerAngles.x; float localroty = CameraTrans.transform.rotation.eulerAngles.y - pose.Rotation.eulerAngles.y; float localrotz = CameraTrans.transform.rotation.eulerAngles.z - pose.Rotation.eulerAngles.z; float localposx = CameraTrans.transform.position.x - pose.Position.x; float localposy = CameraTrans.transform.position.y - pose.Position.y; float localposz = CameraTrans.transform.position.z - pose.Position.z; UIObject.transform.localPosition = new Vector3(pose.Position.x, pose.Position.y, pose.Position.z); UIObject.transform.localRotation = new Quaternion(pose.Rotation.x, pose.Rotation.y, pose.Rotation.z, pose.Rotation.w); //Debug.Log(new Vector3(localposx, localposy, localposz)); //Debug.Log(new Vector3(localrotx,localroty,localrotz)); bool c = localrotx > DetectRangeMin; Debug.Log(c); } }
void Update() { thumbObject.GetComponent <Renderer>().enabled = false; indexObject.GetComponent <Renderer>().enabled = false; middleObject.GetComponent <Renderer>().enabled = false; ringObject.GetComponent <Renderer>().enabled = false; pinkyObject.GetComponent <Renderer>().enabled = false; if (HandJointUtils.TryGetJointPose(TrackedHandJoint.ThumbTip, Handedness.Right, out pose)) { thumbObject.GetComponent <Renderer>().enabled = true; thumbObject.transform.position = pose.Position; } if (HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexTip, Handedness.Right, out pose)) { indexObject.GetComponent <Renderer>().enabled = true; indexObject.transform.position = pose.Position; } if (HandJointUtils.TryGetJointPose(TrackedHandJoint.MiddleTip, Handedness.Right, out pose)) { middleObject.GetComponent <Renderer>().enabled = true; middleObject.transform.position = pose.Position; } if (HandJointUtils.TryGetJointPose(TrackedHandJoint.RingTip, Handedness.Right, out pose)) { ringObject.GetComponent <Renderer>().enabled = true; ringObject.transform.position = pose.Position; } if (HandJointUtils.TryGetJointPose(TrackedHandJoint.PinkyTip, Handedness.Right, out pose)) { pinkyObject.GetComponent <Renderer>().enabled = true; pinkyObject.transform.position = pose.Position; } }
private bool RingAndPinkyFingerDetected() { //※メモ HoloLens2の場合実装的には薬指、小指それぞれの判定は可能だが、実機の場合特に小指単体のトラッキング精度に問題があるため薬指、小指はひとまとめで一つの指として検知する。 var jointedHand = HandJointUtils.FindHand(handType); if (jointedHand.TryGetJoint(TrackedHandJoint.Palm, out MixedRealityPose PalmPose)) { MixedRealityPose PinkyTipPose, PinkyDistalPose, PinkyMiddlePose, PinkyKnucklePose, RingTipPose, RingDistalPose, RingMiddlePose, RingKnucklePose; if (jointedHand.TryGetJoint(TrackedHandJoint.RingTip, out RingTipPose) && jointedHand.TryGetJoint(TrackedHandJoint.RingMiddleJoint, out RingMiddlePose) && jointedHand.TryGetJoint(TrackedHandJoint.RingDistalJoint, out RingDistalPose) && jointedHand.TryGetJoint(TrackedHandJoint.RingKnuckle, out RingKnucklePose)) { Vector3 finger1 = RingKnucklePose.Position - PalmPose.Position; Vector3 finger2 = RingMiddlePose.Position - RingKnucklePose.Position; Vector3 finger3 = RingDistalPose.Position - RingMiddlePose.Position; Vector3 finger4 = RingTipPose.Position - RingDistalPose.Position; float c = Vector3.Angle(PalmPose.Position, finger1); float d = Vector3.Angle(finger1, finger2); float e = Vector3.Angle(finger2, finger3); float f = Vector3.Angle(finger3, finger4); float aba = (Mathf.Abs(d) + Mathf.Abs(e) + Mathf.Abs(f)) / 3; Debug.Log(aba); if (aba < ringAndPinkyFingerThreshpld) { return(true); } } } return(false); }
public void show(int num, Action <int> touch) { touch_ = touch; if (HandJointUtils.TryGetJointPose(TrackedHandJoint.Wrist, Handedness.Right, out pose)) { this.transform.position = pose.Position; _follow.wristObjectR.SetActive(true); // wristObjectR.GetComponent<Renderer>().enabled = true; } else if (HandJointUtils.TryGetJointPose(TrackedHandJoint.Wrist, Handedness.Left, out pose)) { this.transform.position = pose.Position; _follow.wristObjectL.SetActive(true); // wristObjectR.GetComponent<Renderer>().enabled = true; } for (int i = 0; i < Mathf.Min(_buttons.Length, num); ++i) { _buttons[i].SetActive(true); } //throw new NotImplementedException(); }
private void InstantiateRecordingRepresentation(ref GameObject anchoredObject, Vector3 atLocation, bool atPalm = true) { // get palm position Vector3 positionToInstantiate = new Vector3(0, 0, 0); Quaternion rotationToInstantiate = Quaternion.identity; if (atPalm) { if (HandJointUtils.TryGetJointPose(TrackedHandJoint.Palm, Handedness.Left, out MixedRealityPose pose)) { positionToInstantiate = pose.Position; } else { positionToInstantiate = Camera.main.transform.position + 0.5f * Vector3.forward; } } // instantiate representation at palm or specified location recordingRepresentationInstance = Instantiate(original: recordingRepresentationPrefab, position: positionToInstantiate, rotation: rotationToInstantiate, parent: anchoredObject.transform); if (!atPalm) { recordingRepresentationInstance.transform.localPosition = atLocation; } }
// Update is called once per frame void Update() { Vector3 RightIndexTipPosition = Vector3.zero; if (HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexTip, Handedness.Right, out MixedRealityPose poseRightIndexTip)) { RightIndexTipPosition = poseRightIndexTip.Position; } Vector3 LeftIndexTipPosition = Vector3.zero; if (HandJointUtils.TryGetJointPose(TrackedHandJoint.IndexTip, Handedness.Left, out MixedRealityPose poseLeftIndexTip)) { LeftIndexTipPosition = poseLeftIndexTip.Position; } if (Vector3.Distance(LeftIndexTipPosition, RightIndexTipPosition) < EPS) { SensorTrigger(); } else { SensorUntrigger(); } }
public IEnumerator TestUseSourcePoseData() { TestHand rightHand = new TestHand(Handedness.Right); yield return(rightHand.Show(Vector3.zero)); yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); PokePointer pokePointer = PointerUtils.GetPointer <PokePointer>(Handedness.Right); Assert.IsNotNull(pokePointer); SpherePointer grabPointer = PointerUtils.GetPointer <SpherePointer>(Handedness.Right); Assert.IsNotNull(grabPointer); pokePointer.UseSourcePoseData = true; grabPointer.UseSourcePoseData = true; yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); yield return(rightHand.Hide()); yield return(rightHand.Show(Vector3.zero)); yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); // The source pose is centered on the palm MixedRealityPose palmPose; HandJointUtils.TryGetJointPose(TrackedHandJoint.Palm, Handedness.Right, out palmPose); // This offset value is derived from the PokePointer's sourcePoseOffset property float pokePointerOffset = 0.075f; TestUtilities.AssertAboutEqual(pokePointer.Position, grabPointer.Position + pokePointer.transform.forward * pokePointerOffset, "pointer was not in the expected position"); TestUtilities.AssertAboutEqual(grabPointer.Position, palmPose.Position, "pointer was not in the expected position"); }
// Update is called once per frame public void Update() { if (startRecording) { frame_count++; float delta = Time.time - timeSinceStartOfRecording; Vector3 leftPalm = new Vector3(); Vector3 rightPalm = new Vector3(); if (HandJointUtils.TryGetJointPose(TrackedHandJoint.Palm, Handedness.Left, out MixedRealityPose leftPose)) { leftPalm = leftPose.Position; } if (HandJointUtils.TryGetJointPose(TrackedHandJoint.Palm, Handedness.Right, out MixedRealityPose rightPose)) { rightPalm = rightPose.Position; } // append null palm coordinates and check later timesteps[frame_count] = delta; leftPalmArray[frame_count] = leftPalm; rightPalmArray[frame_count] = rightPalm; } }
// Update is called once per frame void Update() { CameraTrans = CameraObject.transform; //DetectRighitHandWrist if (HandJointUtils.TryGetJointPose(TrackedHandJoint.Palm, handednesstype, out MixedRealityPose pose)) { if (!isDetect) { isDetect = true; } posepos = pose.Position; poserote = pose.Rotation; } else { if (isDetect) { Debug.Log(pose); isDetect = false; GameObject Obj = (GameObject)Instantiate(_areaVisualizerObject, posepos, poserote); Obj.transform.parent = targetObject.transform; } } }