示例#1
0
    // Update is called once per frame
    void Update()
    {
        UserPresence userPresence = TobiiAPI.GetUserPresence();

        if (userPresence.IsUserPresent())
        {
            lookatPoint = camera.ScreenToWorldPoint(TobiiAPI.GetGazePoint().Screen);
            var moveVector = new Vector3(lookatPoint.x - moveObject.transform.position.x, lookatPoint.y - moveObject.transform.position.y, 0).normalized;
            moveObject.transform.Translate(moveVector * Time.deltaTime * speed);
        }
    }
示例#2
0
    void Update()
    {
        scotOuter = theVig.VignetteOuterValueDistance;

        if (simAbs)
        {
            noUser = true;
        }
        else
        {
            noUser = false;
        }

        if (Input.GetKeyUp(KeyCode.R)) //Reset
        {
            cam.GetComponent <FinalVignetteCommandBuffer>().enabled = true;
            theVig.VignetteInnerColor.a = 0f;
            theVig.VignetteOuterColor.a = 0.0f;
        }
        if (Input.GetKeyUp(KeyCode.G) && gT.isOn) //glaucoma
        {
            cam.GetComponent <FinalVignetteCommandBuffer>().enabled = true;
            currSim = 0;
            theVig.VignetteInnerColor   = Color.black;
            theVig.VignetteOuterColor   = Color.black;
            theVig.VignetteInnerColor.a = 0f;
            theVig.VignetteOuterColor.a = 1f;
            theVig.VignetteFalloff      = 1f;
            maxScot = 1.5f;
            minScot = .05f;
            theVig.VignetteOuterValueDistance = 1.5f;
        }

        if (Input.GetKeyUp(KeyCode.C) && cT.isOn) //cataract
        {
            cam.GetComponent <FinalVignetteCommandBuffer>().enabled = true;
            currSim = 2;
            theVig.VignetteInnerColor   = catColour;
            theVig.VignetteOuterColor   = catColour;
            theVig.VignetteInnerColor.a = .3f;
            theVig.VignetteOuterColor.a = .1f;
            theVig.VignetteFalloff      = 1f;
            maxScot = 1.5f;
            minScot = .05f;
            theVig.VignetteOuterValueDistance = 1.5f;
        }

        if (Input.GetKeyUp(KeyCode.A) && aT.isOn)//AMD
        {
            cam.GetComponent <FinalVignetteCommandBuffer>().enabled = true;
            currSim = 1;
            theVig.VignetteInnerColor   = Color.black;
            theVig.VignetteOuterColor   = Color.gray;
            theVig.VignetteInnerColor.a = 1f;
            theVig.VignetteOuterColor.a = 0.05f;
            theVig.VignetteFalloff      = 2f;
            maxScot = 1.99f;
            minScot = .2f;
            theVig.VignetteOuterValueDistance = 0.5f;
        }

        if (Input.GetKey(KeyCode.DownArrow))
        {
            if (currSim == 0 && scotOuter > minScot)
            {
                theVig.VignetteOuterValueDistance -= (rateOfChange * Time.deltaTime);
            }
            if (currSim == 1 && scotOuter < maxScot)
            {
                theVig.VignetteOuterValueDistance += (rateOfChange * Time.deltaTime);
            }
            if (currSim == 2 && theVig.VignetteInnerColor.a < maxCatAlpha)
            {
                theVig.VignetteInnerColor.a += (rateOfChange * Time.deltaTime);
                theVig.VignetteOuterColor.a += (rateOfChange * Time.deltaTime);
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        if (Input.GetKey(KeyCode.UpArrow))
        {
            if (currSim == 0 && scotOuter < maxScot)
            {
                theVig.VignetteOuterValueDistance += (rateOfChange * Time.deltaTime);
            }

            if (currSim == 1 && scotOuter > minScot)
            {
                theVig.VignetteOuterValueDistance -= (rateOfChange * Time.deltaTime);
            }

            if (currSim == 2 && theVig.VignetteInnerColor.a > minCatAlpha)
            {
                theVig.VignetteInnerColor.a -= (rateOfChange * Time.deltaTime);
                theVig.VignetteOuterColor.a -= (rateOfChange * Time.deltaTime);
            }
        }

        if (TobiiAPI.IsConnected)
        {
            UserPresence userPresence = TobiiAPI.GetUserPresence();
            if (userPresence.IsUserPresent())
            {
                cam.GetComponent <FinalVignetteCommandBuffer>().enabled = true;
                noUser = false;
                GazePoint gazePoint = TobiiAPI.GetGazePoint();
                HeadPose  headPose  = TobiiAPI.GetHeadPose();
                theVig.VignetteCenter.x = gazePoint.Screen.x / cam.pixelWidth;
                theVig.VignetteCenter.y = gazePoint.Screen.y / cam.scaledPixelHeight;
            }
            else
            {
                noUser = true;
                StartCoroutine("StartAbsentMode");
            }
        }
        else
        {
            theVig.VignetteCenter.x = Input.mousePosition.x / cam.pixelWidth;
            theVig.VignetteCenter.y = Input.mousePosition.y / cam.pixelHeight;
        }
    }
    /// <summary>
    /// Lerping the color
    /// </summary>
    void Update()
    {
        if (_meshRenderer.material.color != _lerpColor)
        {
            _meshRenderer.material.color         = Color.Lerp(_meshRenderer.material.color, _lerpColor, _fadeSpeed);
            text.GetComponent <TextMesh>().color = Color.Lerp(_meshRenderer.material.color, textcolor, _fadeSpeed);
            //  Color.black;
        }

        // Change the color of the cube
        if (_gazeAwareComponent.HasGazeFocus)
        {
            SetLerpColor(selectionColor);
            text.GetComponent <TextMesh>().color = textcolor;
        }
        else
        {
            SetLerpColor(_deselectionColor);
        }

        if (enableHide)
        {
            if (_gazeAwareComponent.HasGazeFocus)
            {
                counter++;
            }

            else
            {
                if (counter > 0)
                {
                    _meshRenderer.enabled = false;
                    text.SetActive(false);
                }
            }

            if (text.activeSelf == false)
            {
                StartCoroutine(updateCoroutine(5, true));
                counter = 0;
            }
        }


        if (enableDesktopHide)
        {
            _userPresence = TobiiAPI.GetUserPresence();
            if (_userPresence.IsUserPresent())
            {
                //   print("A user is present in front of the screen.");
                if (text.activeSelf == false)
                {
                    StartCoroutine(updateCoroutine(1, true));
                }
            }
            else
            {
                //  print("User presence status is: " + _userPresence);
                StartCoroutine(updateCoroutine(5, false));
            }
        }
    }