Ejemplo n.º 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;
         }
     }
 }
Ejemplo n.º 2
0
    private void Update()
    {
        if (isCarried)
        {
            float distanceToFoyerSqr = (this.transform.position - player.transform.position).sqrMagnitude;
            float blinkTime          = 0;
            if (distanceToFoyerSqr > maxBlinkDistanceSqr)
            {
                blinkTime = slowestBlinkTime;
            }
            else
            {
                blinkTime = (distanceToFoyerSqr / maxBlinkDistanceSqr) * slowestBlinkTime;
                if (blinkTime < fastestBlinkTime)
                {
                    blinkTime = fastestBlinkTime;
                }
            }

            timer += Time.deltaTime;
            if (timer > blinkTime)
            {
                timer      = 0;
                blinkState = !blinkState;
            }
            OnBlink?.Invoke(blinkState, blinkTime);
        }
    }
Ejemplo n.º 3
0
    }                                                                 //Debug.Log("onUpdateRawdataEvent " + value); }

    void onUpdateBlinkEvent(int value)
    {
        OnBlink?.Invoke(value);
    }                                                             //Debug.Log("onUpdateBlinkEvent " + value);}