Skip to content

Commit e57e222

Browse files
committed
Implement IMixedRealityHand
1 parent d2d519f commit e57e222

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/XR2018/WindowsMixedRealityArticulatedHand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public bool TryGetJoint(TrackedHandJoint joint, out MixedRealityPose pose)
7373

7474
#endregion IMixedRealityHand Implementation
7575

76+
/// <inheritdoc/>
7677
public override bool IsInPointingPose
7778
{
7879
get

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/XRSDK/Controllers/WindowsMixedRealityXRSDKArticulatedHand.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Microsoft.MixedReality.Toolkit.XRSDK.WindowsMixedReality
2323
[MixedRealityController(
2424
SupportedControllerType.ArticulatedHand,
2525
new[] { Handedness.Left, Handedness.Right })]
26-
public class WindowsMixedRealityXRSDKArticulatedHand : BaseWindowsMixedRealityXRSDKSource
26+
public class WindowsMixedRealityXRSDKArticulatedHand : BaseWindowsMixedRealityXRSDKSource, IMixedRealityHand
2727
{
2828
/// <summary>
2929
/// Constructor.
@@ -280,6 +280,46 @@ private TrackedHandJoint ConvertToTrackedHandJoint(HandFinger finger, int index)
280280
}
281281
}
282282

283+
#region IMixedRealityHand Implementation
284+
285+
/// <inheritdoc/>
286+
public bool TryGetJoint(TrackedHandJoint joint, out MixedRealityPose pose) => unityJointPoses.TryGetValue(joint, out pose);
287+
288+
#endregion IMixedRealityHand Implementation
289+
290+
private readonly float CursorBeamBackwardTolerance = 0.5f;
291+
private readonly float CursorBeamUpTolerance = 0.8f;
292+
293+
/// <inheritdoc/>
294+
public override bool IsInPointingPose
295+
{
296+
get
297+
{
298+
bool valid = true;
299+
MixedRealityPose palmJoint;
300+
if (unityJointPoses.TryGetValue(TrackedHandJoint.Palm, out palmJoint))
301+
{
302+
Vector3 palmNormal = palmJoint.Rotation * (-1 * Vector3.up);
303+
if (CursorBeamBackwardTolerance >= 0)
304+
{
305+
Vector3 cameraBackward = -CameraCache.Main.transform.forward;
306+
if (Vector3.Dot(palmNormal.normalized, cameraBackward) > CursorBeamBackwardTolerance)
307+
{
308+
valid = false;
309+
}
310+
}
311+
if (valid && CursorBeamUpTolerance >= 0)
312+
{
313+
if (Vector3.Dot(palmNormal, Vector3.up) > CursorBeamUpTolerance)
314+
{
315+
valid = false;
316+
}
317+
}
318+
}
319+
return valid;
320+
}
321+
}
322+
283323
#endregion Update data functions
284324
}
285325
}

0 commit comments

Comments
 (0)