public void OnGazeUpdate(GazeData gazeData) { if (CooldownTimer > 0f) { return; } if ((gazeData.State & (GazeData.STATE_TRACKING_FAIL | GazeData.STATE_TRACKING_LOST)) > 0) { Blinked = true; } Point2D point = UnityGazeUtils.getGazeCoordsToUnityWindowCoords(gazeData.SmoothedCoordinates); if ((gazeData.State & GazeData.STATE_TRACKING_GAZE) > 0) { if (Blinked) { CooldownTimer = BlinkCooldown; Blinked = false; } else { gazeX = (float)point.X; gazeY = (float)point.Y; } } }
public void Update() { bool useMouseAsInput = true; Point2D userPos = gazeUtils.GetLastValidUserPosition(); if (null != userPos) { //mapping cam panning to 3:2 aspect ratio double tx = (userPos.X * 5) - 2.5f; double ty = (userPos.Y * 3) - 1.5f; //camera 'look at' origo cam.transform.LookAt(Vector3.zero); } if (!useMouseAsInput) { Point2D gazeCoords = gazeUtils.GetLastValidSmoothedGazeCoordinates(); if (null != gazeCoords) { //map gaze indicator Point2D gp = UnityGazeUtils.getGazeCoordsToUnityWindowCoords(gazeCoords); Vector3 screenPoint = new Vector3((float)gp.X, (float)gp.Y, cam.nearClipPlane + .1f); Vector3 planeCoord = cam.ScreenToWorldPoint(screenPoint); //gazeIndicator.transform.position = planeCoord; //handle collision detection checkGazeCollision(screenPoint); // eye tracker } } if (useMouseAsInput) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Vector3 PositionToMoveTo = ray.GetPoint(5); checkGazeCollision(PositionToMoveTo); // mouse //go.transform.position = PositionToMoveTo; } //handle keypress if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); } else if (Input.GetKey(KeyCode.Space)) { Application.LoadLevel(0); } }
void Update() { Point2D userPos = gazeUtils.GetLastValidUserPosition(); if (null != userPos) { //mapping cam panning to 3:2 aspect ratio double tx = (userPos.X * 5) - 2.5f; double ty = (userPos.Y * 3) - 1.5f; //position camera X-Y plane and adjust distance eyesDistance = gazeUtils.GetLastValidUserDistance(); depthMod = 2 * eyesDistance; Vector3 newPos = new Vector3( (float)tx, (float)ty, (float)(baseDist + depthMod)); cam.transform.position = newPos; //camera 'look at' origo cam.transform.LookAt(Vector3.zero); //tilt cam according to eye angle double angle = gazeUtils.GetLastValidEyesAngle(); cam.transform.eulerAngles = new Vector3(cam.transform.eulerAngles.x, cam.transform.eulerAngles.y, cam.transform.eulerAngles.z + (float)angle); } Point2D gazeCoords = gazeUtils.GetLastValidSmoothedGazeCoordinates(); if (null != gazeCoords) { //map gaze indicator Point2D gp = UnityGazeUtils.getGazeCoordsToUnityWindowCoords(gazeCoords); Vector3 screenPoint = new Vector3((float)gp.X, (float)gp.Y, cam.nearClipPlane + .1f); Vector3 planeCoord = cam.ScreenToWorldPoint(screenPoint); gazeIndicator.transform.position = planeCoord; //handle collision detection checkGazeCollision(screenPoint); } //handle keypress if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); } else if (Input.GetKey(KeyCode.Space)) { Application.LoadLevel(0); } }
private Vector3 GetGazeScreenPosition(Point2D gp) { if (null != gp) { Point2D sp = UnityGazeUtils.getGazeCoordsToUnityWindowCoords(gp); return(new Vector3((float)sp.X, (float)sp.Y, 0f)); } else { return(Vector3.zero); } }
public Vector3 GetGazeScreenPosition() { Point2D gp = GazeDataValidator.Instance.GetLastValidSmoothedGazeCoordinates(); if (null != gp) { Point2D sp = UnityGazeUtils.getGazeCoordsToUnityWindowCoords(gp); return(new Vector3((float)sp.X, (float)sp.Y, 0f)); } else { return(Vector3.zero); } }
public void UpdateGazeCamera() { Point2D gazeCoords = gazeUtils.GetLastValidSmoothedGazeCoordinates(); if (null != gazeCoords) { //map gaze indicator Point2D gp = UnityGazeUtils.getGazeCoordsToUnityWindowCoords(gazeCoords); screenPoint = new Vector3((float)gp.X, (float)gp.Y, cam.nearClipPlane + .1f); if (useGazeTracker) { Vector3 planeCoord = cam.ScreenToWorldPoint(screenPoint); gazeIndicator.transform.position = planeCoord; } //handle collision detection, just as an example //checkGazeCollision(screenPoint); } }