// Update is called once per frame
    void Update()
    {
        // See if we are gazing on this object
        if (gazeAwareComponent.HasGazeFocus)
        {
            // change the material to show that it is selected
            cube.GetComponent <Renderer>().material = selectedMaterial;

            // take the head pose information from the user
            var headPose = TobiiAPI.GetHeadPose();

            // translate the head pose to a position for rotation of cube
            if (headPose.IsRecent())
            {
                cube.transform.rotation = Quaternion.Lerp(cube.transform.rotation, headPose.Rotation, Time.unscaledDeltaTime * responsiveness);
            }
        }
        else
        {
            // change back to deselected material depending on if eye tracker is connected
            if (TobiiAPI.IsConnected)
            {
                cube.GetComponent <Renderer>().material = deselectedMaterial;
            }
            else
            {
                cube.GetComponent <Renderer>().material = noTobiiMaterial;
            }
        }
    }
Beispiel #2
0
        private void Update()
        {
            var headPose = TobiiAPI.GetHeadPose();

            if (headPose.IsRecent())
            {
                var rot = headPose.Rotation;
                if (isMirrored)
                {
                    rot.y *= -1;
                    rot.z *= -1;
                }
                _head.localRotation = Quaternion.Lerp(
                    _head.localRotation,
                    rot,
                    Time.deltaTime * responsiveness
                    );

                var pos = headPose.Position;
                // Debug.Log($"Head Pos = {pos.x:0.00},{pos.y:0.00},{pos.z:0.00}");
                _root.localPosition = new Vector3(
                    pos.x * (-0.001f),
                    pos.y * 0.001f,
                    0
                    );
            }

            var gazePoint = TobiiAPI.GetGazePoint();

            if (gazePoint.IsRecent())
            {
                var fov          = _cam.fieldOfView;
                var mirrorFactor = isMirrored ? -1f : 1f;
                var eyeRotation  = Quaternion.Euler(
                    (gazePoint.Viewport.y - 0.5f) * fov * eyeRotationApplyRate * (-1),
                    (gazePoint.Viewport.x - 0.5f) * fov * _cam.aspect * eyeRotationApplyRate * mirrorFactor,
                    0
                    );

                _leftEye.localRotation  = eyeRotation;
                _rightEye.localRotation = eyeRotation;
            }

            _eyeClosed =
                TobiiAPI.GetUserPresence().IsUserPresent() && (Time.unscaledTime - gazePoint.Timestamp) > eyeCloseJudgeLimitTime ||
                !gazePoint.IsRecent();

            if (_eyeClosed)
            {
                _blinkValue = 1.0f;
            }
            else
            {
                _blinkValue = Mathf.Max(_blinkValue - eyeOpenRate * Time.deltaTime, 0f);
            }

            blendShape.AccumulateValue(lBlinkKey, _blinkValue);
            blendShape.AccumulateValue(rBlinkKey, _blinkValue);
            blendShape.Apply();
        }
    void Update()
    {
        var headPose = TobiiAPI.GetHeadPose();

        if (headPose.IsRecent())
        {
            Head.transform.localRotation = Quaternion.Lerp(Head.transform.localRotation, headPose.Rotation, Time.unscaledDeltaTime * Responsiveness);
        }

        var gazePoint = TobiiAPI.GetGazePoint();

        if (gazePoint.IsRecent() && Camera.main != null)
        {
            var eyeRotation = Quaternion.Euler((gazePoint.Viewport.y - 0.5f) * Camera.main.fieldOfView, (gazePoint.Viewport.x - 0.5f) * Camera.main.fieldOfView * Camera.main.aspect, 0);

            var eyeLocalRotation = Quaternion.Inverse(Head.transform.localRotation) * eyeRotation;

            var pitch = eyeLocalRotation.eulerAngles.x;
            if (pitch > 180)
            {
                pitch -= 360;
            }
            var yaw = eyeLocalRotation.eulerAngles.y;
            if (yaw > 180)
            {
                yaw -= 360;
            }

            LeftEyePosition  = new Vector2(Mathf.Sin(yaw * Mathf.Deg2Rad), Mathf.Sin(pitch * Mathf.Deg2Rad));
            RightEyePosition = new Vector2(Mathf.Sin(yaw * Mathf.Deg2Rad), Mathf.Sin(pitch * Mathf.Deg2Rad));
        }

        LeftEyeClosed = RightEyeClosed = TobiiAPI.GetUserPresence().IsUserPresent() && (Time.unscaledTime - gazePoint.Timestamp) > 0.15f || !gazePoint.IsRecent();
    }
Beispiel #4
0
    // Update is called once per frame
    void Update()
    {
        // See if we are gazing on this object
        if (gazeAwareComponent.HasGazeFocus)
        {
            // set the time started to the current time when the gaze has begun
            if (gazeStarted == false)
            {
                gazeTimeStarted = Time.time;
                gazeStarted     = true;
            }

            // start changing the color of the head
            if (gazeTimeElasped < gazeTime)
            {
                // set the elapsed time
                gazeTimeElasped = Time.time - gazeTimeStarted;

                // lerp the material color to show that it is about to be selected
                float lerpTime = Mathf.PingPong(gazeTimeElasped, gazeTime) / gazeTime;
                renderer.material.Lerp(deselectedMaterial, selectedMaterial, lerpTime);
            }

            if (gazeTimeElasped > gazeTime)
            {
                // take the head pose information from the user
                var headPose = TobiiAPI.GetHeadPose();

                // translate the head pose to a position for rotation of head
                if (headPose.IsRecent())
                {
                    // filter out x and z axis from obeject movement
                    Quaternion headPoseNoXZaxis = Quaternion.Euler(0, headPose.Rotation.eulerAngles.y, 0);

                    // invert axes from head position
                    headPoseNoXZaxis = Quaternion.Inverse(headPoseNoXZaxis);

                    // move the head based on y axis movement
                    head.transform.rotation = Quaternion.Lerp(head.transform.rotation, headPoseNoXZaxis, Time.unscaledDeltaTime * responsiveness);
                }
            }
        }
        else
        {
            // change back to deselected material depending on if eye tracker is connected
            if (TobiiAPI.IsConnected)
            {
                renderer.material = deselectedMaterial;
            }
            else
            {
                renderer.material = noTobiiMaterial;
            }

            // reset the gazeStarted flag & gazeTimeElapsed
            gazeStarted     = false;
            gazeTimeElasped = 0.0f;
        }
    }
Beispiel #5
0
    // Update is called once per frame
    void FixedUpdate()
    {
        HeadPose headPose = TobiiAPI.GetHeadPose();

        if (headPose.IsRecent())
        {
            transform.rotation = Quaternion.Lerp(transform.rotation, headPose.Rotation, Mathf.Min(Time.time * speed, 0.02f));
        }
    }
Beispiel #6
0
 void Update()
 {
     var headPose = TobiiAPI.GetHeadPose();
     //if (headPose.IsRecent())
     {
         Head.transform.localRotation = Quaternion.Lerp(Head.transform.localRotation, headPose.Rotation, Time.unscaledDeltaTime * Responsiveness);
         //print("HeadPose Position (X,Y,Z): " + headPose.Position.x + ", " + headPose.Position.y + ", " + headPose.Position.z);
         print("HeadPose Rotation (X,Y,Z): " + headPose.Rotation.eulerAngles.x + ", " + headPose.Rotation.eulerAngles.y + ", " + headPose.Rotation.eulerAngles.z);
     }
 }
    void Update()
    {
        HeadPose headPose = TobiiAPI.GetHeadPose();

        Debug.Log("hoge");
        if (headPose.IsRecent())
        {
            Debug.Log("HeadPose Position (X,Y,Z): " + headPose.Position.x + ", " + headPose.Position.y + ", " + headPose.Position.z);
            Debug.Log("HeadPose Rotation (X,Y,Z): " + headPose.Rotation.eulerAngles.x + ", " + headPose.Rotation.eulerAngles.y + ", " + headPose.Rotation.eulerAngles.z);
        }
    }
Beispiel #8
0
 // Update is called once per frame
 void Update()
 {
     up = TobiiAPI.GetUserPresence();
     if (physics == true)
     {
         if (up == UserPresence.Present)
         {
             hp = TobiiAPI.GetHeadPose();
             if (hp.Rotation.eulerAngles.y > 180)
             {
                 if (hp.Rotation.eulerAngles.y < 330)
                 {
                     rb.AddForce((360 - hp.Rotation.eulerAngles.y) * (-1) / 5, 0, 0, ForceMode.Force);
                 }
             }
             if (hp.Rotation.eulerAngles.y < 180)
             {
                 if (hp.Rotation.eulerAngles.y > 20)
                 {
                     rb.AddForce(hp.Rotation.eulerAngles.y / 5, 0, 0, ForceMode.Force);
                 }
             }
         }
     }
     if (floorPresent == true)
     {
         if (up == UserPresence.NotPresent)
         {
             floor.active = false;
             floorPresent = false;
         }
     }
     if (gaze.HasGazeFocus)
     {
         if (physics == false)
         {
             if (dwellTime == 0)
             {
                 dwellTime = Time.time;
             }
             if (Time.time - dwellTime >= 0.4)
             {
                 cube.AddComponent <Rigidbody>();
                 rb      = cube.GetComponent <Rigidbody>();
                 physics = true;
             }
         }
     }
     if (!gaze.HasGazeFocus)
     {
         dwellTime = 0;
     }
 }
Beispiel #9
0
 private void get_degree()
 {
     if (!standard_input)
     {
         hp           = TobiiAPI.GetHeadPose();
         input_degree = hp.Rotation.eulerAngles.y;
     }
     else
     {
         input_degree = Input.GetAxis("Horizontal") * (-1) * 21;
         input_degree = input_degree + 180;
     }
 }
Beispiel #10
0
    private void UpdateHeadPose()
    {
        if (!IsEnabled || !HasRecentHeadPoseData())
        {
            HeadRotationScalar = Mathf.Lerp(HeadRotationScalar, 0, Time.unscaledDeltaTime * ResetResponsiveness);
        }
        else
        {
            HeadRotationScalar = !IsAiming?Mathf.Lerp(HeadRotationScalar, 1, Time.unscaledDeltaTime *ResetResponsiveness) : 0;
        }

        var headPose = TobiiAPI.GetHeadPose();
        var currentFilterredHeadPose = _filteredHeadPose;

        if (headPose.IsRecent())
        {
            _currentHeadPose = headPose.Rotation;
            UpdateFilteredHeadPose(_currentHeadPose, Time.unscaledDeltaTime);
            _previousFilteredHeadPose             = currentFilterredHeadPose;
            _accumulatedTimeDeltaForHeadPoseLerp -= (1.0f / HeadTrackingFrequency);
        }

        _accumulatedTimeDeltaForHeadPoseLerp += Time.unscaledDeltaTime;
        _accumulatedTimeDeltaForHeadPoseLerp  = Mathf.Clamp(_accumulatedTimeDeltaForHeadPoseLerp, 0.0f, 1.0f / HeadTrackingFrequency);

        var lerpStep = _accumulatedTimeDeltaForHeadPoseLerp * HeadTrackingFrequency;

        _lerpedFilteredHeadPose.x = Mathf.Lerp(_previousFilteredHeadPose.x, _filteredHeadPose.x, lerpStep);
        _lerpedFilteredHeadPose.y = Mathf.Lerp(_previousFilteredHeadPose.y, _filteredHeadPose.y, lerpStep);

        /* Update current HeadViewSensitivityScale */
        if (!HasRecentGazePointData())
        {
            _currentHeadViewSensitivityScale = Mathf.Lerp(_currentHeadViewSensitivityScale, HeadViewSensitivityScaleHeadOnly,
                                                          10 * Time.unscaledDeltaTime);
        }
        else
        {
            _currentHeadViewSensitivityScale = Mathf.Lerp(_currentHeadViewSensitivityScale, HeadViewSensitivityScale,
                                                          10 * Time.unscaledDeltaTime);
        }

        var centeredNormalizedHeadPose = CreateCenterNormalizedHeadPose(_lerpedFilteredHeadPose);

        var headViewAngles = GetHeadViewAngles(centeredNormalizedHeadPose);

        _headYawOffset   = headViewAngles.y;
        _headPitchOffset = headViewAngles.x * 1.5f;
    }
Beispiel #11
0
    // Update is called once per frame
    void Update()
    {
        HeadPose headPose = TobiiAPI.GetHeadPose();


        Vector3 direction = Vector3.zero;

        if (headPose.IsRecent())
        {
            print("HeadPose Position (X,Y,Z): " + headPose.Position.x + ", " + headPose.Position.y + ", " + headPose.Position.z);

            if (headPose.Position.y < 50.0f)
            {
                direction = Vector3.down;
            }
            if (headPose.Position.y > 150.0f)
            {
                direction = Vector3.up;
            }
            if (headPose.Position.x < -50.0f)
            {
                direction = Vector3.left;
            }
            if (headPose.Position.x > 50.0f)
            {
                direction = Vector3.right;
            }
            if (headPose.Position.z > 600.0f)
            {
                direction = Vector3.back;
            }
            if (headPose.Position.z < 450.0f)
            {
                direction = Vector3.forward;
            }

            if (direction != Vector3.zero)
            {
                transform.Translate(direction * speed * Time.deltaTime, Space.Self);
            }
        }

        // Exit Application
        if (Input.GetKey("escape"))
        {
            Application.Quit();
        }
    }
    void Update()
    {
        var headPose = TobiiAPI.GetHeadPose();

        if (headPose.IsRecent())
        {
            Head.transform.localRotation = Quaternion.Lerp(Head.transform.localRotation, headPose.Rotation, Time.unscaledDeltaTime * Responsiveness);
        }

        var gazePoint = TobiiAPI.GetGazePoint();

        if (gazePoint.IsRecent() && Camera.main != null)
        {
            var eyeRotation = Quaternion.Euler((gazePoint.Viewport.y - 0.5f) * Camera.main.fieldOfView, (gazePoint.Viewport.x - 0.5f) * Camera.main.fieldOfView * Camera.main.aspect, 0);

            var eyeLocalRotation = Quaternion.Inverse(Head.transform.localRotation) * eyeRotation;

            var pitch = eyeLocalRotation.eulerAngles.x;
            if (pitch > 180)
            {
                pitch -= 360;
            }
            var yaw = eyeLocalRotation.eulerAngles.y;
            if (yaw > 180)
            {
                yaw -= 360;
            }

            LeftEyePosition  = new Vector2(Mathf.Sin(yaw * Mathf.Deg2Rad), Mathf.Sin(pitch * Mathf.Deg2Rad));
            RightEyePosition = new Vector2(Mathf.Sin(yaw * Mathf.Deg2Rad), Mathf.Sin(pitch * Mathf.Deg2Rad));
        }

        LeftEyeClosed = RightEyeClosed = TobiiAPI.GetUserPresence().IsUserPresent() && (Time.unscaledTime - gazePoint.Timestamp) > 0.15f || !gazePoint.IsRecent();
        //왼쪽,오른쪽 눈 감긴 여부 = 사용자 존재(사용자가 눈 추적 화면 앞에 있음) && (게임시작으로부터 경과한 시간 - 시선 포인트의 타임 스탬프(눈 이미지가 촬영 될 때 획득)) > 0.15f || gazePoint 유효 여부
        // gazePoint가 유효하지 않으면 true

        Debug.Log(LeftEyeClosed + " , " + RightEyeClosed);                            //값 확인

        headposeR_t.text = "HeadPoseR : " + Head.transform.localRotation.eulerAngles; // 머리 회전값(오일러 각도) 출력
    }
Beispiel #13
0
 // Update is called once per frame
 void Update()
 {
     if (physics == true)
     {
         hp = TobiiAPI.GetHeadPose();
         if (hp.Rotation.eulerAngles.x > 180)
         {
             if (hp.Rotation.eulerAngles.x < 345)
             {
                 rb.AddForce(0, (360 - hp.Rotation.eulerAngles.x) / 2, 0, ForceMode.Force);
             }
         }
         if (hp.Rotation.eulerAngles.x < 180)
         {
             if (hp.Rotation.eulerAngles.x > 30)
             {
                 rb.AddForce(0, ((hp.Rotation.eulerAngles.x) * (-1)) / 10, 0, ForceMode.Force);
             }
         }
     }
     if (gaze.HasGazeFocus)
     {
         if (physics == false)
         {
             if (dwellTime == 0)
             {
                 dwellTime = Time.time;
             }
             if (Time.time - dwellTime >= 0.4)
             {
                 physics = true;
             }
         }
     }
     if (!gaze.HasGazeFocus)
     {
         dwellTime = 0;
     }
 }
        void Update()
        {
            var headPose = TobiiAPI.GetHeadPose();

            if (headPose.IsRecent())
            {
                Debug.Log("hoge");
                head_rotation = headPose.Rotation.eulerAngles;
                //yaw角の正規化(原点から±角度にする)
                if (head_rotation.y > 180)
                {
                    yaw_val = head_rotation.y - 360;
                }
                else
                {
                    yaw_val = head_rotation.y;
                }
                //pitch角の正規化(原点から±角度にする)
                if (head_rotation.x > 180)
                {
                    pitch_val = head_rotation.x - 360;
                }
                else
                {
                    pitch_val = head_rotation.x;
                }
                //roll角の正規化(原点から±角度にする)
                if (head_rotation.z > 180)
                {
                    roll_val = head_rotation.z - 360;
                }
                else
                {
                    roll_val = head_rotation.z;
                }
                //Debug.Log(head_rotation);
            }
        }
    private void UpdateHeadPose()
    {
        if (!IsEnabled)
        {
            HeadRotationScalar = Mathf.Lerp(HeadRotationScalar, 0, Time.unscaledDeltaTime * HeadViewResetResponsiveness);
        }
        else
        {
            HeadRotationScalar = !IsAiming?Mathf.Lerp(HeadRotationScalar, 1, Time.unscaledDeltaTime *HeadViewResetResponsiveness) : 0;
        }

        var headPose = TobiiAPI.GetHeadPose();
        var currentFilterredHeadPose = _filteredHeadPose;

        if (headPose.TimeStampMicroSeconds > _lastHeadPosePreciseTimestamp)
        {
            _lastHeadPosePreciseTimestamp = headPose.TimeStampMicroSeconds;
            _currentHeadPose = new Vector3(headPose.Rotation.Pitch, headPose.Rotation.Yaw, headPose.Rotation.Roll);
            UpdateFilteredHeadPose(_currentHeadPose, Time.unscaledDeltaTime);
            _previousFilteredHeadPose             = currentFilterredHeadPose;
            _accumulatedTimeDeltaForHeadPoseLerp -= (1.0f / HeadTrackingFrequency);
        }

        _accumulatedTimeDeltaForHeadPoseLerp += Time.unscaledDeltaTime;
        _accumulatedTimeDeltaForHeadPoseLerp  = Mathf.Clamp(_accumulatedTimeDeltaForHeadPoseLerp, 0.0f, 1.0f / HeadTrackingFrequency);

        var lerpStep = _accumulatedTimeDeltaForHeadPoseLerp * HeadTrackingFrequency;

        _lerpedFilteredHeadPose.X = Mathf.Lerp(_previousFilteredHeadPose.X, _filteredHeadPose.X, lerpStep);
        _lerpedFilteredHeadPose.Y = Mathf.Lerp(_previousFilteredHeadPose.Y, _filteredHeadPose.Y, lerpStep);

        var centeredNormalizedHeadPose = CreateCenterNormalizedHeadPose(_lerpedFilteredHeadPose);

        var headViewAngles = GetHeadViewAngles(centeredNormalizedHeadPose);

        HeadYawOffset   = -headViewAngles.Y;
        HeadPitchOffset = -headViewAngles.X * 1.5f;
    }
    // Update is called once per frame
    void Update()
    {
        headPose = TobiiAPI.GetHeadPose();

        /*
         * if (headPose.IsRecent())
         * {
         *
         *  //transform.localRotation = Quaternion.Lerp(transform.localRotation, headPose.Rotation, Time.unscaledDeltaTime * Responsiveness);
         *  transform.localRotation = Quaternion.Lerp(transform.localRotation, headPose.Rotation, Time.unscaledDeltaTime * Responsiveness);
         * }
         */
        var gazePoint = TobiiAPI.GetGazePoint();

        if (gazePoint.IsRecent() && Camera.main != null)
        {
            var eyeRotation = Quaternion.Euler((gazePoint.Viewport.y - 0.5f) * Camera.main.fieldOfView, (gazePoint.Viewport.x - 0.5f) * Camera.main.fieldOfView * Camera.main.aspect, 0);


            var eyeLocalRotation = Quaternion.Inverse(transform.localRotation) * eyeRotation;

            var pitch = eyeLocalRotation.eulerAngles.x;


            if (pitch > 180)
            {
                pitch -= 360;
            }
            var yaw = eyeLocalRotation.eulerAngles.y;
            if (yaw > 180)
            {
                yaw -= 360;
            }

            LeftEyePosition  = new Vector2(Mathf.Sin(yaw * Mathf.Deg2Rad), Mathf.Sin(pitch * Mathf.Deg2Rad));
            RightEyePosition = new Vector2(Mathf.Sin(yaw * Mathf.Deg2Rad), Mathf.Sin(pitch * Mathf.Deg2Rad));
        }
    }
Beispiel #17
0
    private void Update()
    {
        //Pauses the level
        UserPresence userPresence = TobiiAPI.GetUserPresence();
        HeadPose     headPose     = TobiiAPI.GetHeadPose();

        if (!m_levelManager.paused)
        {
            if (Input.GetButtonDown("Pause") || (GazeManager.TobiiConnected && (userPresence != UserPresence.Present || !headPose.IsValid)))
            {
                m_levelManager.TooglePause();
                Show();
                m_active = true;
            }
        }
        //Resume
        else if (m_active && Input.GetButtonDown("Pause"))
        {
            m_levelManager.TooglePause();
            Hide();
            m_active = false;
        }
    }
Beispiel #18
0
        public void UpdateBones()
        {
            HeadPose headPose = TobiiAPI.GetHeadPose();

            if (headPose.IsRecent())
            {
                Vector3 headPosition = new Vector3(-headPose.Position.x, headPose.Position.y, headPose.Position.z);
                headPosition     = SmoothPosition(lastHeadPosition, headPosition);
                lastHeadPosition = headPosition;

                headTarget.head.target.transform.position  = tracker.ToWorldPosition(headPosition / 1000);
                headTarget.head.target.confidence.position = 0.8F;

                Vector3    headAngles   = headPose.Rotation.eulerAngles;
                Quaternion headRotation = tracker.ToWorldOrientation(Quaternion.Euler(headAngles.x, headAngles.y + 180, headAngles.z));
                headRotation     = SmoothRotation(lastHeadRotation, headRotation);
                lastHeadRotation = headRotation;

                switch (rotationTrackingAxis)
                {
                case RotationTrackingAxis.XYZ:
                    headTarget.head.target.transform.rotation  = headRotation;
                    headTarget.head.target.confidence.rotation = 0.8F;
                    break;

                case RotationTrackingAxis.XY:
                    headRotation = Quaternion.LookRotation(headRotation * Vector3.forward);
                    headTarget.head.target.transform.rotation  = headRotation;
                    headTarget.head.target.confidence.rotation = 0.8F;
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #19
0
 private void FilterHeadPosition()
 {
     _headXFiltered = Mathf.Lerp(_headXFiltered, TobiiAPI.GetHeadPose().Position.X, HeadPositionSensitivity);
 }
Beispiel #20
0
    private bool HasRecentHeadPoseData()
    {
        var headPose = TobiiAPI.GetHeadPose();

        return(headPose.IsRecent(MaxTimeWithoutData));
    }
Beispiel #21
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;
        }
    }
    private void get_degree_head()
    {
        hp = TobiiAPI.GetHeadPose();
        float pose_x = hp.Rotation.eulerAngles.y;
        float pose_z = hp.Rotation.eulerAngles.x;
        float f      = 0.05f;

        bool  z          = false;
        bool  reverse    = false;
        float direction  = 20;
        bool  do_nothing = false;

        if (pose_x >= 180)
        {
            float amount = 360 - pose_x;
            if (amount > direction)
            {
                direction = amount;
                z         = false;
                reverse   = false;
            }
            //input_degree_X = 1 / f + 180;
        }
        if (pose_x < 180)
        {
            float amount = pose_x;
            if (amount > direction)
            {
                direction = amount;
                z         = false;
                reverse   = true;
            }
            //input_degree_X = -1 / f + 180;
        }

        if (direction == 20)
        {
            if (pose_z >= 180)
            {
                float amount = 360 - pose_z;
                if (amount > 5)
                {
                    direction = amount;
                    z         = true;
                    reverse   = true;
                    //input_degree_Z = -1 / f + 180;
                }
            }
            if (pose_z < 180)
            {
                float amount = pose_z;
                if (amount > 5)
                {
                    direction = amount;
                    z         = true;
                    reverse   = false;
                    //input_degree_Z = 1 / f + 180;
                }
            }
        }

        if (direction == 20)
        {
            do_nothing = true;
        }

        // input manipulation
        if (z)
        {
            input_degree_X = 180;
            input_degree_Z = 1 / f;
            if (reverse)
            {
                input_degree_Z = input_degree_Z * (-1);
            }
            input_degree_Z = input_degree_Z + 180;
        }
        if (!z)
        {
            input_degree_Z = 180;
            input_degree_X = 1 / f;
            if (reverse)
            {
                input_degree_X = input_degree_X * (-1);
            }
            input_degree_X = input_degree_X + 180;
        }

        if (do_nothing)
        {
            input_degree_X = 180;
            input_degree_Z = 180;
        }
    }