Beispiel #1
0
    public void GetTimeElapsed(GameObject focusedObject)
    {
        GameObject currentFocusedObj = TobiiAPI.GetFocusedObject();

        if (focusedObject != null)
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            // while (currentFocusedObj == focusedObject)
            //{
            long elapsedTime = stopwatch.ElapsedTicks;
            for (int i = 0; i < 1000; i++)
            {
                print("i is" + i);
                print("Elapsed time is " + elapsedTime);
            }
            currentFocusedObj = TobiiAPI.GetFocusedObject();
            //LoadLevel("Gallery");
            //}
            stopwatch.Stop();


            print("The user is focused on the " + focusedObject);
        }
    }
    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 #3
0
    public void makeObjectCentered()
    {
        pos   = TobiiAPI.GetGazePoint().Screen;
        pos.z = 0;

        mousePos = Input.mousePosition;

        Ray        ray = Camera.main.ScreenPointToRay(pos);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 50))
        {
            step += 0.01f;
            transform.GetComponent <Renderer>().material.color = new Color(1, Mathf.Lerp(1, 0, step), Mathf.Lerp(1, 0, step));
            print("eye on object");
            if (transform.GetComponent <Renderer>().material.color == Color.red)
            {
                transform.GetComponent <Renderer>().material.color = new Color(1f, 1f, 1f);
                step = 0.0f;
                transform.position = new Vector3(Random.Range(-2, 2), Random.Range(-2, 2), Random.Range(-2, 2));
            }
        }
        else
        {
            step = 0.0f;
            transform.GetComponent <Renderer>().material.color = new Color(1f, 1f, 1f);
        }
    }
Beispiel #4
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene(0);
        }

        RaycastHit hit;

        GazePoint mGazePoint = TobiiAPI.GetGazePoint();
        //Vector3 mScreenPoint = new Vector3 (mGazePoint.Screen.x, mGazePoint.Screen.y, -20f);
        Vector3 mScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, -20f);


        float DebugX = mGazePoint.Screen.x;
        float DebugY = mGazePoint.Screen.y;


        for (int i = -30; i < 30; i++)
        {
            Ray ray = Camera.main.ScreenPointToRay(mScreenPoint + Vector3.right * i);

            if (Physics.Raycast(ray, out hit, 100f))
            {
                tobyTarget = hit.collider.gameObject;
                Debug.DrawRay(ray.origin, ray.direction * 100f, Color.red);
                i = 31;
                print("Hit!");
            }
        }
    }
Beispiel #5
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();
        }
Beispiel #6
0
    void Update()
    {
        GazePoint gazePoint = TobiiAPI.GetGazePoint();

        //Location is calculated by ViewPort from the bottom left.
        string       path   = "Assets/Resources/tobiidata.csv";
        StreamWriter writer = new StreamWriter(path, true);

        writer.WriteLine(gazePoint.Timestamp + "," + gazePoint.Viewport.x + "," + gazePoint.Viewport.y);
        writer.Close();
        //

        if (gazePoint.IsRecent() &&
            gazePoint.Timestamp > (_lastGazePoint.Timestamp + float.Epsilon))
        {
            if (UseFilter)
            {
                UpdateGazeBubblePosition(gazePoint);
            }
            else
            {
                UpdateGazePointCloud(gazePoint);
            }

            _lastGazePoint = gazePoint;
        }

        UpdateGazePointCloudVisibility();
        UpdateGazeBubbleVisibility();
    }
Beispiel #7
0
 void Update()
 {
     if (state == DetectorState.Started)
     {
         // If eyes are OPEN
         Debug.Log(TobiiAPI.GetGazePoint().IsRecent(0.1f));
         Debug.Log("eyestate: " + Enum.GetName(typeof(EyeState), eyeState));
         if (TobiiAPI.GetGazePoint().IsRecent(0.1f))
         {
             if (eyeState == EyeState.EyesClosed || eyeState == EyeState.Unintialized)
             {
                 eyeState = EyeState.EyesOpen;
                 LogEyeOpen();
                 blinkNo++;
                 InputData inputData = new InputData();
                 inputData.validity    = InputValidity.Accepted;
                 inputData.type        = InputType.BlinkDetection;
                 inputData.confidence  = 1f;
                 inputData.inputNumber = blinkNo;
                 onBlink.Invoke(inputData);
             }
             duration = 0f;
         }
         else
         {
             if (eyeState == EyeState.EyesOpen || eyeState == EyeState.Unintialized)
             {
                 eyeState  = EyeState.EyesClosed;
                 timestamp = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff");
                 LogEyeClose();
             }
             duration += Time.deltaTime;
         }
     }
 }
Beispiel #8
0
    void Update()
    {
        GazePoint gazePoint = TobiiAPI.GetGazePoint();


        float      xMouse = gazePoint.Screen.x;
        float      yMouse = gazePoint.Screen.y;
        RaycastHit hit;

        var ray = Camera.main.ScreenPointToRay(new Vector2(xMouse, yMouse));

        if (Physics.Raycast(ray, out hit))
        {
            Debug.Log(hit.collider.name);

            // to shoot a small ball like p

            if (Input.GetKey("q"))
            {
                if (hit.collider.CompareTag("enemy_bug"))
                {
                    Destroy(hit.collider.gameObject);
                }
            }
        }
    }
Beispiel #9
0
    void Update()
    {
        if (_pauseTimer > 0)
        {
            _pauseTimer -= Time.deltaTime;
            return;
        }

        GazePoint.SetActive(false);
        _xOutline.enabled = false;
        _yOutline.enabled = false;

        GazePoint gazePoint = TobiiAPI.GetGazePoint();

        if (gazePoint.IsValid)
        {
            Vector2 gazePosition = gazePoint.Screen;
            yCoord.color = xCoord.color = Color.white;
            Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePosition.x), Mathf.RoundToInt(gazePosition.y));
            xCoord.text = "x (in px): " + roundedSampleInput.x;
            yCoord.text = "y (in px): " + roundedSampleInput.y;
        }

        if (Input.GetKeyDown(KeyCode.Space) && gazePoint.IsRecent())
        {
            _pauseTimer = 3f;
            GazePoint.transform.localPosition = (gazePoint.Screen - new Vector2(Screen.width, Screen.height) / 2f) / GetComponentInParent <Canvas>().scaleFactor;
            yCoord.color = xCoord.color = new Color(0 / 255f, 190 / 255f, 255 / 255f);
            GazePoint.SetActive(true);
            _xOutline.enabled = true;
            _yOutline.enabled = true;
        }
    }
    void Update()
    {
        pos   = TobiiAPI.GetGazePoint().Screen;
        pos.z = 0;

        mousePos = Input.mousePosition;

        Ray        ray = Camera.main.ScreenPointToRay(pos);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 10))
        {
            if (hit.transform.GetComponent <LookAtPlayer>())
            {
                step += 0.05f;
                float x = (Mathf.Lerp(lastSeen.x, Camera.main.transform.position.x, step));
                float y = (Mathf.Lerp(lastSeen.y, Camera.main.transform.position.y, step));
                float z = (Mathf.Lerp(lastSeen.z, Camera.main.transform.position.z, step));
                newPos = new Vector3(x, y, z);
                transform.LookAt(newPos);
                if (newPos == Camera.main.transform.position)
                {
                    lastSeen = Camera.main.transform.position;
                    step     = 0;
                }
            }
            else
            {
                lastSeen = newPos;
                step     = 0;
            }
        }
    }
Beispiel #11
0
    public static RaycastHit FindPlayerGaze(Camera cam, bool wantTobii) // Finds the gazepoint of the player
    {
        Ray ray;

        if (wantTobii) // Allows us to avoid the expensive Tobii computations when we don't need them.
        {
            // Get gazepoint from tobii and create ray
            GazePoint gazePoint = TobiiAPI.GetGazePoint();
            if (gazePoint.IsValid && gazePoint.IsRecent())
            {
                Vector3 gazePosition = new Vector3(gazePoint.Screen.x, gazePoint.Screen.y, 0);
                ray = cam.ScreenPointToRay(gazePosition);
            }
            else  // Use mouse position if gaze position is unavailable
            {
                ray = cam.ScreenPointToRay(Input.mousePosition);
            }
        }
        else
        {
            ray = cam.ScreenPointToRay(Input.mousePosition);
        }


        // Find first intersection from light in direction of mouse in world space
        RaycastHit hit;

        Physics.SphereCast(ray.origin, sphereRadius, ray.direction, out hit);
        return(hit);
    }
    // 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 #13
0
    void Look()
    {
        Vector3 olhando;
        Ray     ray;

        if ((!TobiiAPI.GetDisplayInfo().IsValid) || (!TobiiAPI.GetUserPresence().IsUserPresent()))
        {
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        }
        else
        {
            olhando = new Vector3(TobiiAPI.GetGazePoint().Screen.x, TobiiAPI.GetGazePoint().Screen.y, 0f);
            ray     = Camera.main.ScreenPointToRay(olhando);
            //se tiver eyetracker, mas quiser pausar porque perdeu os olhos, fazer akie

            /*if (TobiiAPI.GetDisplayInfo ().IsValid) {
             *                  Debug.Log ("Seus olhos não podem ser detectados");
             *          }*/
        }
        if (seekMouse)
        {
            gameObject.transform.rotation = Quaternion.LookRotation(ray.direction);
        }
        else
        {
            gameObject.transform.rotation = Camera.main.transform.rotation;
        }
    }
    // Update is called once per frame
    void FixedUpdate()
    {
        rb.drag = 0;
        // Get point where user is looking
        Vector2 gazePoint = TobiiAPI.GetGazePoint().Screen;

        // Convert x screen pixel co ordinate to relative x co ordinate
        float x = ((gazePoint.x / Screen.currentResolution.width) * 15) - 6;

        // If user is looking to left of rabbit push rabbit left
        if (x < rb.position.x - 0.3)
        {
            rb.AddForce(-sidewaysInitalForce * Time.deltaTime, 0, 0);
        }
        // If user is looking to right of rabbit push rabbit right
        else if (x > rb.position.x + 0.3)
        {
            rb.AddForce(sidewaysInitalForce * Time.deltaTime, 0, 0);
        }
        // If user is looking at rabbit increase drag to stop rabbit from moving
        else
        {
            rb.drag = 10;
        }
    }
Beispiel #15
0
    private bool IsPlayerLookingAtCrosshair()
    {
        var gazePoint = TobiiAPI.GetGazePoint();

        if (!gazePoint.IsRecent())
        {
            return(true);
        }

        if (CenterCrosshairImage == null)
        {
            return(false);
        }

        var crosshairTransform = CenterCrosshairImage.GetComponent <RectTransform>();

        if (crosshairTransform == null)
        {
            return(false);
        }

        var crosshairGuiPosition = GetGuiPositionOfPivotPoint(crosshairTransform);
        var currentGazePoint     = gazePoint.GUI;

        return(Vector2.Distance(currentGazePoint, crosshairGuiPosition) < OverrideZoneRadiusInPixels);
    }
    void Update()
    {
        pos      = TobiiAPI.GetGazePoint().Screen;
        pos.z    = 0;
        mousePos = Input.mousePosition;
        Vector2 lookPos = Camera.main.ScreenToViewportPoint(pos);


        if (lookPos.y >= 0.88f || lookPos.y <= 0.12f)
        {
            float tiltAroundX = Input.GetAxis("Mouse Y") * -tiltAngle;
            addition += tiltAroundX;
            //Debug.Log(transform.localEulerAngles.y);
            Quaternion target = Quaternion.Euler(Mathf.Clamp(addition, -30f, 30f), transform.localEulerAngles.y, Mathf.Clamp(transform.rotation.z, -0f, 0f));
            transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth);
        }

        //transform.rotation = target;

        if (lookPos.x <= 0.2f && lookPos.x >= 0.01f)
        {
            transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y - ((0.2f / lookPos.x) * 0.1f), transform.localEulerAngles.z);
        }
        if (lookPos.x <= 0.01f)
        {
            transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y - 2, transform.localEulerAngles.z);
        }

        if (lookPos.x >= 0.8f)
        {
            transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y + ((lookPos.x - 0.8f) * 10), transform.localEulerAngles.z);
        }
    }
Beispiel #17
0
    // Start is called before the first frame update
    void Start()
    {
        gazePoint = TobiiAPI.GetGazePoint();
        Vector3 gazeOnScreen = Camera.main.ScreenToWorldPoint(gazePoint.Screen);

        lastGazePoint = gazeOnScreen;
    }
Beispiel #18
0
    private void UpdateObjectFocusedForSelection()
    {
        GameObject newlyFocusedObject = null;

        if (IsPlayerLookingAtCrosshair())
        {
            newlyFocusedObject = GetObjectAtCrosshair();
        }

        if (newlyFocusedObject == null)
        {
            newlyFocusedObject = TobiiAPI.GetFocusedObject();
            if (newlyFocusedObject != null)
            {
                if (Vector3.Distance(newlyFocusedObject.transform.position, ExtendedView.CameraWithoutExtendedView.transform.position) > MaxInteractionDistance)
                {
                    newlyFocusedObject = null;
                }
            }
        }

        if (!IsInteractableGazeAware(newlyFocusedObject))
        {
            newlyFocusedObject = null;
        }

        UpdatePreviouslyFocusedObject(newlyFocusedObject, _focusedObject, _focusedLastSeen);

        _focusedObject = newlyFocusedObject;
        if (_focusedObject != null)
        {
            _focusedLastSeen = Time.time;
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (double.IsNaN(TobiiAPI.GetGazePoint().Screen.x))
        {
            SceneManager.LoadScene("PongScene");
        }
        if (ball.Reset)
        {
            ResetPaddle();
        }
        var pos = transform.position;

        if (isBottom)
        {
            Vector2 input = Smoothify(TobiiAPI.GetGazePoint().Screen);
            pos.x = (input.x - Screen.width / 2) / 100;
        }
        else
        {
            if (ball.Direction.x > 0 && ball.transform.position.x > pos.x)
            {
                pos.x = pos.x + (Random.Range((float)2.5, (float)10) / 100);
            }
            else if (ball.Direction.x < 0 && ball.transform.position.x < pos.x)
            {
                pos.x = pos.x - (Random.Range((float)2.5, (float)10) / 100);
            }
        }
        if (pos.x - 1.25 > (Screen.width / 2 * -1) / 100 && pos.x + 1.25 < (Screen.width / 2) / 100)
        {
            transform.position = pos;
        }
    }
    void FixedUpdate()
    {
        GazePoint gazePoint = TobiiAPI.GetGazePoint();                                      // get GazePoint from Tobii Eye Tracker

        // Doesnt work at the moment
        if (!gazePoint.IsValid)                                                             // Is User looking on screen ?
        {
            Time.timeScale = 0.0f;                                                          // Stop any calculations
        }
        else
        {
            Time.timeScale = 1.0f;                                                          // Resumes time "flow"
            setEyeHorizontalFactor(gazePoint);                                              // Calculate horizontal eye movement from screen center
            setEyeVerticalFactor(gazePoint);                                                // Calculate vertical eye movement from screen center
        }

        prevPosition = transform.position;                                                  // save transform values before physics

        HandleMovement();
        HandleJump();

        grounded = isGrounded();
        if (grounded)
        {
            clearRBConstraints();
            rb.mass = 1;
        }
        //Debug.Log("Eye Position: <" + eyeHorizontalFactor + ", " + eyeVerticalFactor + ">");
    }
Beispiel #21
0
    public void makeObjectCentered()
    {
        pos   = TobiiAPI.GetGazePoint().Screen;
        pos.z = 0;

        mousePos = Input.mousePosition;

        if (Camera.main.GetComponent <MoveCamera>().enabled)
        {
            Ray        ray = Camera.main.ScreenPointToRay(pos);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, 10))
            {
                if (hit.transform == this.transform)
                {
                    step += 0.01f;
                    transform.GetComponent <Renderer>().material.color = new Color(Mathf.Lerp(0, 1, step), 0, 0);
                    if (transform.GetComponent <Renderer>().material.color == Color.red)
                    {
                        Camera.main.transform.position = CameraPlace.transform.position;
                        step = 0;
                    }
                }
                else
                {
                    transform.GetComponent <Renderer>().material.color = new Color(0, 0, 0);
                    step = 0;
                }
            }
        }
    }
Beispiel #22
0
 // Use this for initialization
 void Start()
 {
     cube  = GameObject.Find("Cube");
     floor = GameObject.Find("Floor");
     gaze  = cube.GetComponent <GazeAware>();
     up    = TobiiAPI.GetUserPresence();
 }
    // Update is called once per frame
    void Update()
    {
        if (!isJudgeMode)
        {
            if (Input.GetMouseButtonDown(0))
            {
                enableDrawing = true;
            }

            if (enableDrawing)
            {
                WriteLine();
            }
        }
        else
        {
            print(isInArea(0, camera.ScreenToWorldPoint(Input.mousePosition)));
        }

        if (recordFlag)
        {
            GazePoint gazePoint = TobiiAPI.GetGazePoint();
            if (gazePoint.IsValid)
            {
                sw = fi.AppendText();
                int    xt = (int)(gazePoint.Screen.x - 200) * 954 / 1525;
                int    yt = (int)(1070 - gazePoint.Screen.y) * 954 / 1070;
                String xs = xt.ToString();
                String ys = yt.ToString();
                sw.WriteLine(xs + "," + ys + "," + "0.3");
                sw.Flush();
                sw.Close();
            }
        }
    }
 protected void Update()
 {
     if (!TobiiAPI.GetUserPresence().IsUserPresent())
     {
         timer = 0f;
         return;
     }
     timer += Time.deltaTime;
     if (objectCollider.bounds.IntersectRay(mainCamera.ScreenPointToRay(TobiiAPI.GetGazePoint().Screen)))
     {
         startedGaze = true;
         if (timer > gazeTime() && !objectBeingGazed)
         {
             objectBeingGazed = true;
             gazeAction();
         }
         else if (!objectBeingGazed)
         {
             startedGazing();
         }
     }
     else
     {
         timer = 0f;
         if (startedGaze)
         {
             stoppedGazing();
         }
         startedGaze      = false;
         objectBeingGazed = false;
     }
 }
Beispiel #25
0
        // Returns distance between user gaze and given (x,y)
        // Input should be in World Point Coordinates
        public double distanceFromGaze(double x, double y)
        {
            GazePoint gazePoint = TobiiAPI.GetGazePoint();

            if (gazePoint.IsRecent())
            {
                // Convert Tobii Coordinates to Viewport
                Vector3 original = new Vector3(gazePoint.Screen.x, gazePoint.Screen.y, 0);
                Vector3 tobii_world_coordinates    = cam.ScreenToWorldPoint(original);
                Vector3 tobii_viewport_coordinates = cam.WorldToViewportPoint(tobii_world_coordinates);

                // Convert given World Point Coordinates to Viewport
                Vector3 given_coordinates         = new Vector3((float)x, (float)y, 0);
                Vector3 give_viewport_coordinates = cam.WorldToViewportPoint(given_coordinates);

                double x_diff   = give_viewport_coordinates.x - tobii_viewport_coordinates.x;
                double y_diff   = give_viewport_coordinates.y - tobii_viewport_coordinates.y;
                double distance = Math.Sqrt(
                    Math.Pow(x_diff, 2f) +
                    Math.Pow(y_diff, 2f));

                return(distance);
            }
            return(-1);
        }
    //--------------------------------------------------------------------
    // MonoBehaviour event functions (messages)
    //--------------------------------------------------------------------
    protected void LateUpdate()
    {
        UpdateSettings();

        UpdateHeadPose();

        if (!IsEnabled ||     /* || !TobiiAPI.GetUserPresence().IsUserPresent*/
            (IsAiming && RemoveExtendedViewWhenAiming))
        {
            _gazeViewTarget = new Vector2();
        }
        else
        {
            Vector2 currentGazePoint = TobiiAPI.GetGazePoint();
            //if (currentGazePoint.IsValid)
            {
                _lastValidGazePoint = currentGazePoint;
            }

            if (!ShouldPauseInfiniteScreenOnCleanUI())
            {
                //if (_lastValidGazePoint.IsValid)
                {
                    var normalizedCenteredGazeCoordinates = CreateNormalizedCenteredGazeCoordinates(_lastValidGazePoint);
                    if (!IsLocked)
                    {
                        UpdateViewTarget(normalizedCenteredGazeCoordinates);
                    }
                }
            }
        }

        UpdateInfiniteScreenAngles();
        UpdateTransform();
    }
Beispiel #27
0
    static extern bool SetCursorPos(float X, float Y); //added to make eye gaze determine "mouse" position

    void Update()
    {
        GazePoint gazePoint = TobiiAPI.GetGazePoint();

        if (NUIManager.Instance.typeOfNUI == 2)
        {
            if (gazePoint.IsRecent() &&
                gazePoint.Timestamp > (_lastGazePoint.Timestamp + float.Epsilon))
            {
                if (UseFilter)
                {
                    UpdateGazeBubblePosition(gazePoint);
                }
                else
                {
                    UpdateGazePointCloud(gazePoint);
                }

                _lastGazePoint = gazePoint;
                Vector2 gazePosition = _lastGazePoint.Screen;
                SetCursorPos(gazePosition.x, gazePosition.y);
            }

            UpdateGazePointCloudVisibility();
            UpdateGazeBubbleVisibility();
        }
    }
Beispiel #28
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 #29
0
    public void makeObjectTrackEyes()
    {
        Vector3 pos = TobiiAPI.GetGazePoint().Screen;

        pos.z = 10;
        pos   = Camera.main.ScreenToWorldPoint(pos);
        transform.position = Vector3.Lerp(transform.position, pos, 10 * Time.deltaTime);
    }
Beispiel #30
0
    // Start is called before the first frame update
    void Start()
    {
        _gazePoint = TobiiAPI.GetGazePoint();

        lastInput = new Vector3(Screen.width * 0.5f, Screen.height * 0.5f);

        baseline = Mathf.Sqrt(Screen.width * Screen.width + Screen.height * Screen.height);
    }