Пример #1
0
    void getEyePos()
    {
        if (index < lr.numPositions - 1)
        {
            Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

            if (EyeTracking.GetGazePoint().IsValid)
            {
                Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePosition.x), Mathf.RoundToInt(gazePosition.y));

                roundedSampleInput.x /= Camera.main.pixelWidth;
                roundedSampleInput.y /= Camera.main.pixelHeight;
                Debug.Log(roundedSampleInput);
                Vector3 newPos = new Vector3(roundedSampleInput.x, roundedSampleInput.y, 0f);

                positions [index] = newPos;
                index++;
                //Debug.Log (index);
            }
        }
        else if (index == lr.numPositions - 1)
        {
            lr.SetPositions(positions);
            index = lr.numPositions;
        }
    }
Пример #2
0
    private void NewGravity()
    {
        bool addForce = (Player.EYE_TRACKER && EyeTracking.GetGazePoint().IsValid) ||
                        (!Player.EYE_TRACKER && Input.GetMouseButton(0));

        if (addForce)
        {
            if (Player.EYE_TRACKER)
            {
                _newPosition = _camera.ScreenToWorldPoint(new Vector3(EyeTracking.GetGazePoint().Screen.x,
                                                                      EyeTracking.GetGazePoint().Screen.y, Z));
            }
            else
            {
                _newPosition = _camera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Z));
            }
            if (icon)
            {
                AssignNewPosition();
                RenderIcon(true);
                ShowVortex(true, _camera.WorldToViewportPoint(_newPosition));
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            if (icon)
            {
                RenderIcon(false);
                ShowVortex(false, _offScreen);
            }
        }
    }
Пример #3
0
    void Update()
    {
        Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

        if (EyeTracking.GetGazePoint().IsValid)
        {
            Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePosition.x), Mathf.RoundToInt(gazePosition.y));
        }
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        gaze = EyeTracking.GetGazePoint();
        var v = gaze.Viewport * 10f;


        if (gaze.IsValid)
        {
            transform.position = new Vector3(v.x, v.y, 0f);
        }
    }
Пример #5
0
    void Update()
    {
        Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

        if (EyeTracking.GetGazePoint().IsValid)
        {
            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;
        }
    }
Пример #6
0
    private void AddingForce()
    {
        bool addForce = (EYE_TRACKER && EyeTracking.GetGazePoint().IsValid) ||
                        (!EYE_TRACKER && _gravityScript.ButtonClick);

        if (addForce)
        {
            _rigidbody.AddForce((_gravityScript.NewPosition - transform.position).normalized * _gravityScript.GetGravity);
            _rigidbody.AddTorque((_gravityScript.NewPosition - transform.position).magnitude / 100);
        }
    }
Пример #7
0
    void Update()
    {
        #region 判斷是否要開啟 Debug 的訊息
        if (Input.GetKeyDown(KeyCode.D))
        {
            IsDebugMode = !IsDebugMode;
        }
        #endregion
        #region 任務時間計算
        if (!counter.IsRecordBefore)
        {
            counter.TimeCounter += Time.deltaTime;
        }
        #endregion
        #region 眼動儀抓點
        if (!EyeTracking.GetGazePoint().IsValid)
        {
            return;
        }
        FinalPoint = ScreenToWorld(EyeTracking.GetGazePoint().Screen);
        if (IsUseFilter)
        {
            FinalPoint = DoubleExpFilter(FinalPoint);
        }

        recordData.Add(FinalPoint);
        #endregion
        #region 移動滑鼠 & 點擊判斷
        CursorAPI.SetCursorPosAPI(FinalPoint);

        // 判斷距離有沒有在設定的範圍內,有的話就加時間
        float dist = Vector3.Distance(HistoryPointTime0, FinalPoint);
        if (dist <= DiffDistance)
        {
            DiffCounter += Time.deltaTime;
        }
        else
        {
            DiffCounter = 0;
        }

        // 如果超過 DiffTime 代表傳送點擊事件
        if (DiffCounter >= DiffTime)
        {
            CursorAPI.CursorClickAPI();
            DiffCounter = 0;
        }


        // 最後要更新過去的點
        HistoryPointTime0 = FinalPoint;
        #endregion
    }
Пример #8
0
    // Update is called once per frame
    void Update()
    {
        GazePoint gazePoint = EyeTracking.GetGazePoint();

        if (gazePoint.SequentialId > _lastGazePoint.SequentialId &&
            gazePoint.IsWithinScreenBounds)
        {
            StoreGazePoint(gazePoint);

            _lastGazePoint = gazePoint;
        }
    }
Пример #9
0
    void Update()
    {
        Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

        if (EyeTracking.GetGazePoint().IsValid)
        {
            Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePosition.x), Mathf.RoundToInt(gazePosition.y));

            Vector3 newPos = Camera.main.WorldToViewportPoint(new Vector3(roundedSampleInput.x, roundedSampleInput.y, 0f) - new Vector3(Camera.main.pixelWidth / 2, Camera.main.pixelHeight / 2, 0f));

            transform.position = newPos;
        }
    }
Пример #10
0
    void Update()
    {
        Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

        if (EyeTracking.GetGazePoint().IsValid)
        {
            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;

            Dictionary <string, string> data = new Dictionary <string, string>();
            data["x"] = roundedSampleInput.x.ToString();
            data["y"] = roundedSampleInput.y.ToString();

            socket.Emit("coors", new JSONObject(data));
            //Debug.Log(roundedSampleInput.x + ", " + roundedSampleInput.y);
        }
    }
Пример #11
0
    //Check every frame if object is looked at (or pointed at)
    void Update()
    {
        //Using Gaze coordinates from Eyetracker
        Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

        if (EyeTracking.GetGazePoint().IsValid)
        {
            _ray = Camera.main.ScreenPointToRay(gazePosition);
            CastRay(_ray);
            //Mouse input
        }
        else if (mouseInput)
        {
            _ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            CastRay(_ray);
        }
    }
Пример #12
0
    // Update is called once per frame
    void Update()
    {
        GazePoint gp = EyeTracking.GetGazePoint();

        if (!gp.IsWithinScreenBounds)
        {
            return;
        }
        //print(gp.Screen.x + "+" + gp.Screen.y);

        Ray        ray = Camera.main.ScreenPointToRay(new Vector3(gp.Screen.x, gp.Screen.y, 0));
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, float.MaxValue, lmask))
        {
            //print("I'm looking at " + hit.transform.name);
            transform.position = hit.point;
        }
        //print("I'm looking at nothing!");
    }
Пример #13
0
    // Update is called once per frame
    void WriteLineToFile()
    {
        using (StreamWriter sw = new StreamWriter(fileName, true))
        {
            //Only log if eyetracker active, meaning screen values are not NaN
            Vector2 gazePoint = EyeTracking.GetGazePoint().Screen;

            if (EyeTracking.GetGazePoint().IsValid)  // Do not log NaN values TODO does that also remove negative values?
            {
                //Debug.Log("New line to text" + " " + gazePoint.x);
                Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePoint.x), Mathf.RoundToInt(gazePoint.y));
                string  time = DateTime.Now.ToString("HH_mm_ss__fff-dd-MM-yyyy");
                // Add line to file
                sw.WriteLine(time + "," + roundedSampleInput.x + "," + roundedSampleInput.y);
            }
            else
            {
                //Debug.Log("Eyetracker inactive");
            }
        }
    }
Пример #14
0
    void Update()
    {
        //Checks when eye tracker is available. Translates controls depending on setting.
        if (GetValidEyeTracking)
        {
            transform.position = Vector3.Lerp(transform.position, mainCamera.ScreenToWorldPoint(
                                                  new Vector3(EyeTracking.GetGazePoint().Screen.x, EyeTracking.GetGazePoint().Screen.y, transform.position.z)),
                                              _eyeSpeed * Time.deltaTime);
        }
        else
        {
            transform.position = mainCamera.ScreenToWorldPoint(
                new Vector3(Input.mousePosition.x, Input.mousePosition.y, transform.position.z));
        }

        //Displays icon when eye tracker is available.
        if (eyecon.enabled != GetValidEyeTracking)
        {
            eyecon.enabled = GetValidEyeTracking;
        }
    }
Пример #15
0
    void Update()
    {
        GazePoint gazePoint = EyeTracking.GetGazePoint();

        if (gazePoint.SequentialId > _lastGazePoint.SequentialId &&
            gazePoint.IsWithinScreenBounds)
        {
            if (UseFilter)
            {
                UpdateGazeBubblePosition(gazePoint);
            }
            else
            {
                UpdateGazePointCloud(gazePoint);
            }

            _lastGazePoint = gazePoint;
        }

        UpdateGazePointCloudVisibility();
        UpdateGazeBubbleVisibility();
    }
Пример #16
0
    //Check every frame if object is looked at (or pointed at)
    void Update()
    {
        //Using Gaze coordinates from Eyetracker
        Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

        if (EyeTracking.GetGazePoint().IsValid)
        {
            //Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePosition.x), Mathf.RoundToInt(gazePosition.y));
            //Debug.Log(roundedSampleInput);
            //Debug.Log(Input.mousePosition.ToString());

            _ray = Camera.main.ScreenPointToRay(gazePosition);

            CastRay(_ray);
            //Mouse input
        }
        else if (mouseInput)
        {
            _ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            CastRay(_ray);
        }
    }
Пример #17
0
 // Update is called once per frame
 void Update()
 {
     if (ended)
     {
         return;
     }
     if (isMouseInput)
     {
         readMouseInput();
     }
     else
     {
         GazePoint gazePoint = EyeTracking.GetGazePoint();
         if (gazePoint.SequentialId > lastGazePoint.SequentialId && gazePoint.IsWithinScreenBounds)
         {
             GameObject focusedObject    = EyeTracking.GetFocusedObject();
             Vector3    gazePointInWorld = getPositionInWorld(gazePoint.Screen);
             Vector3    normalized       = gazePointInWorld;
             if (focusedObject != null)
             {
                 normalized = normalize(gazePointInWorld, this.lastGazePointLoc);
                 gazeawareFocused(normalized, focusedObject);
                 this.lastGazePointLoc = normalized;
             }
             else
             {
                 fall();
             }
             updateTrackerPosition(normalized);
             this.lastGazePoint = gazePoint;
         }
     }
     if (this.started)
     {
         updateTimer();
     }
 }
Пример #18
0
    void Update()
    {
        GazePoint gazePoint = EyeTracking.GetGazePoint();

        if (gazePoint.SequentialId > _lastGazePoint.SequentialId &&
            gazePoint.IsWithinScreenBounds)
        {
            if (UseFilter)
            {
                UpdateGazeBubblePosition(gazePoint);
            }
            else
            {
                //This is the row equivalent where we store in file in the GazeplotTofile. THis means that the output from that file should be
                //sent to the UpdateGazePointCloud method equivalent.
                UpdateGazePointCloud(gazePoint);
            }

            _lastGazePoint = gazePoint;
        }

        UpdateGazePointCloudVisibility();
        UpdateGazeBubbleVisibility();
    }
Пример #19
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;

        var dstatus = "status:\n";

        dstatus += DemoController.step.ToString() + "\n";
        gaze     = EyeTracking.GetGazePoint();
        var presence = EyeTracking.GetUserPresence();

        if (presence.IsUserPresent)
        {
            dstatus += "user present\n";
        }
        else
        {
            dstatus += "user absent\n";
        }

        //get the target if valid
        if (gaze.IsValid)
        {
            dstatus += "gaze VALID\n";
            dstatus += "x: " + gaze.Screen.x.ToString() + " y: " + gaze.Screen.y.ToString() + "\n";
            Ray ray = cam.ScreenPointToRay(new Vector3(gaze.Screen.x, gaze.Screen.y, 0f));

            Debug.DrawRay(ray.origin, ray.direction * 5f, Color.red, 1f);

            if (Physics.Raycast(ray, out hit, 10f, lmask))
            {
                target = hit.point;
            }
        }
        else
        {
            dstatus += "gaze INVALID\n";
        }

        //smoothed move
        var smoothedPosition = cube.transform.position;

        smoothedPosition       += (target - smoothedPosition) * Time.deltaTime * smoothing;
        cube.transform.position = smoothedPosition;

        //smoothing options
        if (Input.GetKeyDown(KeyCode.UpArrow) && smoothing < 10f)
        {
            smoothing += 0.5f;
        }
        if (Input.GetKeyDown(KeyCode.DownArrow) && smoothing > 1f)
        {
            smoothing -= 0.5f;
        }


        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            cup.transform.position = cube.transform.position;
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            landingZone.transform.position = cube.transform.position;
        }

        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            audiance.transform.position = cube.transform.position;
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            ArduinoSend.WriteToArduino("n");
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            DemoController.setStep(DemoController.demoSteps.calibration);
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            DemoController.setStep(DemoController.demoSteps.pickup);
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            DemoController.setStep(DemoController.demoSteps.place);
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            DemoController.setStep(DemoController.demoSteps.audience);
        }


        dstatus += "smoothing: " + smoothing.ToString() + "\n";


        dstatus += "cubeX: " + cube.transform.position.x.ToString() + "\n";
        dstatus += "cubeX scaled: " + ((int)((cube.transform.position.x + 3) * 30)).ToString() + "\n";

        dtext.text = dstatus;
    }
Пример #20
0
 private void Update()
 {
     DispatchPositionEvent(positionInput, EyeTracking.GetGazePoint().Screen);
     SpaceInput();
 }