コード例 #1
0
        public IEnumerator ArticulatedCursorState()
        {
            var inputSystem = PlayModeTestUtilities.GetInputSystem();

            // Show hand far enough from the test collider so the cursor is not on it
            var hand = new TestHand(Handedness.Right);
            Vector3 offObjectPos = new Vector3(0.05f, 0, 1.0f);
            yield return hand.Show(offObjectPos);
            VerifyCursorStateFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorStateEnum.Interact);

            // Move hand closer to the collider so the cursor is on it
            Vector3 onObjectPos = new Vector3(0.05f, 0, 1.5f);
            yield return hand.MoveTo(onObjectPos, numFramesPerMove);
            VerifyCursorStateFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorStateEnum.InteractHover);

            // Trigger pinch
            yield return hand.SetGesture(ArticulatedHandPose.GestureId.Pinch);
            VerifyCursorStateFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorStateEnum.Select);

            // Release pinch
            yield return hand.SetGesture(ArticulatedHandPose.GestureId.Open, false);
            VerifyCursorStateFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorStateEnum.Release);

            // Wait to transition back to InteractHover
            yield return null;
            VerifyCursorStateFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorStateEnum.InteractHover);

            // Move back so the cursor is no longer on the object
            yield return hand.MoveTo(offObjectPos, numFramesPerMove);
            VerifyCursorStateFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorStateEnum.Interact);
        }
        public IEnumerator TestOverrideFocusDetails()
        {
            PlayModeTestUtilities.Setup();

            var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

            yield return(null);

            var focusProvider = PlayModeTestUtilities.GetInputSystem().FocusProvider;

            var pointer = new TestPointer();

            Assert.IsFalse(focusProvider.TryGetFocusDetails(pointer, out var focusDetails));
            Assert.IsFalse(focusProvider.TryOverrideFocusDetails(pointer, new Physics.FocusDetails()));

            focusProvider.RegisterPointer(pointer);
            yield return(null);

            Assert.IsTrue(focusProvider.TryGetFocusDetails(pointer, out focusDetails));
            Assert.IsNull(focusDetails.Object);

            var newFocusDetails = new Physics.FocusDetails();

            newFocusDetails.Object      = cube;
            newFocusDetails.RayDistance = 10;
            newFocusDetails.Point       = new Vector3(1, 2, 3);
            Assert.IsTrue(focusProvider.TryOverrideFocusDetails(pointer, newFocusDetails));

            Assert.IsTrue(focusProvider.TryGetFocusDetails(pointer, out focusDetails));
            Assert.AreEqual(newFocusDetails.Object, focusDetails.Object);
            Assert.AreEqual(newFocusDetails.RayDistance, focusDetails.RayDistance);
            Assert.AreEqual(newFocusDetails.Point, focusDetails.Point);
            Assert.AreEqual(newFocusDetails.Object, focusProvider.GetFocusedObject(pointer));
        }
        public IEnumerator TestGazeCursorArticulated()
        {
            IMixedRealityInputSystem inputSystem = PlayModeTestUtilities.GetInputSystem();

            yield return(null);

            // Verify that the gaze cursor is visible at the start
            Assert.IsTrue(inputSystem.GazeProvider.GazePointer.IsInteractionEnabled, "Gaze cursor should be visible at start");

            // raise hand up -- gaze cursor should no longer be visible
            // disable user input
            InputSimulationService inputSimulationService = PlayModeTestUtilities.GetInputSimulationService();

            inputSimulationService.UserInputEnabled = false;

            ArticulatedHandPose gesturePose = ArticulatedHandPose.GetGesturePose(ArticulatedHandPose.GestureId.Open);
            var handOpenPose = PlayModeTestUtilities.GenerateHandPose(ArticulatedHandPose.GestureId.Open, Handedness.Right, Vector3.forward * 0.1f, Quaternion.identity);

            inputSimulationService.HandDataRight.Update(true, false, handOpenPose);
            yield return(null);

            // Gaze cursor should not be visible
            Assert.IsFalse(inputSystem.GazeProvider.GazePointer.IsInteractionEnabled, "Gaze cursor should not be visible when one articulated hand is up");
            inputSimulationService.HandDataRight.Update(false, false, handOpenPose);
            yield return(null);

            // Say "select" to make gaze cursor active again
            // Really we need to tear down the scene and create it again but MRTK doesn't support that yet
            var gazeInputSource = inputSystem.DetectedInputSources.Where(x => x.SourceName.Equals("Gaze")).First();

            inputSystem.RaiseSpeechCommandRecognized(gazeInputSource, RecognitionConfidenceLevel.High, new System.TimeSpan(), System.DateTime.Now, new SpeechCommands("select", KeyCode.Alpha1, MixedRealityInputAction.None));
            yield return(null);

            Assert.IsTrue(inputSystem.GazeProvider.GazePointer.IsInteractionEnabled, "Gaze cursor should be visible after select command");
        }
コード例 #4
0
        public IEnumerator TestFocusProviderWithoutGaze()
        {
            IMixedRealityInputSystem inputSystem = PlayModeTestUtilities.GetInputSystem();

            yield return(null);

            InputSimulationService inputSimulationService = PlayModeTestUtilities.GetInputSimulationService();

            yield return(null);

            // Put up a hand to ensure there's a second pointer, which will keep the FocusProvider UpdatePointers loop spinning
            yield return(PlayModeTestUtilities.ShowHand(Handedness.Right, inputSimulationService));

            // Verify that the GazeProvider exists at the start
            Assert.IsTrue(inputSystem.GazeProvider as MonoBehaviour != null, "Gaze provider should exist at start");
            yield return(null);

            // Destroy the GazeProvider
            Object.Destroy(inputSystem.GazeProvider as MonoBehaviour);
            yield return(null);

            // Verify that the GazeProvider no longer exists
            Assert.IsTrue(inputSystem.GazeProvider as MonoBehaviour == null, "Gaze provider should no longer exist");
            yield return(null);

            // Hide the hand for other tests
            yield return(PlayModeTestUtilities.HideHand(Handedness.Right, inputSimulationService));
        }
コード例 #5
0
        public IEnumerator TestPointerDirectionToCameraDirection()
        {
            var inputSystem = PlayModeTestUtilities.GetInputSystem();

            // Raise the hand
            var rightHand = new TestHand(Handedness.Right);

            // Set initial position and show hand
            Vector3 initialPos = new Vector3(0.01f, 0.1f, 0.5f);

            yield return(rightHand.Show(initialPos));

            // Return first hand controller that is right and source type hand
            var handController = inputSystem.DetectedControllers.First(x => x.ControllerHandedness == Utilities.Handedness.Right && x.InputSource.SourceType == InputSourceType.Hand);

            Assert.IsNotNull(handController);

            // Get the line pointer from the hand controller
            var linePointer = handController.InputSource.Pointers.OfType <LinePointer>().First();

            Assert.IsNotNull(linePointer);

            Vector3 linePointerOrigin = linePointer.Position;

            // Check that the line pointer origin is within half a centimeter of the initial position of the hand
            var distance = Vector3.Distance(initialPos, linePointerOrigin);

            Assert.LessOrEqual(distance, 0.005f);

            // Check that the angle between the line pointer ray and camera forward does not exceed 40 degrees
            float angle = Vector3.Angle(linePointer.Rays[0].Direction, CameraCache.Main.transform.forward);

            Assert.LessOrEqual(angle, 40.0f);
        }
コード例 #6
0
        public IEnumerator CursorContextScaleRotate()
        {
            var inputSystem = PlayModeTestUtilities.GetInputSystem();

            var empty = new GameObject();
            var info = cube.AddComponent<CursorContextInfo>();
            info.ObjectCenter = empty.transform;

            // Show hand on object
            var hand = new TestHand(Handedness.Right);
            Vector3 handPos = new Vector3(0.05f, 0, 1.5f);
            yield return hand.Show(handPos);
            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorContextEnum.None);

            // rotate, center north
            info.CurrentCursorAction = CursorContextInfo.CursorAction.Rotate;
            empty.transform.SetPositionAndRotation(cube.transform.position + Vector3.up, Quaternion.identity);
            yield return new WaitForFixedUpdate();
            yield return null;
            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorContextEnum.RotateNorthSouth);

            // rotate, center east
            empty.transform.SetPositionAndRotation(cube.transform.position + Vector3.right, Quaternion.identity);
            yield return new WaitForFixedUpdate();
            yield return null;
            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorContextEnum.RotateEastWest);

            // scale, center northeast
            info.CurrentCursorAction = CursorContextInfo.CursorAction.Scale;
            empty.transform.SetPositionAndRotation(cube.transform.position + Vector3.up + Vector3.right, Quaternion.identity);
            yield return new WaitForFixedUpdate();
            yield return null;
            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorContextEnum.MoveNortheastSouthwest);

            // scale, center southeast
            empty.transform.SetPositionAndRotation(cube.transform.position + Vector3.down + Vector3.right, Quaternion.identity);
            yield return new WaitForFixedUpdate();
            yield return null;
            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorContextEnum.MoveNorthwestSoutheast);

            // scale, center northwest
            empty.transform.SetPositionAndRotation(cube.transform.position + Vector3.up + Vector3.left, Quaternion.identity);
            yield return new WaitForFixedUpdate();
            yield return null;
            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorContextEnum.MoveNorthwestSoutheast);

            // scale, center southwest
            empty.transform.SetPositionAndRotation(cube.transform.position + Vector3.down + Vector3.left, Quaternion.identity);
            yield return new WaitForFixedUpdate();
            yield return null;
            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers<ShellHandRayPointer>(), CursorContextEnum.MoveNortheastSouthwest);

            Object.Destroy(empty);
            Object.Destroy(info);
        }
        public void SetupFocusProviderRaycastTests()
        {
            PlayModeTestUtilities.Setup();

            focusProvider = PlayModeTestUtilities.GetInputSystem().FocusProvider;

            pointer = new TestPointer();
            focusProvider.RegisterPointer(pointer);

            GameObject raycastTestPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath("dc3b0cf66c0615e4c81d979f35d51eaa"));

            raycastTestPrefabInstance = Object.Instantiate(raycastTestPrefab);
        }
コード例 #8
0
        public void SetupFocusProviderRaycastTests()
        {
            PlayModeTestUtilities.Setup();

            focusProvider = PlayModeTestUtilities.GetInputSystem().FocusProvider;

            pointer = new TestPointer();
            focusProvider.RegisterPointer(pointer);

            GameObject raycastTestPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(Path.Combine("Assets", "MixedRealityToolkit.Tests", "PlayModeTests", "Prefabs", "FocusProviderRaycastTest.prefab"));

            raycastTestPrefabInstance = Object.Instantiate(raycastTestPrefab);
        }
コード例 #9
0
        public override IEnumerator Setup()
        {
            yield return(base.Setup());

            focusProvider = PlayModeTestUtilities.GetInputSystem().FocusProvider;

            pointer = new TestPointer();
            focusProvider.RegisterPointer(pointer);

            GameObject raycastTestPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath("dc3b0cf66c0615e4c81d979f35d51eaa"));

            raycastTestPrefabInstance = Object.Instantiate(raycastTestPrefab);
            yield return(null);
        }
        private static IEnumerator TestRecording(string recordingProfilePath)
        {
            var profile = AssetDatabase.LoadAssetAtPath(profilePath, typeof(MixedRealityToolkitConfigurationProfile)) as MixedRealityToolkitConfigurationProfile;

            MixedRealityToolkit.Instance.ActiveProfile = profile;

            yield return(null);

            yield return(null);

            var inputSystem      = PlayModeTestUtilities.GetInputSystem();
            var recordingService = CoreServices.GetInputSystemDataProvider <InputRecordingService>();
            var recordingProfile = AssetDatabase.LoadAssetAtPath(recordingProfilePath, typeof(MixedRealityInputRecordingProfile)) as MixedRealityInputRecordingProfile;

            Debug.Log($"Record hand data: {recordingProfile.RecordHandData}");
            Debug.Log($"Record camera data: {recordingProfile.RecordCameraPose}");
            Debug.Log($"Record gaze data: {recordingProfile.RecordEyeGaze}");

            recordingService.InputRecordingProfile = recordingProfile;

            if (recordingProfile.RecordEyeGaze)
            {
                CoreServices.InputSystem.EyeGazeProvider.Enabled = true;
                CoreServices.InputSystem.EyeGazeProvider.UpdateEyeTrackingStatus(null, true);
            }

            recordingService.StartRecording();

            yield return(MoveAround(recordingProfile.RecordHandData, recordingProfile.RecordCameraPose, recordingProfile.RecordEyeGaze));

            recordingService.StopRecording();

            string path            = recordingService.SaveInputAnimation("TestRecording.bin", null);
            var    playbackService = CoreServices.GetInputSystemDataProvider <IMixedRealityInputPlaybackService>();

            yield return(null);

            playbackService.LoadInputAnimation(path);

            var animation = playbackService.Animation;

            Assert.True(recordingProfile.RecordHandData == animation.HasHandData && recordingProfile.RecordCameraPose == animation.HasCameraPose && recordingProfile.RecordEyeGaze == animation.HasEyeGaze);
            playbackService.Play();

            yield return(new WaitWhile(() => playbackService.IsPlaying));

            yield return(null);
        }
コード例 #11
0
        public IEnumerator TestMotionControllerPointerDirectionToCameraDirection()
        {
            var inputSystem = PlayModeTestUtilities.GetInputSystem();

            // Switch to motion controller
            var iss        = PlayModeTestUtilities.GetInputSimulationService();
            var oldSimMode = iss.ControllerSimulationMode;

            iss.ControllerSimulationMode = ControllerSimulationMode.MotionController;

            // Raise the motion controller
            var rightMotionController = new TestMotionController(Handedness.Right);

            // Set initial position and show motion controller
            Vector3 initialPos = TestUtilities.PositionRelativeToPlayspace(new Vector3(0.01f, 0.1f, 0.5f));

            yield return(rightMotionController.Show(initialPos));

            // Return first motion controller that is right and source type controller
            var motionController = inputSystem.DetectedControllers.First(x => x.ControllerHandedness == Handedness.Right && x.InputSource.SourceType == InputSourceType.Controller);

            Assert.IsNotNull(motionController);

            // Get the line pointer from the motion controller
            var linePointer = motionController.InputSource.Pointers.OfType <ShellHandRayPointer>().First();

            Assert.IsNotNull(linePointer);

            Vector3 linePointerOrigin = linePointer.Position;

            // Check that the line pointer origin is within half a centimeter of the initial position of the motion controller
            var distance = Vector3.Distance(initialPos, linePointerOrigin);

            Assert.LessOrEqual(distance, 0.005f);

            // Check that the angle between the line pointer ray and camera forward does not exceed 40 degrees
            float angle = Vector3.Angle(linePointer.Rays[0].Direction, CameraCache.Main.transform.forward);

            Assert.LessOrEqual(angle, 40.0f);

            // Restore the input simulation profile
            iss.ControllerSimulationMode = oldSimMode;
            yield return(null);
        }
コード例 #12
0
        public IEnumerator TestGazeCursorWhenHandsNearGrabbable()
        {
            var inputSystem = PlayModeTestUtilities.GetInputSystem();

            TestUtilities.PlayspaceToOriginLookingForward();

            // Create grabbable cube
            var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

            cube.AddComponent <NearInteractionGrabbable>();
            cube.transform.localScale = Vector3.one * 0.35f;
            cube.transform.position   = new Vector3(-0.2f, 0.3f, 4.2f);
            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);
        }
コード例 #13
0
        public IEnumerator TestGazeProviderDestroyed()
        {
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            // remove the gaze provider and it's components from the scene
            GazeProvider gazeProvider = CoreServices.InputSystem.GazeProvider.GameObjectReference.GetComponent <GazeProvider>();

            gazeProvider.GazePointer.BaseCursor.Destroy();
            DebugUtilities.LogVerbose("Application was playing, destroyed the gaze pointer's BaseCursor");
            UnityObjectExtensions.DestroyObject(gazeProvider);
            gazeProvider = null;

            // Ensure that the input system and it's related input sources are able to be reinitialized without issue.
            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            PlayModeTestUtilities.GetInputSystem().Initialize();

            yield return(PlayModeTestUtilities.WaitForInputSystemUpdate());

            yield return(null);
        }
コード例 #14
0
        public IEnumerator CursorContextMove()
        {
            var inputSystem = PlayModeTestUtilities.GetInputSystem();

            // The cube needs to be moved from under the gaze cursor before we add the manipulation handler.
            // Because the cube is under the gaze cursor from the beginning, it gets a focus gained event
            // in Setup(). When we show the right hand, we get a focus lost event from the gaze pointer.
            // This messes with the CursorContextManipulationHandler hoverCount, as it decrements without
            // ever having incremented. To avoid this, we move the cube out of focus before we add the
            // ManipulationHandler and CursorContextManipulationHandler.
            cube.transform.localPosition = new Vector3(0, -2, 2);
            yield return(new WaitForFixedUpdate());

            yield return(null);

            cube.AddComponent <ManipulationHandler>();
            var temp = cube.AddComponent <CursorContextManipulationHandler>();

            yield return(new WaitForFixedUpdate());

            yield return(null);

            // Move cube back to original postion (described above)
            cube.transform.localPosition = new Vector3(0, 0, 2);
            yield return(new WaitForFixedUpdate());

            yield return(null);

            // Show right hand on object
            var     rightHand = new TestHand(Handedness.Right);
            Vector3 rightPos  = new Vector3(0.05f, 0, 1.5f);

            yield return(rightHand.Show(rightPos));

            yield return(new WaitForFixedUpdate());

            yield return(null);

            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers <ShellHandRayPointer>(), CursorContextEnum.None);

            // Pinch right hand
            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Pinch));

            yield return(new WaitForFixedUpdate());

            yield return(null);

            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers <ShellHandRayPointer>(), CursorContextEnum.MoveCross);

            // Show left hand on object
            var     leftHand = new TestHand(Handedness.Left);
            Vector3 leftPos  = new Vector3(-0.05f, 0, 1.5f);

            yield return(rightHand.Hide());

            yield return(leftHand.Show(leftPos));

            yield return(new WaitForFixedUpdate());

            yield return(null);

            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers <ShellHandRayPointer>(), CursorContextEnum.None);

            // Pinch left hand
            yield return(leftHand.SetGesture(ArticulatedHandPose.GestureId.Pinch));

            yield return(new WaitForFixedUpdate());

            yield return(null);

            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers <ShellHandRayPointer>(), CursorContextEnum.MoveCross);

            // Show both hands on object
            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Open));

            yield return(rightHand.Show(rightPos));

            yield return(leftHand.SetGesture(ArticulatedHandPose.GestureId.Open));

            yield return(new WaitForFixedUpdate());

            yield return(null);

            VerifyCursorContextFromPointers(inputSystem.FocusProvider.GetPointers <ShellHandRayPointer>(), CursorContextEnum.MoveCross);

            Object.Destroy(cube.GetComponent <ManipulationHandler>());
            Object.Destroy(cube.GetComponent <CursorContextManipulationHandler>());
        }
コード例 #15
0
        public IEnumerator GestureCursorState()
        {
            var inputSystem = PlayModeTestUtilities.GetInputSystem();

            var iss    = PlayModeTestUtilities.GetInputSimulationService();
            var oldIsp = iss.InputSimulationProfile;
            var isp    = ScriptableObject.CreateInstance <MixedRealityInputSimulationProfile>();

            isp.HandSimulationMode     = HandSimulationMode.Gestures;
            iss.InputSimulationProfile = isp;

            Vector3 underPointerPos = new Vector3(0, 0, 2);
            Vector3 abovePointerPos = new Vector3(0, -2, 2);

            var rightHand = new TestHand(Handedness.Right);
            var leftHand  = new TestHand(Handedness.Left);

            // No hands, pointer not on cube, hand open
            cube.transform.localPosition = abovePointerPos;
            yield return(new WaitForFixedUpdate());

            yield return(null);

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Observe);

            // No hands, pointer on cube, hand open
            cube.transform.localPosition = underPointerPos;
            yield return(new WaitForFixedUpdate());

            yield return(null);

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.ObserveHover);

            // Right hand, pointer not on cube, hand open
            cube.transform.localPosition = abovePointerPos;
            yield return(new WaitForFixedUpdate());

            yield return(rightHand.Show(Vector3.zero));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Interact);

            // Both hands, pointer not on cube, hand open
            yield return(leftHand.Show(Vector3.zero));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Interact);

            // Left hand, pointer not on cube, hand open
            yield return(rightHand.Hide());

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Interact);

            // Left hand, pointer on cube, hand open
            cube.transform.localPosition = underPointerPos;
            yield return(new WaitForFixedUpdate());

            yield return(null);

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.InteractHover);

            // Both hands, pointer on cube, hand open
            yield return(rightHand.Show(Vector3.zero));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.InteractHover);

            // Right hand, pointer on cube, hand open
            yield return(leftHand.Hide());

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.InteractHover);

            // Right hand, pointer on cube, hand pinched
            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Pinch));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Select);
            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Open));

            // Left hand, pointer on cube, hand pinched
            yield return(rightHand.Hide());

            yield return(leftHand.Show(Vector3.zero));

            yield return(leftHand.SetGesture(ArticulatedHandPose.GestureId.Pinch));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Select);

            // Both hands, pointer on cube, left pinched & right open
            yield return(rightHand.Show(Vector3.zero));

            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Open));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Select);

            // Both hands, pointer on cube, both pinched
            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Pinch));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Select);

            // Both hands, pointer on cube, right pinched & left open
            yield return(leftHand.SetGesture(ArticulatedHandPose.GestureId.Open));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Select);

            // Restore the input simulation profile
            iss.InputSimulationProfile = oldIsp;
            yield return(null);
        }
コード例 #16
0
        public IEnumerator GestureCursorState()
        {
            var inputSystem = PlayModeTestUtilities.GetInputSystem();

            var iss            = PlayModeTestUtilities.GetInputSimulationService();
            var oldHandSimMode = iss.ControllerSimulationMode;

            iss.ControllerSimulationMode = ControllerSimulationMode.HandGestures;

            Vector3 underPointerPos = TestUtilities.PositionRelativeToPlayspace(new Vector3(0, 0, 2));
            Vector3 abovePointerPos = TestUtilities.PositionRelativeToPlayspace(new Vector3(0, -2, 2));
            Vector3 zeroPos         = TestUtilities.PositionRelativeToPlayspace(Vector3.zero);

            var rightHand = new TestHand(Handedness.Right);
            var leftHand  = new TestHand(Handedness.Left);

            // No hands, pointer not on cube, hand open
            cube.transform.localPosition = abovePointerPos;
            yield return(new WaitForFixedUpdate());

            yield return(null);

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Observe);

            // No hands, pointer on cube, hand open
            cube.transform.localPosition = underPointerPos;
            yield return(new WaitForFixedUpdate());

            yield return(null);

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.ObserveHover);

            // Right hand, pointer not on cube, hand open
            cube.transform.localPosition = abovePointerPos;
            yield return(new WaitForFixedUpdate());

            yield return(rightHand.Show(zeroPos));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Interact);

            // Both hands, pointer not on cube, hand open
            yield return(leftHand.Show(zeroPos));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Interact);

            // Left hand, pointer not on cube, hand open
            yield return(rightHand.Hide());

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Interact);

            // Left hand, pointer on cube, hand open
            cube.transform.localPosition = underPointerPos;
            yield return(new WaitForFixedUpdate());

            yield return(null);

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.InteractHover);

            // Both hands, pointer on cube, hand open
            yield return(rightHand.Show(zeroPos));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.InteractHover);

            // Right hand, pointer on cube, hand open
            yield return(leftHand.Hide());

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.InteractHover);

            // Right hand, pointer on cube, hand pinched
            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Pinch));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Select);
            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Open));

            // Left hand, pointer on cube, hand pinched
            yield return(rightHand.Hide());

            yield return(leftHand.Show(zeroPos));

            yield return(leftHand.SetGesture(ArticulatedHandPose.GestureId.Pinch));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Select);

            // Both hands, pointer on cube, left pinched & right open
            yield return(rightHand.Show(zeroPos));

            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Open));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Select);

            // Both hands, pointer on cube, both pinched
            yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Pinch));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Select);

            // Both hands, pointer on cube, right pinched & left open
            yield return(leftHand.SetGesture(ArticulatedHandPose.GestureId.Open));

            VerifyCursorState(inputSystem.GazeProvider.GazeCursor, CursorStateEnum.Select);

            // Restore the input simulation profile
            iss.ControllerSimulationMode = oldHandSimMode;
            yield return(null);
        }