- 07/10/2019 at 17:49 #12061
Thanks all for your responses. i was having similar questions and your answers were helpful to me.07/10/2019 at 20:00 #12063
Hi @dragontattoo, great! glad to hear it 🙂 Please don’t hesitate to get in touch again should you require any further assistance. Best Wishes.11/12/2019 at 14:14 #12464
Here’s what I did and as far as I can see it works.
I’ve use the Sample Scene of the Tobii SDK (TobiiXR for Unity package) and cut most of the code from the GazeVisualizer there. So take a look there is you want too!
This is the abbreviated bit of code:
public class EyeTrackOnScreen : MonoBehaviour
float _defaultDistance = 5f;
IEyeTrackingProvider provider = TobiiXR.Internal.Provider;
TobiiXR_EyeTrackingData eyeTrackingData = EyeTrackingDataHelper.Clone(provider.EyeTrackingDataLocal);
Matrix4x4 localToWorldMatrix = provider.LocalToWorldMatrix;
Vector3 worldForward = localToWorldMatrix.MultiplyVector(Vector3.forward);
TobiiXR_GazeRay gazeRay = eyeTrackingData.GazeRay;
Vector3 screenPosition = gazeRay.Origin + gazeRay.Direction.normalized * _defaultDistance;
float screenX = transform.localPosition.x + (Screen.width * 0.5);
float screenY = transform.localPosition.y + (Screen.height * 0.5);
Note: it is the Game screen that is calculated and so you have to take into account what size the game screen is at run time. If it’s full screen the gaze coordinates will conform to the resolution of your monitor. Is it running in a window, then the inner dimensions of that window will determine the max X and Y.
The screenPosition vector has its origin at the center of the screen.
The screenX and screenY are adjusted for the current Screen size.
Marco13/12/2019 at 12:55 #12473
Hi Marco, that’s great! Thanks so much for sharing your experience, much appreciated. We hope other users will find it useful as well 🙂
You must be logged in to reply to this topic.