void Start() { gazePointDataProvider.Start(); eyePositionDataProvider.Start(); this.previousGazePoint = this.gazePointDataProvider.Last; // disable the rendering of the invisible walls //GameObject.Find ("Level_1_Obstacle_Wall_01").GetComponent<MeshRenderer>().enabled = false; GameObject.Find("Level_1_Obstacle_Wall_02").GetComponent <MeshRenderer>().enabled = false; GameObject.Find("Level_1_Obstacle_Wall_03").GetComponent <MeshRenderer>().enabled = false; //GameObject.Find ("Level_1_Obstacle_Wall_04").GetComponent<MeshRenderer>().enabled = false; // set all wall lights to first color GameObject[] wallLights = GameObject.FindGameObjectsWithTag("WallLight_Level1"); foreach (GameObject wallLight in wallLights) { ColorPanel colorPanelScript = wallLight.GetComponent <ColorPanel>(); wallLight.GetComponentInChildren <MeshRenderer>().material.color = colorPanelScript.defaultColor; } // load the number of wallLights this.numberOfWallLights = GameObject.FindGameObjectsWithTag("WallLight_Level1").Length; audioFiles = this.gameObject.GetComponent <AudioFilesLevel1> (); }
public override void OnUpdate() { LastGazePoint = _dataProvider.Last; if (LastGazePoint.IsValid) { if (! GuiPosition.IsNone) { GuiPosition.Value = LastGazePoint.GUI; } if (! ScreenPosition.IsNone) { ScreenPosition.Value = LastGazePoint.Screen; } if (! ViewPortPosition.IsNone) { ViewPortPosition.Value = LastGazePoint.Viewport; } if (! isWithinScreenBound.IsNone) { isWithinScreenBound.Value = LastGazePoint.IsWithinScreenBounds; } } if (! isValid.IsNone) { isValid.Value = LastGazePoint.IsValid; } }
public void storeTrackPoint(EyeXGazePoint trackPoint) { if (currentState != null) { currentState.Execute(this, trackPoint); } }
public override void OnUpdate() { LastGazePoint = _dataProvider.Last; if (LastGazePoint.IsValid) { if (!GuiPosition.IsNone) { GuiPosition.Value = LastGazePoint.GUI; } if (!ScreenPosition.IsNone) { ScreenPosition.Value = LastGazePoint.Screen; } if (!ViewPortPosition.IsNone) { ViewPortPosition.Value = LastGazePoint.Viewport; } if (!isWithinScreenBound.IsNone) { isWithinScreenBound.Value = LastGazePoint.IsWithinScreenBounds; } } if (!isValid.IsNone) { isValid.Value = LastGazePoint.IsValid; } }
//30 fps public void updateEyeTrack(EyeXGazePoint gazePoint) { _gazePoint = gazePoint; Vector3 gPos = _gazePoint.Screen; aim_sprite.GetComponent <RectTransform> ().position = gPos; }
private Vector2 GetNormalizedGazePosition(EyeXGazePoint lastGazePoint) { // Get position in screen space Vector2 gazePointInScreenSpace = lastGazePoint.Viewport; // Smoothen Vector2 smoothedGazePoint = Smoothify(gazePointInScreenSpace); return(smoothedGazePoint); }
public override void Execute(sceneTrackdata entity, EyeXGazePoint trackPoint) { trackDataSet mydata = new trackDataSet(); mydata.Timestamp = Time.time; mydata.target = new Vector2(); mydata.aim = new Vector2(); entity.insertData(mydata); }
private void handleWallLights() { EyeXGazePoint gazePoint = gazePointDataProvider.Last; Vector2 screenCoordinates = gazePoint.Screen; Ray gazeRay = Camera.main.ScreenPointToRay(new Vector3(screenCoordinates.x, screenCoordinates.y, 0)); Debug.DrawRay(gazeRay.origin, gazeRay.direction, Color.magenta, 40.0f); if (gazePoint.Equals(this.previousGazePoint)) { return; // do nothing if no new gaze point is available } if (Physics.Raycast(gazeRay.origin, gazeRay.direction, out gazeRaycastHit, 40.0f, ~raycastMask)) { // get the gazed object GameObject gazedObject = gazeRaycastHit.collider.gameObject; if (gazedObject.name.Contains("Panel") && !gazedObject.name.Equals(this.lastGazedWallLightName)) { // now check which color it has, set it to another color Color gazedObjectColor = gazedObject.GetComponentInChildren <MeshRenderer>().material.color; ColorPanel colorPanelScript = gazedObject.GetComponent <ColorPanel>(); if (gazedObjectColor.Equals(colorPanelScript.defaultColor)) { // color the wall light gazedObject.GetComponentInChildren <MeshRenderer>().material.color = colorPanelScript.gazedColor; // play audio sound AudioManager.instance.playSoundEffect(this.audioFiles.clickSound); // if it is the first colored panel, play a sound if (wallLightsColored == 0) { AudioManager.instance.playAudioClipForced(audioFiles.getWallOfLights_Stage01_AudioClip()); } else if (wallLightsColored == ((int)(this.numberOfWallLights / 3))) { // play a impatient audio clip AudioManager.instance.playAudioClipForced(audioFiles.getWallOfLights_Stage02_AudioClip()); } else if (wallLightsColored == (this.numberOfWallLights - 1)) { // Play a special audio file cuz the player gazed ALL PANELS!!! AudioManager.instance.queueAudioClip(audioFiles.getWallOfLightsOver_Stage01()); } // update the counter wallLightsColored++; } } this.lastGazedWallLightName = gazedObject.name; } this.previousGazePoint = gazePoint; }
/// <summary> /// Draws a square GUI.Box at the location specified by the gazePoint. /// <para> /// Note: This method has to be called from the OnGUI() method! /// </para> /// </summary> /// <param name="gazePoint">The box location</param> /// <param name="size">Size of the sides of the square box, in pixels</param> /// <param name="color">Color of the box</param> /// <param name="title">Title of the box</param> protected void DrawGUI(EyeXGazePoint gazePoint, float size, Color color, string title) { var defaultStyle = GUI.skin.box; GUI.skin.box = CreateBoxStyle(color); if (gazePoint.IsWithinScreenBounds) { GUI.Box(new UnityEngine.Rect(gazePoint.GUI.x - size / 2.0f, gazePoint.GUI.y - size / 2.0f, size, size), title); } GUI.skin.box = defaultStyle; }
//for moving object based on gaze coordinates from tracker //based on resolution of window //receives object, renderer, bounds script, and data script //returns vector3 position in world coordinates public Vector3 positionObjectWithRendererBoundsData(GameObject theObject, Renderer theRenderer, BoundsCheck theBounds, EyeXGazePoint theData) { //check bounds //use the object with the outermost bounds and a renderer to make the check Vector3 boundsVector = theBounds.checkBoundsForRenderer(theRenderer, theData.Viewport); //convert viewport vector to world position vector Vector3 worldPos = Camera.main.ViewportToWorldPoint(boundsVector); worldPos.z = theObject.transform.position.z; //maintain z position for object //return new world position return worldPos; }
void FollowGazePoint() { EyeXGazePoint lastGazePoint = gazePointDataComponent.LastGazePoint; if (lastGazePoint.IsWithinScreenBounds) { Vector2 screenSpace = lastGazePoint.Screen; Vector3 gazeWorldPoint = Camera.main.ScreenToWorldPoint(new Vector3(screenSpace.x, screenSpace.y, Camera.main.nearClipPlane)); gazeWorldPoint = new Vector3(gazeWorldPoint.x, gazeWorldPoint.y, 0.0f); Vector3 lerped = Vector3.Lerp(transform.position, gazeWorldPoint, lerpAmount); transform.position = lerped; } }
// Update is called once per frame void Update() { EyeXGazePoint lastGazePoint = this.gazePointDataProvider.Last; Vector2 lastGazeScreenPosition = lastGazePoint.Screen; this.lastGazePoints.Enqueue(lastGazeScreenPosition); // calculate average point on screen float x = 0.0f; float y = 0.0f; Vector2[] lastScreenPoints = this.lastGazePoints.ToArray(); foreach (Vector2 screenPosition in lastScreenPoints) { x += screenPosition.x; y += screenPosition.y; } x = x / lastScreenPoints.Length; y = y / lastScreenPoints.Length; // set the eyeposition to the screen point GameObject eyePosition = GameObject.Find("EyePosition"); if (eyePosition != null) { // if the eyeposition image should not be shown place it at -10000 -10000 0 position if (this.showEyePosition) { eyePosition.transform.position = new Vector3(x, y, 0); } else { eyePosition.transform.position = new Vector3(-10000, -10000, 0); } } // dequeue the last screen position this.lastGazePoints.Dequeue(); // check key input if (Input.GetButtonDown("EyePoint")) { this.showEyePosition = !this.showEyePosition; } }
void Update() { EyeXGazePoint gaze = _gazePointDataComponent.LastGazePoint; if (_userPresenceComponent.IsValid && _userPresenceComponent.IsUserPresent && gaze.IsValid) { // Save gaze position lookingPos = GetNormalizedGazePosition(gaze); // Change state and handle elapsed time HandleState(); // Change camera rotation LookAround(); } else { _hasHistoricPoint = false; } }
protected override void HandleEvent(IEnumerable <Behavior> eventBehaviors, Vector2 viewportPosition, Vector2 viewportPixelsPerDesktopPixel) { // Note that this method is called on a worker thread, so we MAY NOT access any game objects from here. // The data is stored in the Last property and used from the main thread. foreach (var behavior in eventBehaviors) { FixationDataEventParams eventParams; if (behavior.TryGetFixationDataEventParams(out eventParams)) { var gazePoint = new EyeXGazePoint( new Vector2((float)eventParams.X, (float)eventParams.Y), eventParams.Timestamp, viewportPosition, viewportPixelsPerDesktopPixel); Last = new EyeXFixationPoint(gazePoint, eventParams.Timestamp, eventParams.EventType); } } }
// Update is called once per frame void Update() { EyeXGazePoint lastGazePoint = GetComponent <GazePointDataComponent> ().LastGazePoint; gazePoint = lastGazePoint.Screen; if (lastGazePoint.IsWithinScreenBounds) { Vector2 screenSpace = lastGazePoint.Screen; lastShootPos = Camera.main.ScreenToWorldPoint(new Vector3(screenSpace.x, screenSpace.y, 8f)); lastShootPos.z = 0f; } /*Vector3 mouse_po = Input.mousePosition; * lastShootPos = Camera.main.ScreenToWorldPoint (new Vector3 (mouse_po.x, mouse_po.y, 8f)); * lastShootPos.z = 0f; * gazePoint = mouse_po;*/ lockOn.transform.position = lastShootPos; }
public void DrawGUI(EyeXGazePoint gazePoint, float size, Color color) { var defaultStyle = GUI.skin.box; GUI.skin.box = CreateBoxStyle(color); if (gazePoint.IsWithinScreenBounds) { GUI.Box(new UnityEngine.Rect(gazePoint.GUI.x - size / 2.0f, gazePoint.GUI.y - size / 2.0f, size, size), "n"); } GUI.skin.box = defaultStyle; //--------------------------------JL--------------------------------------------- /* * Vector2 screenSpace = gazePoint.Screen; * //Vector2 filteredscreenSpace = getJLFilterValueSnappy(screenSpace); * Vector2 filteredscreenSpace = getJLFilterValue(screenSpace); * * Ray ray = Camera.main.ScreenPointToRay(filteredscreenSpace); * * RaycastHit hit; * if (Physics.Raycast (ray, out hit, 500.0F)) * { * GameObject GO = GameObject.Find("Sphere"); * if(GO) * { * * GO.transform.position = hit.point; * * Debug.Log(ray.origin.ToString() + " " + hit.point.ToString()); * } * } */ //----------------------------------------------------------------------------- }
void Update() { elapsedTime += Time.deltaTime; // play the wakeup sound if (timeTillWakeupSoundStarts < elapsedTime && wakeupSoundPlayed == false) { wakeupSoundPlayed = true; //Debug.Log ("Wakeup sound queued"); AudioManager.instance.queueAudioClip(audioFiles.wakeupAudioClip); } // If the wall trigger was triggered then start the countdown till the voice should start if (wallTriggerStarted) { timeTillWallSoundStarts -= Time.deltaTime; if (wallSoundPlayed == false && timeTillWallSoundStarts < 0) { // play Audio Sound wallSoundPlayed = true; AudioManager.instance.queueAudioClip(audioFiles.firstWallAudioClip); } } // open the door if the time is right! if (elapsedTime > timeTillFirstDoorOpens && !openFirstDoorAnimationStarted) { openFirstDoorAnimationStarted = true; GameObject.Find("FirstDoor").GetComponent <Animator>().Play("OpenDoor"); } // after the firstWallAudioClip was played check if the player closes his eyes for a second if (wallSoundPlayed && !wallsVisible) { // check whether left and right eye are closed EyeXEyePosition lastEyePosition = eyePositionDataProvider.Last; //Debug.Log ("lastEyePosition: " + lastEyePosition); if (!lastEyePosition.RightEye.IsValid && !lastEyePosition.LeftEye.IsValid) { timeEyesAreClosed += Time.deltaTime; } else { timeEyesAreClosed = 0.0f; } if (timeEyesAreClosed > 1.0f) { // show the walls GameObject.Find("Level_1_Obstacle_Wall_01").GetComponent <MeshRenderer>().enabled = true; GameObject.Find("Level_1_Obstacle_Wall_02").GetComponent <MeshRenderer>().enabled = true; GameObject.Find("Level_1_Obstacle_Wall_03").GetComponent <MeshRenderer>().enabled = true; GameObject.Find("Level_1_Obstacle_Wall_04").GetComponent <MeshRenderer>().enabled = true; wallsVisible = true; } } // if the walls are passed send out rays to check whether the player is looking at a "solar panel" if (wallsVisible) { EyeXGazePoint gazePoint = gazePointDataProvider.Last; //Debug.Log ("last Gaze Point: " + gazePoint); Vector2 screenCoordinates = gazePoint.Screen; Ray gazeRay = Camera.main.ScreenPointToRay(new Vector3(screenCoordinates.x, screenCoordinates.y, 0)); Debug.DrawRay(gazeRay.origin, gazeRay.direction, Color.magenta, 120.0f); if (Physics.Raycast(gazeRay.origin, gazeRay.direction, out gazeRaycastHit, 40.0f)) { string gazedObject = gazeRaycastHit.collider.gameObject.name; if (gazedObject.Contains("Panel_Colored")) { Debug.Log("Panel gazed"); Debug.Log("gazedObject: " + gazedObject); Debug.Log("currentBlinkingLight: " + currentBlinkingLight); if (gazedObject == currentBlinkingLight && currentBlinkingLightRemoved == false) { Debug.Log("Blinking Panel gazed"); ((GameObject)blinkingLights[currentBlinkingLightIndex]).GetComponentInChildren <MeshRenderer>().enabled = false; blinkingLights.RemoveAt(currentBlinkingLightIndex); currentBlinkingLightRemoved = true; } } } } GameObject.Find("Cow").GetComponentInChildren <MeshRenderer> ().material.color = Color.Lerp(Color.magenta, Color.blue, elapsedTime % 10 / 10.0f); blinkingLightCounter += Time.deltaTime; if (blinkingLightCounter > 2.75f) { blinkingLightCounter = 0.0f; blinkLight(); } }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="gazePoint">The location of the fixation. See also <seealso cref="EyeXGazePoint"/>.</param> /// <param name="timestamp">The timestamp of the fixation.</param> /// <param name="eventType">The event type of the original fixation event.</param> public EyeXFixationPoint(EyeXGazePoint gazePoint, double timestamp, FixationDataEventType eventType) { GazePoint = gazePoint; Timestamp = timestamp; EventType = eventType; }
//30 fps public void updateEyeTrack(EyeXGazePoint gazePoint) { _gazePoint = gazePoint; }
// Update is called once per frame void Update() { // movement controls if (!freeze) { if (Input.GetKey(KeyCode.W)) { //transform.position += Vector3.up * Time.deltaTime * movementSpeed; rb.AddForce(Vector3.up * force); } if (Input.GetKey(KeyCode.A)) { //transform.position += Vector3.left * Time.deltaTime * movementSpeed; rb.AddForce(Vector3.left * force); } if (Input.GetKey(KeyCode.S)) { //transform.position += Vector3.down * Time.deltaTime * movementSpeed; rb.AddForce(Vector3.down * force); } if (Input.GetKey(KeyCode.D)) { //transform.position += Vector3.right * Time.deltaTime * movementSpeed; rb.AddForce(Vector3.right * force); } } // power up handling foreach (string powerup in PowerupMaxTimes.Keys) { if (Powerups[powerup] == true) { PowerupTimes[powerup] -= Time.deltaTime; } if (PowerupTimes[powerup] <= 0) { Powerups[powerup] = false; } } if (!Powerups["Invincibility"]) { transform.GetChild(1).gameObject.SetActive(true); transform.GetChild(2).gameObject.SetActive(false); } else { transform.GetChild(2).gameObject.SetActive(true); transform.GetChild(1).gameObject.SetActive(false); } if (!Powerups["IncreaseFireRate"]) { transform.GetChild(3).gameObject.SetActive(false); } else { transform.GetChild(3).gameObject.SetActive(true); } if (!freeze) { // get the target screen position if (!useMouse) { // if using the tobii-eye, get the gaze position EyeXGazePoint lastGazePoint = GetComponent <GazePointDataComponent> ().LastGazePoint; if (lastGazePoint.IsWithinScreenBounds) { Vector2 screenSpace = lastGazePoint.Screen; lastShootPos = Camera.main.ScreenToWorldPoint(new Vector3(screenSpace.x, screenSpace.y, Camera.main.nearClipPlane)); lastShootPos.z = 0f; lockOn.transform.position = lastShootPos; lastShootPos = new Vector3(screenSpace.x, screenSpace.y, 0f); } } else { // if using the mouse, get the mouse position Vector3 mouse_po = Input.mousePosition; //Vector3 obj = Camera.main.WorldToScreenPoint (transform.position); lastShootPos = Camera.main.ScreenToWorldPoint(new Vector3(mouse_po.x, mouse_po.y, Camera.main.nearClipPlane)); lastShootPos.z = 0f; lockOn.transform.position = lastShootPos; lastShootPos = mouse_po; } // calculate the direction of the target position //lockOn.transform.position = lastShootPos; Vector3 direction = lastShootPos - Camera.main.WorldToScreenPoint(transform.position); direction.z = 0f; direction = direction.normalized; transform.up = -direction; // if it's time to shoot, shoot if (Powerups ["IncreaseFireRate"] == true && timer > 0.2f) { timer = 0.2f; } timer -= Time.deltaTime; if (timer <= 0.0f) { if (Powerups["IncreaseFireRate"] == true) { timer += 0.2f; } else { timer += timeToShoot; } Quaternion q = Quaternion.FromToRotation(Vector3.up, direction); GameObject go = (GameObject)Instantiate(projectile, transform.position, q); Rigidbody2D bulletRb = go.GetComponent <Rigidbody2D> (); bulletRb.AddForce(go.transform.up * bulletForce); AudioSource audio = GetComponent <AudioSource> (); if (audio != null) { audio.Play(); } } } }
protected void Update() { if (!active) { return; } ; LastGazePoint = _dataProvider.Last; for (int i = 0; i < buttonList.Count; i++) { buttonList[i].timeToLive -= Time.deltaTime; if (buttonList[i].timeToLive < 0) { buttonList[i].button.SetActive(true); buttonList.RemoveAt(i); i--; } } // Get the last fixation point. EyeXGazePoint lastGazePoint = GetComponent <GazePointDataComponent>().LastGazePoint; if (lastGazePoint.IsValid) { Vector2 screenCoordinates = lastGazePoint.Screen; Vector3 worldCoordinates = Camera.main.ScreenToWorldPoint(new Vector3(screenCoordinates.x, screenCoordinates.y, 0)); Ray gazeRay = Camera.main.ScreenPointToRay(new Vector3(screenCoordinates.x, screenCoordinates.y, 0)); if (Physics.Raycast(gazeRay.origin, gazeRay.direction, out gazeRaycastHit, 80)) { //Debug.Log ("I gazed: " + gazeRaycastHit.collider.gameObject.name); string gazedObject = gazeRaycastHit.collider.gameObject.name; // set collider to gazed position (used for multiple buttons that will be colored due to the collider then) if (gazeRaycastHit.transform.gameObject.tag == "ColorButton") { gazeRaycastHit.collider.gameObject.GetComponent <ColorButton>().hit(gazeRaycastHit.collider); //colorCollider.transform.position = gazeRaycastHit.transform.position; //colliderAlive = 0.5f; } else if (gazeRaycastHit.transform.gameObject.tag == "AudioButton") { gazeRaycastHit.collider.gameObject.GetComponent <AudioButton>().hit(gazeRaycastHit.collider); } else if (gazeRaycastHit.transform.gameObject.tag == "AudioColorButton") { gazeRaycastHit.collider.gameObject.GetComponent <AudioColorButton>().hit(gazeRaycastHit.collider); } else if (gazeRaycastHit.transform.gameObject.name == "Logo") { gazeRaycastHit.collider.gameObject.GetComponent <HubLogo>().hit(gazeRaycastHit.collider); } else if (gazeRaycastHit.transform.gameObject.name == "Arrow") { gazeRaycastHit.collider.gameObject.GetComponent <GravityButton>().hit(gazeRaycastHit.collider); } else if (gazeRaycastHit.transform.gameObject.tag == "Exploder") { gazeRaycastHit.collider.gameObject.GetComponent <Explosion>().hit(gazeRaycastHit.collider); } /*--------AudioFilesLevelFloppi afFloppi = GameObject.Find ("AudioFilesLevelFloppi").GetComponent<AudioFilesLevelFloppi>(); * * if(gazedObject.Contains("Button_red")){ * bool didPlay = AudioManager.instance.playAudioClipIfFree(afFloppi.getRedButtonClip()); * * if (didPlay) { * gazeRaycastHit.collider.gameObject.SetActive (false); * buttonList.Add (new ButtonTimeToLive(gazeRaycastHit.collider.gameObject, 0.1f)); * } * * } else if (gazedObject.Contains ("Button_green")) { * bool didPlay = AudioManager.instance.playAudioClipIfFree (afFloppi.getGreenButtonClip()); * * if (didPlay) { * gazeRaycastHit.collider.gameObject.SetActive (false); * buttonList.Add (new ButtonTimeToLive(gazeRaycastHit.collider.gameObject, 0.1f)); * } * * } else if (gazedObject.Contains ("Button_blue")) { * bool didPlay = AudioManager.instance.playAudioClipIfFree(afFloppi.getBlueButtonClip()); * * if (didPlay) { * gazeRaycastHit.collider.gameObject.SetActive (false); * buttonList.Add (new ButtonTimeToLive(gazeRaycastHit.collider.gameObject, 0.1f)); * } * }---------*/ } } /*if (colliderAlive > 0) { * colliderAlive -= Time.deltaTime; * if (colliderAlive <= 0) { * colorCollider.transform.position = new Vector3(3, 4, -47); * } * }*/ }
private void handlePanelRiddle() { Debug.Log("handlePanelRiddle"); this.timeSinceLastPanelRiddleHint += Time.deltaTime; EyeXGazePoint gazePoint = gazePointDataProvider.Last; EyeXEyePosition eyePosition = this.eyePositionDataProvider.Last; // check if both eyes are opened, only then retreive the last gazePoint if (/*!gazePoint.Screen.Equals (this.previousGazePoint.Screen)*/ true) { Vector2 screenCoordinates = gazePoint.Screen; Ray gazeRay = Camera.main.ScreenPointToRay(new Vector3(screenCoordinates.x, screenCoordinates.y, 0)); Debug.DrawRay(gazeRay.origin, gazeRay.direction, Color.magenta, 120.0f); //Ray debugRay = Camera.main.ScreenPointToRay (new Vector3(Screen.width / 2.0f, Screen.height / 2.0f, 0.0f)); //Debug.DrawRay (debugRay.origin, debugRay.direction, Color.magenta, 120.0f); if (Physics.Raycast(gazeRay.origin, gazeRay.direction, out gazeRaycastHit, 40.0f, ~raycastMask)) { //if (Physics.Raycast (debugRay.origin, debugRay.direction, out gazeRaycastHit, 40.0f)) { string gazedObject = gazeRaycastHit.collider.gameObject.name; // colorize the border of the wall-panel if (gazedObject.Contains("Panel")) { gazeRaycastHit.collider.gameObject.GetComponent <GazePanel>().didGazePanel(); Debug.Log("didGazePanel"); } // check if the gazed panel is the one that is currently lerping if (gazedObject == ((GameObject)blinkingLights [blinkingLightIndex]).name) { // the gazed object is the one that is currently lerping Debug.Log("gazing currently lerped panel"); if (currentLerpTimePaused == false) { currentLerpTimePaused = true; gazeStartedPanelColor = ((GameObject)blinkingLights [blinkingLightIndex]).GetComponentInChildren <MeshRenderer> ().material.color; this.continuesPanelDisgazeCounter = 0.0f; } } else { this.continuesPanelDisgazeCounter += Time.deltaTime; } // check if player gazed the goal if (gazedObject.Equals("Outer") || gazedObject.Equals("GoalDoor")) { // if goal collider was gazed play a hint if (this.panelRiddleHintsPlayed == 0) { AudioManager.instance.playAudioClipIfFree(audioFiles.getLocked_Stage01_AudioClip()); this.panelRiddleHintsPlayed++; } else { if (this.timeSinceLastPanelRiddleHint > 10.0f) { AudioManager.instance.playAudioClipIfFree(audioFiles.getLocked_Stage02_AudioClip()); this.timeSinceLastPanelRiddleHint = 0.0f; this.panelRiddleHintsPlayed++; } } } } else { Debug.Log("else from raycast if"); this.continuesPanelDisgazeCounter += Time.deltaTime; } } else { this.continuesPanelDisgazeCounter += Time.deltaTime; Debug.Log("equal locations"); } this.previousGazePoint = gazePoint; if (this.continuesPanelDisgazeCounter > 0.3f) { this.continuesPanelDisgazeCounter = 0.0f; this.currentLerpTimePaused = false; this.currentGazedLerpTime = 0.0f; } if (currentLerpTimePaused) { // if the current lerp time is paused this means the user is looking at the panel float lerpValue = this.currentGazedLerpTime / this.gazedColorLerpTime; //((GameObject) blinkingLights[this.blinkingLightIndex]).GetComponentInChildren<MeshRenderer>().material.color = Color.Lerp (this.gazeStartedPanelColor, this.gazePanelColor, lerpValue); // if the line above is in comment it is the version without lerping } /* else */ /* without else: version without lerping, with else: version with lerping when staring at the panel*/ if (currentLerpTime < standardColorLerpTime / 2.0f) { // fade-in lerp animation float lerpValue = this.currentLerpTime / (this.standardColorLerpTime / 2.0f); ((GameObject)blinkingLights [blinkingLightIndex]).GetComponentInChildren <MeshRenderer> ().material.color = Color.Lerp(this.standardPanelColor, this.highlightedPanelColor, lerpValue); } else { //Debug.Log("lerp out"); ((GameObject)blinkingLights [blinkingLightIndex]).GetComponentInChildren <MeshRenderer> ().material.color = Color.Lerp(this.highlightedPanelColor, this.standardPanelColor, this.currentLerpTime / (this.standardColorLerpTime / 2.0f) - 1.0f); } // Version where you stare at the light without lerping the color while watching currentLerpTime += Time.deltaTime; if (currentLerpTime > standardColorLerpTime) { currentLerpTime = 0.0f; blinkLight(); } if (currentLerpTimePaused) { // lerp time paused, use the gazedLerpTime this.currentGazedLerpTime += Time.deltaTime; if (this.currentGazedLerpTime > this.gazeToLockTime) { // call the method to delete the object from the array and mark it as done! this.activatePanel(); } } /* * // version where you stare at the light and it lerps * if (!currentLerpTimePaused) { * currentLerpTime += Time.deltaTime; * if (currentLerpTime > standardColorLerpTime) { * currentLerpTime = 0.0f; * blinkLight (); * } * * } else { * // lerp time paused, use the gazedLerpTime * this.currentGazedLerpTime += Time.deltaTime; * if (this.currentGazedLerpTime > gazedColorLerpTime) { * // call the method to delete the object from the array and mark it as done! * this.activatePanel(); * } * }*/ }
private void HandleEvent(string interactorid, InteractionEvent event_) { // Note that this method is called on a worker thread, so we MAY NOT access any game objects from here. // Therefore, we store the data in a variable and read from the variable in the Update() method. foreach (var behavior in event_.Behaviors) { if (behavior.BehaviorType == InteractionBehaviorType.GazePointData) { GazePointDataEventParams eventParams; if (behavior.TryGetGazePointDataEventParams(out eventParams)) { Last = new EyeXGazePoint((float)eventParams.X, (float)eventParams.Y, eventParams.Timestamp); } } else if (behavior.BehaviorType == InteractionBehaviorType.FixationData) { FixationDataEventParams fixationEventParams; if (behavior.TryGetFixationDataEventParams(out fixationEventParams)) { if (fixationEventParams.EventType == FixationDataEventType.Begin) { FixationCount++; } else if (fixationEventParams.EventType == FixationDataEventType.End) { // Do nothing right now } else { Last = new EyeXGazePoint((float)fixationEventParams.X, (float)fixationEventParams.Y, fixationEventParams.Timestamp); } } } } }
protected void Update() { LastGazePoint = _dataProvider.Last; }
public override void Execute(sceneTrackdata entity, EyeXGazePoint trackPoint) { }
abstract public void Execute(sceneTrackdata entity, EyeXGazePoint trackPoint);