/// <summary> /// Set the lerp color /// </summary> void Start() { _gazeAwareComponent = GetComponent <GazeAware>(); _meshRenderer = GetComponent <MeshRenderer>(); _lerpColor = _meshRenderer.material.color; _deselectionColor = new Color(1f, 1f, 1f, 0.2f); _userPresence = TobiiAPI.GetUserPresence(); // _deselectionColorText = new Color(1f, 1f, 1f, 0.4f); // textcolor = new Color(0f,0f,0f,1f); }
// Update is called once per frame void Update() { if (!TobiiAPI.GetUserPresence().IsUserPresent()) { return; } GazePoint gazePoint = TobiiAPI.GetGazePoint(); Vector2 drawPoint = smoothFilter(Camera.main.ScreenToWorldPoint(gazePoint.Screen)); if (Vector3.Magnitude(drawPoint - localPositionAverage) < focusRadius) { if ((Time.time - timeStart > timeInterval) && !toggleDraw && (null == TobiiAPI.GetFocusedObject())) { Debug.Log(Vector3.Magnitude(drawPoint - localPositionAverage)); Debug.Log("average: " + localPositionAverage); Debug.Log("draw point: " + drawPoint); currentObject = Instantiate(drawObject, new Vector3(localPositionAverage.x, localPositionAverage.y, -Time.time / 100000), Quaternion.identity); timeStart = Time.time; toggleDraw = true; spotPause = localPositionAverage; } } else { timeStart = Time.time; } /*if(toggleDraw && (Vector3.Magnitude(localPositionAverage - spotPause) > focusRadius)) * { * toggleDraw = false; * }*/ if (toggleDraw) { if (Vector3.Magnitude(localPositionAverage - spotPause) > focusRadius) { toggleDraw = false; } if (currentObject != null) { currentObject.transform.localScale *= 1.01f; } } else { } movingAverage(drawPoint); }
// Update is called once per frame void Update() { UserPresence userPresence = TobiiAPI.GetUserPresence(); if (userPresence.IsUserPresent()) { lookatPoint = camera.ScreenToWorldPoint(TobiiAPI.GetGazePoint().Screen); var moveVector = new Vector3(lookatPoint.x - moveObject.transform.position.x, lookatPoint.y - moveObject.transform.position.y, 0).normalized; moveObject.transform.Translate(moveVector * Time.deltaTime * speed); } }
// 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; } }
void Update() { var presence = TobiiAPI.GetUserPresence(); if (presence.IsUserPresent()) { _current = Color.Lerp(_current, active, Time.deltaTime * 5); } else { _current = Color.Lerp(_current, inactive, Time.deltaTime * 5); } }
// Update is called once per frame void Update() { var presence = TobiiAPI.GetUserPresence(); if (presence.IsUserPresent()) { RenderSettings.fogEndDistance = Mathf.Lerp(RenderSettings.fogEndDistance, 30, Time.deltaTime); } else { RenderSettings.fogEndDistance = Mathf.Lerp(RenderSettings.fogEndDistance, 0, Time.deltaTime * 10); } }
/// <summary> /// Print the User Presence status /// </summary> private void UpdateUserPresenceView() { var userPresence = TobiiAPI.GetUserPresence(); TextViewUserPresenceStatus.text = userPresence.ToString(); if (TobiiAPI.GetUserPresence().IsUserPresent()) { TextViewIsUserPresent.text = "Yes"; } else { TextViewIsUserPresent.text = "No"; } }
// Update is called once per frame void Update() { if (TobiiAPI.GetUserPresence() == UserPresence.Present) { Plane plane = new Plane(Vector3.up, Vector3.zero); Ray screenRay = Camera.main.ScreenPointToRay(TobiiAPI.GetGazePoint().Screen); float hitDistance = 0; if (plane.Raycast(screenRay, out hitDistance)) { Vector3 temp = new Vector3(screenRay.GetPoint(hitDistance).x, screenRay.GetPoint(hitDistance).y + .66f, screenRay.GetPoint(hitDistance).z); transform.position = temp; Debug.Log(transform.position + " " + hitDistance); } } //float x = TobiiAPI.GetGazePoint().x; }
void Update() { if (VoidGameManager.Instance.UseEyeTracker) { active = TobiiAPI.GetUserPresence().IsUserPresent(); col.enabled = active; if (active) { transform.position = GazePlotter.publicGazePoint; } } else { active = true; Vector3 mousePosition = Input.mousePosition; mousePosition.z = 22; transform.position = Camera.main.ScreenToWorldPoint(mousePosition); } }
IEnumerator checkForGaze() { float startTime = Time.unscaledTime; while (true) { if (!TobiiAPI.GetUserPresence().IsUserPresent()) { timer = 0f; yield return(new WaitForSecondsRealtime(0.05f)); continue; } yield return(new WaitForSecondsRealtime(0.05f)); timer = Time.unscaledTime - startTime; if (mainCamera != null && objectCollider.bounds.IntersectRay(mainCamera.ScreenPointToRay(TobiiAPI.GetGazePoint().Screen))) { startedGaze = true; if (timer > getGazeTime() && !objectBeingGazed) { objectBeingGazed = true; gazeAction(); } else if (!objectBeingGazed) { startedGazing(); } } else { timer = 0f; startTime = Time.unscaledTime; if (startedGaze) { stoppedGazing(); } startedGaze = false; objectBeingGazed = false; } } }
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; // 머리 회전값(오일러 각도) 출력 }
// Moves the ball side to side in accordance with the position of a ray cast void HorizontalMovement() { if (TobiiAPI.GetUserPresence() == UserPresence.Present) { Plane plane = new Plane(Vector3.up, Vector3.zero); Ray screenRay = Camera.main.ScreenPointToRay(TobiiAPI.GetGazePoint().Screen); RaycastHit hit; //float hitDistance = 0; if (Physics.Raycast(screenRay, out hit, 100)) { cursor.transform.position = new Vector3(hit.point.x, hit.point.y + .66f, hit.point.z); transform.position = Vector3.Lerp(transform.position, new Vector3(hit.point.x, .775f, cursor.transform.position.z), lerpSpeed * Time.deltaTime); } } //Ray ray = myCamera.ScreenPointToRay(Input.mousePosition); //RaycastHit hit; //if(Physics.Raycast(ray,out hit, 100)) //{ // transform.position = Vector3.Lerp(transform.position, new Vector3(hit.point.x, transform.position.y, transform.position.z), lerpSpeed * Time.deltaTime); //} }
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; } }
public override void Update() { if (tracker == null || !tracker.enabled || !enabled) { return; } if (TobiiAPI.GetUserPresence() != UserPresence.Present) { status = Humanoid.Tracking.Status.Present; Debug.LogWarning("No user detected. Is Tobii Eye Tracking enabled in the system tray?"); return; } status = Humanoid.Tracking.Status.Tracking; if (headTracking) { UpdateBones(); } if (eyeTracking) { UpdateEyes(); } if (virtual3dTracking) { Vector3 focusPoint = tracker.trackerTransform.position + Vector3.up * 0.2F; // 20 cm above the tobii tracker Vector3 lookDirection = focusPoint - fpCamera.transform.position; headTarget.neck.target.transform.rotation = tracker.trackerTransform.rotation * Quaternion.LookRotation(lookDirection); headTarget.neck.target.transform.position = new Vector3(-headTarget.neck.target.transform.position.x, headTarget.neck.target.transform.position.y, headTarget.humanoid.transform.position.z); Debug.DrawLine(fpCamera.transform.position, focusPoint, Color.cyan); Debug.DrawRay(fpCamera.transform.position, lookDirection, Color.magenta); } }
// Update is called once per frame void Update() { if (!TobiiAPI.GetUserPresence().IsUserPresent()) { return; } GazePoint gazePoint = TobiiAPI.GetGazePoint(); Vector2 drawPoint = smoothFilter(Camera.main.ScreenToWorldPoint(gazePoint.Screen)); if (rotateSprite) { Instantiate(drawObject, drawPoint, Quaternion.LookRotation(Vector3.forward, drawPoint - lastDrawPoint)); } else { Instantiate(drawObject, drawPoint, Quaternion.identity); } lastDrawPoint = drawPoint; }
/// <summary> /// Lerping the color /// </summary> void Update() { if (_meshRenderer.material.color != _lerpColor) { _meshRenderer.material.color = Color.Lerp(_meshRenderer.material.color, _lerpColor, _fadeSpeed); text.GetComponent <TextMesh>().color = Color.Lerp(_meshRenderer.material.color, textcolor, _fadeSpeed); // Color.black; } // Change the color of the cube if (_gazeAwareComponent.HasGazeFocus) { SetLerpColor(selectionColor); text.GetComponent <TextMesh>().color = textcolor; } else { SetLerpColor(_deselectionColor); } if (enableHide) { if (_gazeAwareComponent.HasGazeFocus) { counter++; } else { if (counter > 0) { _meshRenderer.enabled = false; text.SetActive(false); } } if (text.activeSelf == false) { StartCoroutine(updateCoroutine(5, true)); counter = 0; } } if (enableDesktopHide) { _userPresence = TobiiAPI.GetUserPresence(); if (_userPresence.IsUserPresent()) { // print("A user is present in front of the screen."); if (text.activeSelf == false) { StartCoroutine(updateCoroutine(1, true)); } } else { // print("User presence status is: " + _userPresence); StartCoroutine(updateCoroutine(5, false)); } } }
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; } }
// Update is called once per frame void FixedUpdate() { var temp = TobiiAPI.GetUserPresence(); if (temp.IsUserPresent()) { character_anim.SetBool("Walking", true); // Get mouse position var eyePosition = Camera.ScreenToWorldPoint(TobiiAPI.GetGazePoint().Screen); // Determine the character heading from the character's current position and the mouse position var heading = GetHeading(eyePosition, transform.position); // Get an isometric heading for the given heading var isometricHeading = GetIsometricHeading(heading.Value); // If the character is at the cursor position, do not move if (!isometricHeading.HasValue) { character_anim.SetBool("Walking", false); return; } // Get the compass bearing for the heading var bearing = GetBearing(heading.Value); // Set the appropriate character sprite for the given bearing //spriteRenderer.sprite = GetSpriteForBearing(bearing); character_anim.SetInteger("Direction", GetSpriteForBearing(bearing)); flashLight.transform.up = isometricHeading.Value; characterLight.transform.up = isometricHeading.Value; characterLight.transform.Rotate(new Vector3(0, 0, 1), 180); // Move the character rigidBody.velocity = isometricHeading.Value * Time.fixedDeltaTime * PlayerSpeed; } else if (Input.GetMouseButton(0)) { character_anim.SetBool("Walking", true); // Get mouse position var mousePosition = Camera.ScreenToWorldPoint(Input.mousePosition); // Determine the character heading from the character's current position and the mouse position var heading = GetHeading(mousePosition, transform.position); // Get an isometric heading for the given heading var isometricHeading = GetIsometricHeading(heading.Value); // If the character is at the cursor position, do not move if (!isometricHeading.HasValue) { character_anim.SetBool("Walking", false); return; } // Get the compass bearing for the heading var bearing = GetBearing(heading.Value); // Set the appropriate character sprite for the given bearing //spriteRenderer.sprite = GetSpriteForBearing(bearing); character_anim.SetInteger("Direction", GetSpriteForBearing(bearing)); flashLight.transform.up = isometricHeading.Value; characterLight.transform.up = isometricHeading.Value; characterLight.transform.Rotate(new Vector3(0, 0, 1), 180); // Move the character rigidBody.velocity = isometricHeading.Value * Time.fixedDeltaTime * PlayerSpeed; } else { character_anim.SetBool("Walking", false); rigidBody.velocity = new Vector2(); } }