I working with a Microsoft Hololens2 and the Windows Mixed Reality Toolkit (MRTK3). I'm trying to programmatically get hold of the current Gaze direction and origin, which is explained here for MRTK2:
void LogGazeDirectionOrigin()
{
Debug.Log("Gaze is looking in direction: "
+ CoreServices.InputSystem.GazeProvider.GazeDirection);
Debug.Log("Gaze origin is: "
+ CoreServices.InputSystem.GazeProvider.GazeOrigin);
}
However, how do I do this in MRTK3?
Searched on Windows forums with no luck
For future reference: To get gaze direction in MRTK3 you have multiple options
FuzzyGazeInteractor: By default, theMRTK XR Righas theMRTK Gaze Controllerattached as a child which contains theFuzzyGazeInteractor. For more information see this documentation by Microsoft. To get gaze origin and direction, you can then do the following, assuminggazeInteractoris a reference to theFuzzyGazeInteractor:2.
ExtendedEyeGazeDataProvider: In contrast to regular eye tracking, this interface allows extraction of additional, more detailed information such as separated gaze information about left & right eye. See this documentation by Microsoft in that regard. Getting gaze direction & origin (for example for combined gaze) then works as follows, assuminggazeProvideris a reference to theExtendedEyeGazeDataProvider:3. Regarding head gaze: If you are actually interested in the user's head gaze, you can just use information about the
MainCamera. Head gaze origin & direction could then be estimated using the following approach:Also, if no eye tracking is available, the named interfaces will return head gaze as a fallback. You could also disable eye gaze composite completely so that head gaze is always used (see this github issue as an example).