コード例 #1
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;
         }
     }
 }
コード例 #2
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);
                }
            }
        }
    }
コード例 #3
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();
        }
コード例 #4
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;
        }
    }
コード例 #5
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);
    }
コード例 #6
0
    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);
        }
    }
コード例 #7
0
    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;
            }
        }
    }
コード例 #8
0
    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();
    }
コード例 #9
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!");
            }
        }
    }
コード例 #10
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);
        }
    }
コード例 #11
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);
    }
コード例 #12
0
ファイル: EyeGazePlot.cs プロジェクト: LadySith/Fishy
    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();
        }
    }
コード例 #13
0
    // 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;
        }
    }
コード例 #14
0
    // Start is called before the first frame update
    void Start()
    {
        gazePoint = TobiiAPI.GetGazePoint();
        Vector3 gazeOnScreen = Camera.main.ScreenToWorldPoint(gazePoint.Screen);

        lastGazePoint = gazeOnScreen;
    }
コード例 #15
0
    // 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;
        }
    }
コード例 #16
0
 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;
     }
 }
コード例 #17
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;
        }
    }
コード例 #18
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();
    }
コード例 #19
0
    // 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();
            }
        }
    }
コード例 #20
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);
        }
コード例 #21
0
    //--------------------------------------------------------------------
    // 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();
    }
コード例 #22
0
    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 + ">");
    }
コード例 #23
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;
                }
            }
        }
    }
コード例 #24
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);
    }
コード例 #25
0
ファイル: PresenceMeEye.cs プロジェクト: Dugyu/Efface
    // 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);
    }
コード例 #26
0
    // Update is called once per frame
    void Update()
    {
        GazePoint gazePoint = TobiiAPI.GetGazePoint();

        CheckLR(gazePoint);
        CheckUD(gazePoint);
        Rotate();
    }
コード例 #27
0
ファイル: GameManager.cs プロジェクト: PappaArty/TDDD23
 void Update()
 {
     gazePoint = TobiiAPI.GetGazePoint();
     ticks    += Time.deltaTime;
     if (!gazePoint.IsRecent())
     {
         ticksOfScreen += Time.deltaTime;
     }
 }
コード例 #28
0
 // Use this for initialization
 void Start()
 {
     if (double.IsNaN(TobiiAPI.GetGazePoint().Screen.x))
     {
         RestartGame();
     }
     Time.timeScale = 1f;
     GenerateBricks();
 }
コード例 #29
0
    public void makeObjectCentered()
    {
        pos   = TobiiAPI.GetGazePoint().Screen;
        pos.z = 0;

        mousePos = Input.mousePosition;

        if (!holding)
        {
            if (Camera.main.GetComponent <MoveCamera>().enabled)
            {
                Ray        ray = Camera.main.ScreenPointToRay(pos);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit, 10))
                {
                    if (hit.transform.GetComponent <PickupObject>())
                    {
                        step += 0.01f;
                        transform.GetComponent <Renderer>().material.SetColor("_OutlineColor", new Color(Mathf.Lerp(0, 1, step), 0, 0));
                        print("eye on object");
                        if (transform.GetComponent <Renderer>().material.GetColor("_OutlineColor") == Color.red)
                        {
                            transform.GetComponent <Renderer>().material.SetColor("_OutlineColor", new Color(0, 0, 0));
                            step                       = 0.0f;
                            transform.parent           = Camera.main.transform;
                            transform.localPosition    = new Vector3(0.82f, -0.34f, 1);
                            transform.localEulerAngles = new Vector3(-32, 0, 0);
                            transform.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
                            transform.GetComponent <Rigidbody>().useGravity  = false;
                            StartCoroutine(WaitForExplenation());
                            holding = true;
                        }
                    }
                    else
                    {
                        step = 0.0f;
                        transform.GetComponent <Renderer>().material.SetColor("_OutlineColor", new Color(0, 0, 0));
                    }
                }
            }
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                StopAllCoroutines();
                Canvas.SetActive(false);

                transform.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None;

                transform.GetComponent <Rigidbody>().useGravity = true;
                transform.GetComponent <Rigidbody>().AddForce(Camera.main.transform.forward * 250);
                transform.parent = null;
                holding          = false;
            }
        }
    }
コード例 #30
0
 // Update is called once per frame
 void Update()
 {
     if (!gameManager.GameIsPaused)
     {
         Vector3 vector3 = new Vector3((Smoothify(TobiiAPI.GetGazePoint().Viewport).x * 21f) - 10.5f, 5f,
                                       (Smoothify(TobiiAPI.GetGazePoint().Viewport).y * 12f) - 6f);
         transform.position = vector3;
     }
 }