コード例 #1
0
    public void Tick()
    {
#if TOBIIXR_HTCPROVIDER
        _hmdToWorldTransformer.Tick();
        EnsureHTCFrameworkRunning();

        if (SRanipal_Eye_Framework.Status != SRanipal_Eye_Framework.FrameworkStatus.WORKING)
        {
            return;
        }

        EyeTrackingData.Timestamp       = Time.unscaledTime;
        EyeTrackingData.GazeRay.IsValid = SRanipal_Eye.GetGazeRay(GazeIndex.COMBINE, out EyeTrackingData.GazeRay.Origin, out EyeTrackingData.GazeRay.Direction);

        // Blink
        float eyeOpenness        = 0;
        var   eyeOpennessIsValid = SRanipal_Eye.GetEyeOpenness(EyeIndex.LEFT, out eyeOpenness);
        EyeTrackingData.IsLeftEyeBlinking = !eyeOpennessIsValid || eyeOpenness < 0.1;
        eyeOpennessIsValid = SRanipal_Eye.GetEyeOpenness(EyeIndex.RIGHT, out eyeOpenness);
        EyeTrackingData.IsRightEyeBlinking = !eyeOpennessIsValid || eyeOpenness < 0.1;

        // Convergence distance
        Vector3 leftRayOrigin, rightRayOrigin, leftRayDirection, rightRayDirection;
        var     leftRayValid  = SRanipal_Eye.GetGazeRay(GazeIndex.LEFT, out leftRayOrigin, out leftRayDirection);
        var     rightRayValid = SRanipal_Eye.GetGazeRay(GazeIndex.RIGHT, out rightRayOrigin, out rightRayDirection);

        if (leftRayValid && rightRayValid)
        {
            EyeTrackingData.ConvergenceDistanceIsValid = true;
            var convergenceDistance_mm = Convergence.CalculateDistance(
                leftRayOrigin * 1000f,
                leftRayDirection,
                rightRayOrigin * 1000f,
                rightRayDirection
                );
            EyeTrackingData.ConvergenceDistance = convergenceDistance_mm / 1000f; // Convert to meters
        }
        else
        {
            EyeTrackingData.ConvergenceDistanceIsValid = false;
        }

        // Transform to world space
        _localToWorldMatrix = _hmdToWorldTransformer.GetLocalToWorldMatrix();
        EyeTrackingDataHelper.TransformGazeData(EyeTrackingData, _localToWorldMatrix);
#endif
    }
コード例 #2
0
    public void Tick()
    {
        _hmdToWorldTransformer.Tick();
        EnsureHTCFrameworkRunning();

        if (SRanipal_Eye_Framework.Status != SRanipal_Eye_Framework.FrameworkStatus.WORKING)
        {
            return;
        }

        _eyeTrackingDataLocal.Timestamp       = Time.unscaledTime;
        _eyeTrackingDataLocal.GazeRay.IsValid = SRanipal_Eye.GetGazeRay(GazeIndex.COMBINE, out _eyeTrackingDataLocal.GazeRay.Origin, out _eyeTrackingDataLocal.GazeRay.Direction);

        // Blink
        float eyeOpenness;
        var   eyeOpennessIsValid = SRanipal_Eye.GetEyeOpenness(EyeIndex.LEFT, out eyeOpenness);

        _eyeTrackingDataLocal.IsLeftEyeBlinking = !eyeOpennessIsValid || eyeOpenness < 0.1;
        eyeOpennessIsValid = SRanipal_Eye.GetEyeOpenness(EyeIndex.RIGHT, out eyeOpenness);
        _eyeTrackingDataLocal.IsRightEyeBlinking = !eyeOpennessIsValid || eyeOpenness < 0.1;

        // Convergence distance
        Vector3 leftRayOrigin, rightRayOrigin, leftRayDirection, rightRayDirection;
        var     leftRayValid  = SRanipal_Eye.GetGazeRay(GazeIndex.LEFT, out leftRayOrigin, out leftRayDirection);
        var     rightRayValid = SRanipal_Eye.GetGazeRay(GazeIndex.RIGHT, out rightRayOrigin, out rightRayDirection);

        if (leftRayValid && rightRayValid)
        {
            _eyeTrackingDataLocal.ConvergenceDistanceIsValid = true;
            var convergenceDistance_mm = Convergence.CalculateDistance(
                leftRayOrigin * 1000f,
                leftRayDirection,
                rightRayOrigin * 1000f,
                rightRayDirection
                );
            _eyeTrackingDataLocal.ConvergenceDistance = convergenceDistance_mm / 1000f; // Convert to meters
        }
        else
        {
            _eyeTrackingDataLocal.ConvergenceDistanceIsValid = false;
        }

        // Update world transform
        _hmdToWorldTransformer.Tick();
        _localToWorldMatrix = _hmdToWorldTransformer.GetLocalToWorldMatrix();
    }