public IEnumerator HeadGazeRayTest()
        {
            yield return(null);

            TestContext.Out.WriteLine("Get the head gaze ray");
            Ray ray = InputRayUtils.GetHeadGazeRay();

            Assert.True(ray.origin == Vector3.zero);
            Assert.True(ray.direction == new Vector3(0.0f, 0.0f, 1.0f));

            yield return(null);

            // Rotate the head (camera) 180 degrees
            TestContext.Out.WriteLine("Rotate the camera");
            CameraCache.Main.transform.Rotate(0, 180, 0);

            yield return(null);

            TestContext.Out.WriteLine("Get the head gaze ray");
            ray = InputRayUtils.GetHeadGazeRay();
            TestContext.Out.WriteLine($"origin: {ray.origin}");
            Assert.True(ray.origin == Vector3.zero);
            TestContext.Out.WriteLine($"direction: {ray.direction}");
            Assert.True(ray.direction == new Vector3(0.0f, 0.0f, -1.0f));
        }
コード例 #2
0
    public Vector3 GetHeadPosition()
    {
        if (InputRayUtils.TryGetRay(headTuple.Item1, headTuple.Item2, out Ray headRay))
        {
            return(headRay.origin + headRay.direction);
        }

        else
        {
            return(vectorNull);
        }
    }
コード例 #3
0
        void Update()
        {
            StringBuilder sb = new StringBuilder();

            foreach (var tuple in inputSources)
            {
                var sourceType = tuple.Item1;
                var handedness = tuple.Item2;
                sb.Append(sourceType.ToString() + " ");
                if (handedness != Handedness.Any)
                {
                    sb.Append(handedness.ToString());
                }
                sb.Append(": ");
                Ray myRay;
                if (InputRayUtils.TryGetRay(sourceType, handedness, out myRay))
                {
                    sb.Append($"pos: ({myRay.origin.x:F2}, {myRay.origin.y:F2}, {myRay.origin.z:F2}");
                    sb.Append($" forward: ({myRay.direction.x:F2}, {myRay.direction.y:F2}, {myRay.direction.z:F2}");
                }
                else
                {
                    sb.Append(" not available");
                }
                sb.AppendLine();
            }
            inputUtilsText.text = sb.ToString();

            // Iterate through all controllers output position, rotation, and other data from input
            // mappings on a controller.
            sb.Clear();
            foreach (var controller in CoreServices.InputSystem.DetectedControllers)
            {
                sb.AppendLine("Inputs for " + controller.InputSource.SourceName);
                sb.AppendLine();
                // Interactions for a controller is the list of inputs that this controller exposes
                foreach (MixedRealityInteractionMapping inputMapping in controller.Interactions)
                {
                    sb.AppendLine("\tDescription: " + inputMapping.Description);
                    sb.Append("\tAxisType: " + inputMapping.AxisType);
                    sb.Append("\tInputType: " + inputMapping.InputType);
                    sb.Append("\tPositionData: " + inputMapping.PositionData);
                    sb.Append("\tRotationData: " + inputMapping.RotationData);
                    sb.Append("\tBoolData: " + inputMapping.BoolData);
                    sb.Append("\tFloatData: " + inputMapping.FloatData);
                    sb.AppendLine();
                    sb.AppendLine();
                }
                sb.AppendLine();
            }
            rawDataText.text = sb.ToString();
        }
コード例 #4
0
        public void Update()
        {
            Ray myRay;

            if (InputRayUtils.TryGetRay(sourceType, handedness, out myRay))
            {
                transform.localPosition = myRay.origin;
                transform.localRotation = Quaternion.LookRotation(myRay.direction, Vector3.up);
                SetIsDataAvailable(true);
            }
            else
            {
                SetIsDataAvailable(false);
            }
        }
        public IEnumerator HandRayTest()
        {
            yield return(null);

            Vector3 rightHandOrigin = new Vector3(-0.3f, -0.1f, 0.5f);

            // Create a hand (we will use the right hand)
            TestHand rightHand = new TestHand(Handedness.Right);

            yield return(rightHand.Show(rightHandOrigin));

            Ray  ray;
            bool success;

            TestContext.Out.WriteLine("Get the right hand ray");
            success = InputRayUtils.TryGetHandRay(Handedness.Right, out ray);
            Assert.True(success, "TryGetHandRay did not succeed");
            TestUtilities.AssertAboutEqual(ray.origin, rightHandOrigin, "hand ray origin is not correct", 0.1f);
            TestUtilities.AssertAboutEqual(ray.direction, new Vector3(-0.7f, 0.2f, 0.7f), "hand ray direction is not correct", 0.1f);
        }