public IEnumerator TestGazeCursorWhenHandsNearGrabbable() { var inputSystem = PlayModeTestUtilities.GetInputSystem(); TestUtilities.PlayspaceToOriginLookingForward(); // Create grabbable cube var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.AddComponent <NearInteractionGrabbable>(); cube.transform.position = new Vector3(0, 0, 4.72f); yield return(null); // No hands, default cursor should be visible Assert.IsTrue(CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible, "Head gaze cursor should be visible"); // Hand up near grabbable TestHand hand = new TestHand(Handedness.Right); yield return(hand.Show(Vector3.forward * 4.05f)); yield return(null); var grabPointer = PointerUtils.GetPointer <SpherePointer>(Handedness.Right); // Grab pointer is near grabbable Assert.IsTrue(grabPointer.IsNearObject, "Grab pointer should be near a grabbable"); // Head cursor invisible when grab pointer is near grabbable Assert.IsFalse(CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible, "Eye gaze cursor should not be visible"); // Enabling eye tracking data InputSimulationService inputSimulationService = PlayModeTestUtilities.GetInputSimulationService(); inputSimulationService.SimulateEyePosition = true; yield return(null); // Eye based gaze cursor should still be invisible Assert.IsFalse(CoreServices.InputSystem.GazeProvider.GazeCursor.IsVisible, "Eye gaze cursor should be visible"); UnityEngine.Object.Destroy(cube); }
public void OnTouchStarted(HandTrackingInputEventData eventData) { _panningPointer = PointerUtils.GetPointer <PokePointer>(eventData.Handedness); if (CoreServices.InputSystem.FocusProvider.TryGetFocusDetails(_panningPointer, out FocusDetails focusDetails) && focusDetails.Object == gameObject) { //_panningPointer = eventData.Pointer; _startingPointInLocalSpace = focusDetails.PointLocalSpace; _startingPointInMercatorSpace = _mapRenderer.TransformLocalPointToMercatorWithAltitude( _startingPointInLocalSpace, out _startingAltitudeInMeters, out _startingMercatorScale); _currentPointInLocalSpace = _startingPointInLocalSpace; _startingMapCenterInMercator = _mapRenderer.Center.ToMercatorPosition(); eventData.Use(); } }
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"); }
private void EnsurePointerStates(Handedness h, PointerStateContainer c) { Action <IMixedRealityPointer, string, bool?> helper = (ptr, name, expected) => { if (!expected.HasValue) { Assert.Null(ptr, $"Expected {h} {name} to be null but it was not null"); } else { Assert.NotNull(ptr, $"Expected {name} to not be null, but it was null"); Assert.AreEqual(expected.Value, ptr.IsInteractionEnabled, $"Incorrect state for {h} {name}.IsInteractionEnabled"); } }; helper(PointerUtils.GetPointer <LinePointer>(h), "Line Pointer", c.LinePointerEnabled); helper(PointerUtils.GetPointer <SpherePointer>(h), "Sphere Pointer", c.SpherePointerEnabled); helper(PointerUtils.GetPointer <PokePointer>(h), "Poke Pointer", c.PokePointerEnabled); helper(PointerUtils.GetPointer <GGVPointer>(h), "GGV Pointer", c.GGVPointerEnabled); helper(CoreServices.InputSystem.GazeProvider.GazePointer, "Gaze Pointer", c.GazePointerEnabled); }
private IEnumerator TestHandSolver(SetupData testData, InputSimulationService inputSimulationService, Vector3 handPos, Handedness hand) { Assert.IsTrue(testData.handler.TrackedTargetType == TrackedObjectType.ControllerRay || testData.handler.TrackedTargetType == TrackedObjectType.HandJoint, "TestHandSolver supports on ControllerRay and HandJoint tracked target types"); yield return(PlayModeTestUtilities.ShowHand(hand, inputSimulationService, Utilities.ArticulatedHandPose.GestureId.Open, handPos)); // Give time for cube to float to hand yield return(WaitForFrames(2)); Vector3 handOrbitalPos = testData.target.transform.position; Assert.LessOrEqual(Vector3.Distance(handOrbitalPos, handPos), DistanceThreshold); Transform expectedTransform = null; if (testData.handler.TrackedTargetType == TrackedObjectType.ControllerRay) { expectedTransform = PointerUtils.GetPointer <LinePointer>(hand)?.transform; } else { var handJointService = (CoreServices.InputSystem as IMixedRealityDataProviderAccess)?.GetDataProvider <IMixedRealityHandJointService>(); expectedTransform = handJointService.RequestJointTransform(testData.handler.TrackedHandJoint, hand); } Assert.AreEqual(testData.handler.CurrentTrackedHandedness, hand); Assert.IsNotNull(expectedTransform); // SolverHandler creates a dummy GameObject to provide a transform for tracking so it can be managed (allocated/deleted) // Look at the parent to compare transform equality for what we should be tracking against Assert.AreEqual(testData.handler.TransformTarget.parent, expectedTransform); yield return(PlayModeTestUtilities.HideHand(Handedness.Right, inputSimulationService)); yield return(WaitForFrames(2)); }
public IEnumerator TestPointerFOV() { var rightHand = new TestHand(Handedness.Right); yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.AddComponent <NearInteractionGrabbable>(); cube.AddComponent <NearInteractionTouchableVolume>(); yield return(rightHand.Show(Vector3.zero)); yield return(PlayModeTestUtilities.WaitForInputSystemUpdate()); var spherePointer = PointerUtils.GetPointer <SpherePointer>(Handedness.Right); var pokePointer = PointerUtils.GetPointer <PokePointer>(Handedness.Right); yield return(TestPointerFOVHelper(spherePointer, cube, rightHand)); yield return(TestPointerFOVHelper(pokePointer, cube, rightHand)); rightHand.Hide(); GameObject.Destroy(cube); }
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"); }