Beispiel #1
0
        private void UpdateThePosition()
        {
            gazeVis.SetActive(true);

            RaycastHit hitInformation;

            //Get raycast from gaze
            smiInstance.smi_GetRaycastHitFromGaze(out hitInformation);
            if (hitInformation.collider != null)
            {
                gazeVis.transform.position      = hitInformation.point;
                gazeVis.transform.localRotation = smiInstance.transform.rotation;
                gazeVis.transform.localScale    = initialeScale * hitInformation.distance;
                gazeVis.transform.LookAt(Camera.main.transform);
                gazeVis.transform.transform.rotation *= Quaternion.Euler(0, 180, 0);
            }
            else
            {
                //If the raycast does not collide with any object, put it far away.
                float   distance = 100;
                Vector3 scale    = initialeScale * distance;
                Ray     gazeRay  = smiInstance.smi_GetRayFromGaze();

                gazeVis.transform.position = gazeRay.origin + Vector3.Normalize(gazeRay.direction) * distance;
                gazeVis.transform.rotation = smiInstance.transform.rotation;
                if (gazeRay.direction != Vector3.zero)
                {
                    gazeVis.transform.localScale = scale;
                }
                else
                {
                    gazeVis.transform.localScale = Vector3.zero;
                }
            }

            //Toggle the gaze cursor by Key "g"
            if (Input.GetKeyDown(KeyCode.G))
            {
                gazeVis.GetComponent <MeshRenderer>().enabled = !(gazeVis.GetComponent <MeshRenderer>().enabled);
            }
        }