コード例 #1
0
        public IEnumerator SetGesture(ArticulatedHandPose.GestureId newGestureId)
        {
            gestureId = newGestureId;
            yield return(PlayModeTestUtilities.MoveHandFromTo(position, position, 1, gestureId, handedness, simulationService));

            yield return(new WaitForFixedUpdate());
        }
コード例 #2
0
 public static SimulatedHandData.HandJointDataGenerator GenerateHandPose(ArticulatedHandPose.GestureId gesture, Handedness handedness, Vector3 worldPosition, Quaternion rotation)
 {
     return((jointsOut) =>
     {
         ArticulatedHandPose gesturePose = ArticulatedHandPose.GetGesturePose(gesture);
         gesturePose.ComputeJointPoses(handedness, rotation, worldPosition, jointsOut);
     });
 }
コード例 #3
0
 public static SimulatedHandData.HandJointDataGenerator GenerateHandPose(ArticulatedHandPose.GestureId gesture, Handedness handedness, Vector3 worldPosition, Quaternion rotation)
 {
     return((jointsOut) =>
     {
         ArticulatedHandPose gesturePose = SimulatedArticulatedHandPoses.GetGesturePose(gesture);
         Quaternion worldRotation = rotation * CameraCache.Main.transform.rotation;
         gesturePose.ComputeJointPoses(handedness, worldRotation, worldPosition, jointsOut);
     });
 }
コード例 #4
0
 public static SimulatedHandData.HandJointDataGenerator GenerateHandPose(ArticulatedHandPose.GestureId gesture, Handedness handedness, Vector3 screenPosition)
 {
     return((jointsOut) =>
     {
         ArticulatedHandPose gesturePose = ArticulatedHandPose.GetGesturePose(gesture);
         Quaternion rotation = Quaternion.identity;
         Vector3 position = CameraCache.Main.ScreenToWorldPoint(screenPosition);
         gesturePose.ComputeJointPoses(handedness, rotation, position, jointsOut);
     });
 }
コード例 #5
0
 /// <summary>
 /// Changes the hand's pose to the given gesture.  Does not animate the hand between the current pose and new pose.
 /// </summary>
 /// <param name="newGestureId">The new hand pose</param>
 /// <param name="waitForFixedUpdate">If true, waits for a fixed update after moving to the new pose.</param>
 public IEnumerator SetGesture(ArticulatedHandPose.GestureId newGestureId, bool waitForFixedUpdate = true)
 {
     gestureId = newGestureId;
     for (var iter = PlayModeTestUtilities.MoveHand(position, position, gestureId, handedness, simulationService, 1); iter.MoveNext();)
     {
         yield return(iter.Current);
     }
     if (waitForFixedUpdate)
     {
         yield return(new WaitForFixedUpdate());
     }
 }
コード例 #6
0
 private ArticulatedHandPose.GestureId ToggleGesture(ArticulatedHandPose.GestureId gesture)
 {
     if (UnityEngine.Input.GetMouseButtonDown(0))
     {
         return(gesture != profile.LeftMouseHandGesture ? profile.LeftMouseHandGesture : profile.DefaultHandGesture);
     }
     else if (UnityEngine.Input.GetMouseButtonDown(1))
     {
         return(gesture != profile.RightMouseHandGesture ? profile.RightMouseHandGesture : profile.DefaultHandGesture);
     }
     else if (UnityEngine.Input.GetMouseButtonDown(2))
     {
         return(gesture != profile.MiddleMouseHandGesture ? profile.MiddleMouseHandGesture : profile.DefaultHandGesture);
     }
     else
     {
         // 'None' will not change the gesture
         return(ArticulatedHandPose.GestureId.None);
     }
 }
コード例 #7
0
 private ArticulatedHandPose.GestureId ToggleGesture(ArticulatedHandPose.GestureId gesture)
 {
     // See comments in SelectGesture for why both the button down and gesture are checked.
     if (KeyInputSystem.GetKeyDown(profile.InteractionButton) && profile.LeftMouseHandGesture != ArticulatedHandPose.GestureId.None)
     {
         return(gesture != profile.LeftMouseHandGesture ? profile.LeftMouseHandGesture : profile.DefaultHandGesture);
     }
     else if (KeyInputSystem.GetKeyDown(profile.MouseLookButton) && profile.RightMouseHandGesture != ArticulatedHandPose.GestureId.None)
     {
         return(gesture != profile.RightMouseHandGesture ? profile.RightMouseHandGesture : profile.DefaultHandGesture);
     }
     else if (KeyInputSystem.GetKeyDown(KeyBinding.FromMouseButton(KeyBinding.MouseButton.Middle)) && profile.MiddleMouseHandGesture != ArticulatedHandPose.GestureId.None)
     {
         return(gesture != profile.MiddleMouseHandGesture ? profile.MiddleMouseHandGesture : profile.DefaultHandGesture);
     }
     else
     {
         // 'None' will not change the gesture
         return(ArticulatedHandPose.GestureId.None);
     }
 }
コード例 #8
0
 private ArticulatedHandPose.GestureId ToggleGesture(ArticulatedHandPose.GestureId gesture)
 {
     // See comments in SelectGesture for why both the button down and gesture are checked.
     if (UnityEngine.Input.GetMouseButtonDown(0) && profile.LeftMouseHandGesture != ArticulatedHandPose.GestureId.None)
     {
         return(gesture != profile.LeftMouseHandGesture ? profile.LeftMouseHandGesture : profile.DefaultHandGesture);
     }
     else if (UnityEngine.Input.GetMouseButtonDown(1) && profile.RightMouseHandGesture != ArticulatedHandPose.GestureId.None)
     {
         return(gesture != profile.RightMouseHandGesture ? profile.RightMouseHandGesture : profile.DefaultHandGesture);
     }
     else if (UnityEngine.Input.GetMouseButtonDown(2) && profile.MiddleMouseHandGesture != ArticulatedHandPose.GestureId.None)
     {
         return(gesture != profile.MiddleMouseHandGesture ? profile.MiddleMouseHandGesture : profile.DefaultHandGesture);
     }
     else
     {
         // 'None' will not change the gesture
         return(ArticulatedHandPose.GestureId.None);
     }
 }
コード例 #9
0
        internal static IEnumerator MoveHandFromTo(
            Vector3 startPos, Vector3 endPos, int numSteps,
            ArticulatedHandPose.GestureId gestureId, Handedness handedness, InputSimulationService inputSimulationService)
        {
            Debug.Assert(handedness == Handedness.Right || handedness == Handedness.Left, "handedness must be either right or left");
            bool isPinching = gestureId == ArticulatedHandPose.GestureId.Grab || gestureId == ArticulatedHandPose.GestureId.Pinch || gestureId == ArticulatedHandPose.GestureId.PinchSteadyWrist;

            for (int i = 1; i <= numSteps; i++)
            {
                float   t                 = i / (float)numSteps;
                Vector3 handPos           = Vector3.Lerp(startPos, endPos, t);
                var     handDataGenerator = GenerateHandPose(
                    gestureId,
                    handedness,
                    handPos,
                    Quaternion.identity);
                SimulatedHandData handData = handedness == Handedness.Right ? inputSimulationService.HandDataRight : inputSimulationService.HandDataLeft;
                handData.Update(true, isPinching, handDataGenerator);
                yield return(null);
            }
        }
        private IEnumerator TestTouchableDistances(BaseNearInteractionTouchable touchable, float colliderThickness, GameObject objectDownExpected)
        {
            Handedness handedness = Handedness.Right;

            ArticulatedHandPose.GestureId gesture = ArticulatedHandPose.GestureId.Open;

            yield return(PlayModeTestUtilities.ShowHand(handedness, inputSim));

            PokePointer       pokePointer = null;
            IMixedRealityHand hand        = HandJointUtils.FindHand(handedness);

            Assert.IsNotNull(hand);
            foreach (IMixedRealityPointer pointer in hand.InputSource.Pointers)
            {
                pokePointer = pointer as PokePointer;
                if (pokePointer)
                {
                    break;
                }
            }
            Assert.IsNotNull(pokePointer);
            float touchableDistance = pokePointer.TouchableDistance;

            float debounceThreshold = 0.01f;

            touchable.DebounceThreshold = debounceThreshold;

            Vector3 center = touchable.transform.position;

            float   margin    = 0.001f;
            Vector3 pStart    = center + new Vector3(0, 0, -touchableDistance - 0.5f);
            Vector3 pTouch    = center + new Vector3(0, 0, -touchableDistance + margin);
            Vector3 pPoke     = center + new Vector3(0, 0, -colliderThickness + margin);
            Vector3 pDebounce = center + new Vector3(0, 0, -colliderThickness - touchable.DebounceThreshold - margin);
            Vector3 pEnd      = center + new Vector3(0, 0, touchableDistance + 0.5f);

            // Test return beyond DebounceThreshold
            yield return(PlayModeTestUtilities.MoveHand(pStart, pStart, gesture, handedness, inputSim, 1));

            Assert.IsNull(pokePointer.ClosestProximityTouchable);
            Assert.IsNull(pokePointer.CurrentTouchableObjectDown);

            yield return(PlayModeTestUtilities.MoveHand(pStart, pTouch, gesture, handedness, inputSim));

            Assert.AreEqual(touchable, pokePointer.ClosestProximityTouchable);
            Assert.IsNull(pokePointer.CurrentTouchableObjectDown);

            yield return(PlayModeTestUtilities.MoveHand(pTouch, pPoke, gesture, handedness, inputSim));

            Assert.AreEqual(touchable, pokePointer.ClosestProximityTouchable);
            Assert.AreEqual(objectDownExpected, pokePointer.CurrentTouchableObjectDown);

            yield return(PlayModeTestUtilities.MoveHand(pPoke, pDebounce, gesture, handedness, inputSim));

            Assert.AreEqual(touchable, pokePointer.ClosestProximityTouchable);
            Assert.IsNull(pokePointer.CurrentTouchableObjectDown);

            yield return(PlayModeTestUtilities.MoveHand(pDebounce, pStart, gesture, handedness, inputSim));

            Assert.IsNull(pokePointer.ClosestProximityTouchable);
            Assert.IsNull(pokePointer.CurrentTouchableObjectDown);

            // Test touchable distance behind the surface
            yield return(PlayModeTestUtilities.MoveHand(pStart, pStart, gesture, handedness, inputSim, 1));

            Assert.IsNull(pokePointer.ClosestProximityTouchable);
            Assert.IsNull(pokePointer.CurrentTouchableObjectDown);

            yield return(PlayModeTestUtilities.MoveHand(pStart, pTouch, gesture, handedness, inputSim));

            Assert.AreEqual(touchable, pokePointer.ClosestProximityTouchable);
            Assert.IsNull(pokePointer.CurrentTouchableObjectDown);

            yield return(PlayModeTestUtilities.MoveHand(pTouch, pPoke, gesture, handedness, inputSim));

            Assert.AreEqual(touchable, pokePointer.ClosestProximityTouchable);
            Assert.AreEqual(objectDownExpected, pokePointer.CurrentTouchableObjectDown);

            yield return(PlayModeTestUtilities.MoveHand(pPoke, pEnd, gesture, handedness, inputSim));

            Assert.IsNull(pokePointer.ClosestProximityTouchable);
            Assert.IsNull(pokePointer.CurrentTouchableObjectDown);

            yield return(PlayModeTestUtilities.MoveHand(pEnd, pDebounce, gesture, handedness, inputSim));

            Assert.AreEqual(touchable, pokePointer.ClosestProximityTouchable);
            Assert.IsNull(pokePointer.CurrentTouchableObjectDown);

            yield return(PlayModeTestUtilities.MoveHand(pDebounce, pStart, gesture, handedness, inputSim));

            Assert.IsNull(pokePointer.ClosestProximityTouchable);
            Assert.IsNull(pokePointer.CurrentTouchableObjectDown);

            yield return(PlayModeTestUtilities.HideHand(handedness, inputSim));
        }
コード例 #11
0
        public static IEnumerator ShowHand(Handedness handedness, InputSimulationService inputSimulationService, ArticulatedHandPose.GestureId handPose, Vector3 handLocation)
        {
            yield return(null);

            SimulatedHandData handData = handedness == Handedness.Right ? inputSimulationService.HandDataRight : inputSimulationService.HandDataLeft;

            handData.Update(true, false, GenerateHandPose(handPose, handedness, handLocation, Quaternion.identity));

            // Wait one frame for the hand to actually appear
            yield return(null);
        }
コード例 #12
0
        public static IEnumerator SetHandRotation(Quaternion fromRotation, Quaternion toRotation, Vector3 handPos, ArticulatedHandPose.GestureId gestureId,
                                                  Handedness handedness, int numSteps, InputSimulationService inputSimulationService)
        {
            Debug.Assert(handedness == Handedness.Right || handedness == Handedness.Left, "handedness must be either right or left");
            bool isPinching = gestureId == ArticulatedHandPose.GestureId.Grab || gestureId == ArticulatedHandPose.GestureId.Pinch || gestureId == ArticulatedHandPose.GestureId.PinchSteadyWrist;

            for (int i = 1; i <= numSteps; i++)
            {
                float      t                 = i / (float)numSteps;
                Quaternion handRotation      = Quaternion.Lerp(fromRotation, toRotation, t);
                var        handDataGenerator = GenerateHandPose(
                    gestureId,
                    handedness,
                    handPos,
                    handRotation);
                SimulatedHandData handData = handedness == Handedness.Right ? inputSimulationService.HandDataRight : inputSimulationService.HandDataLeft;
                handData.Update(true, isPinching, handDataGenerator);
                yield return(null);
            }
        }
コード例 #13
0
 public static IEnumerator SetHandState(Vector3 handPos, ArticulatedHandPose.GestureId gestureId, Handedness handedness, InputSimulationService inputSimulationService)
 {
     yield return(MoveHand(handPos, handPos, ArticulatedHandPose.GestureId.Pinch, handedness, inputSimulationService, 2));
 }
コード例 #14
0
        public static IEnumerator ShowHand(Handedness handedness, InputSimulationService inputSimulationService, ArticulatedHandPose.GestureId handPose, Vector3 handLocation)
        {
            yield return(null);

            Debug.Assert(
                ((inputSimulationService.ControllerSimulationMode == ControllerSimulationMode.HandGestures) ||
                 (inputSimulationService.ControllerSimulationMode == ControllerSimulationMode.ArticulatedHand)),
                "The current ControllerSimulationMode must be HandGestures or ArticulatedHand!");
            SimulatedHandData handData = handedness == Handedness.Right ? inputSimulationService.HandDataRight : inputSimulationService.HandDataLeft;

            handData.Update(true, false, GenerateHandPose(handPose, handedness, handLocation, Quaternion.identity));

            // Wait one frame for the hand to actually appear
            yield return(null);
        }