示例#1
0
        private void Update()
        {
            gazeOrigin = Camera.main.transform.position;

            gazeDirection = Camera.main.transform.forward;

            gazeStabilizer.UpdateHeadStability(gazeOrigin, Camera.main.transform.rotation);

            gazeOrigin = gazeStabilizer.StableHeadPosition;

            UpdateRaycast();
        }
示例#2
0
        private void Update()
        {
            // 2.a: Assign Camera's main transform position to gazeOrigin.
            gazeOrigin = Camera.main.transform.position;

            // 2.a: Assign Camera's main transform forward to gazeDirection.
            gazeDirection = Camera.main.transform.forward;

            // 3.a: Using gazeStabilizer, call function UpdateHeadStability.
            // Pass in gazeOrigin and Camera's main transform rotation.
            gazeStabilizer.UpdateHeadStability(gazeOrigin, Camera.main.transform.rotation);

            // 3.a: Using gazeStabilizer, get the StableHeadPosition and
            // assign it to gazeOrigin.
            gazeOrigin = gazeStabilizer.StableHeadPosition;

            UpdateRaycast();
        }
示例#3
0
        private void Update()
        {
            // 2.a: Assign Camera's main transform _position_ to gazeOrigin.
            gazeOrigin = Camera.main.transform.position;

            // 2.a: Assign Camera's main transform _forward_ to gazeDirection.
            gazeDirection = Camera.main.transform.forward;

            // 3.a: Using gazeStabilizer, call function UpdateHeadStability.
            // Pass in gazeOrigin and Camera's main transform rotation.
            // Note: 'main' refers to the first enabled camera tagged "MainCamera" (Read Only).
            gazeStabilizer.UpdateHeadStability(position: gazeOrigin,
                                               rotation: Camera.main.transform.rotation);

            // 3.a: Using gazeStabilizer, get the StableHeadPosition and
            // assign it to gazeOrigin.
            gazeOrigin = gazeStabilizer.StableHeadPosition;

            UpdateRaycast();
        }
示例#4
0
        // Update is called once per frame
        void Update()
        {
            {
                gazeOrigin = Camera.main.transform.position;

                gazeDirection = Camera.main.transform.forward;

                gazeStabilizer.UpdateHeadStability(gazeOrigin, Camera.main.transform.rotation);

                gazeOrigin = gazeStabilizer.StableHeadPosition;

                UpdateRaycast();
            }

            // Do a raycast into the world based on the user's
            // head position and orientation.
            var headPosition   = Camera.main.transform.position;
            var gazeDirection2 = Camera.main.transform.forward;

            RaycastHit hitInfo;

            if (Physics.Raycast(headPosition, gazeDirection2, out hitInfo))
            {
                // If the raycast hit a hologram...
                // Display the cursor mesh.
                meshRenderer.enabled = true;

                // Move the cursor to the point where the raycast hit.
                this.transform.position = hitInfo.point;

                // Rotate the cursor to hug the surface of the hologram.
                this.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal);
            }
            else
            {
                // If the raycast did not hit a hologram, hide the cursor mesh.
                meshRenderer.enabled = false;
            }
        }