/// <summary> /// get the raw gaze direction in world space. includes fove/pupil labs eye tracking /// </summary> public Vector3 GetWorldGazeDirection() { Vector3 gazeDirection = CameraTransform.forward; #if CVR_FOVE //direction var eyeRays = FoveInstance.GetGazeRays(); var ray = eyeRays.left; gazeDirection = new Vector3(ray.direction.x, ray.direction.y, ray.direction.z); gazeDirection.Normalize(); #elif CVR_PUPIL //var v2 = PupilGazeTracker.Instance.GetEyeGaze(PupilGazeTracker.GazeSource.BothEyes); //0-1 screen pos var v2 = PupilData._2D.GetEyeGaze("0"); //if it doesn't find the eyes, skip this snapshot //if (PupilTools.Confidence(PupilData.rightEyeID) > 0.1f) { var ray = cam.ViewportPointToRay(v2); gazeDirection = ray.direction.normalized; } //else uses HMD forward #elif CVR_TOBIIVR gazeDirection = _eyeTracker.LatestProcessedGazeData.CombinedGazeRayWorld.direction; #elif CVR_NEURABLE gazeDirection = NeurableUnity.NeurableUser.Instance.NeurableCam.GazeRay().direction; #elif CVR_AH gazeDirection = ah_calibrator.GetGazeVector(filterType: FilterType.ExponentialMovingAverage); #endif return(gazeDirection); }
/// <summary> /// get the raw gaze direction in world space. includes fove/pupil labs eye tracking /// </summary> public Vector3 GetWorldGazeDirection() { Vector3 gazeDirection = GameplayReferences.HMD.forward; #if CVR_FOVE //direction var eyeRays = GameplayReferences.FoveInstance.GetGazeRays(); var ray = eyeRays.left; gazeDirection = new Vector3(ray.direction.x, ray.direction.y, ray.direction.z); gazeDirection.Normalize(); #elif CVR_PUPIL gazeDirection = GameplayReferences.HMD.TransformDirection(localGazeDirection); #elif CVR_TOBIIVR if (Tobii.XR.TobiiXR.Internal.Provider.EyeTrackingDataLocal.GazeRay.IsValid) { gazeDirection = GameplayReferences.HMD.TransformDirection(Tobii.XR.TobiiXR.Internal.Provider.EyeTrackingDataLocal.GazeRay.Direction); } #elif CVR_VIVEPROEYE var ray = new Ray(); if (ViveSR.anipal.Eye.SRanipal_Eye.GetGazeRay(ViveSR.anipal.Eye.GazeIndex.COMBINE, out ray)) { gazeDirection = GameplayReferences.HMD.TransformDirection(ray.direction); } #elif CVR_VARJO if (Varjo.VarjoPlugin.InitGaze()) { var data = Varjo.VarjoPlugin.GetGaze(); if (data.status != Varjo.VarjoPlugin.GazeStatus.INVALID) { var ray = data.gaze; gazeDirection = GameplayReferences.HMD.TransformDirection(new Vector3((float)ray.forward[0], (float)ray.forward[1], (float)ray.forward[2])); } } #elif CVR_NEURABLE gazeDirection = Neurable.Core.NeurableUser.Instance.NeurableCam.GazeRay().direction; #elif CVR_AH gazeDirection = ah_calibrator.GetGazeVector(filterType: FilterType.ExponentialMovingAverage); #elif CVR_SNAPDRAGON gazeDirection = SvrManager.Instance.leftCamera.transform.TransformDirection(SvrManager.Instance.EyeDirection); #elif CVR_XR UnityEngine.XR.Eyes eyes; if (UnityEngine.XR.InputDevices.GetDeviceAtXRNode(UnityEngine.XR.XRNode.CenterEye).TryGetFeatureValue(UnityEngine.XR.CommonUsages.eyesData, out eyes)) { //first arg probably to mark which feature the value should return. type alone isn't enough to indicate the property Vector3 convergancePoint; if (eyes.TryGetFixationPoint(out convergancePoint)) { Vector3 leftPos = Vector3.zero; eyes.TryGetLeftEyePosition(out leftPos); Vector3 rightPos = Vector3.zero; eyes.TryGetRightEyePosition(out rightPos); Vector3 centerPos = (rightPos + leftPos) / 2f; gazeDirection = (convergancePoint - centerPos).normalized; } } #endif return(gazeDirection); }
/// <summary> /// get the raw gaze direction in world space. includes fove/pupil labs eye tracking /// </summary> public Vector3 GetWorldGazeDirection() { Vector3 gazeDirection = GameplayReferences.HMD.forward; #if CVR_FOVE //direction var eyeRays = FoveInstance.GetGazeRays(); var ray = eyeRays.left; gazeDirection = new Vector3(ray.direction.x, ray.direction.y, ray.direction.z); gazeDirection.Normalize(); #elif CVR_PUPIL //var v2 = PupilGazeTracker.Instance.GetEyeGaze(PupilGazeTracker.GazeSource.BothEyes); //0-1 screen pos var v2 = PupilData._2D.GetEyeGaze("0"); //if it doesn't find the eyes, skip this snapshot //if (PupilTools.Confidence(PupilData.rightEyeID) > 0.1f) { var ray = GameplayReferences.HMDCameraComponent.ViewportPointToRay(v2); gazeDirection = ray.direction.normalized; } //else uses HMD forward #elif CVR_TOBIIVR gazeDirection = _eyeTracker.LatestProcessedGazeData.CombinedGazeRayWorld.direction; #elif CVR_VIVEPROEYE var ray = new Ray(); if (ViveSR.anipal.Eye.SRanipal_Eye.GetGazeRay(ViveSR.anipal.Eye.GazeIndex.COMBINE, out ray)) { gazeDirection = GameplayReferences.HMD.TransformDirection(ray.direction); } #elif CVR_VARJO if (Varjo.VarjoPlugin.InitGaze()) { var data = Varjo.VarjoPlugin.GetGaze(); if (data.status != Varjo.VarjoPlugin.GazeStatus.INVALID) { var ray = data.gaze; gazeDirection = GameplayReferences.HMD.TransformDirection(new Vector3((float)ray.forward[0], (float)ray.forward[1], (float)ray.forward[2])); } } #elif CVR_NEURABLE gazeDirection = Neurable.Core.NeurableUser.Instance.NeurableCam.GazeRay().direction; #elif CVR_AH gazeDirection = ah_calibrator.GetGazeVector(filterType: FilterType.ExponentialMovingAverage); #elif CVR_SNAPDRAGON gazeDirection = SvrManager.Instance.leftCamera.transform.TransformDirection(SvrManager.Instance.EyeDirection); #endif return(gazeDirection); }
public bool CombinedWorldGazeRay(out Ray ray) { Vector3 r = ah_calibrator.GetGazeVector(filterType: AdhawkApi.Numerics.Filters.FilterType.ExponentialMovingAverage); Vector3 x = ah_calibrator.GetGazeOrigin(); ray = new Ray(x, r); return(true); }
/// <summary> /// get the raw gaze direction in world space. includes fove/pupil labs eye tracking /// </summary> public Vector3 GetWorldGazeDirection() { Vector3 gazeDirection = GameplayReferences.HMD.forward; #if CVR_FOVE //direction var eyeRays = GameplayReferences.FoveInstance.GetGazeRays(); var ray = eyeRays.left; gazeDirection = new Vector3(ray.direction.x, ray.direction.y, ray.direction.z); gazeDirection.Normalize(); #elif CVR_PUPIL gazeDirection = GameplayReferences.HMD.TransformDirection(localGazeDirection); #elif CVR_TOBIIVR if (Tobii.XR.TobiiXR.Internal.Provider.EyeTrackingDataLocal.GazeRay.IsValid) { gazeDirection = GameplayReferences.HMD.TransformDirection(Tobii.XR.TobiiXR.Internal.Provider.EyeTrackingDataLocal.GazeRay.Direction); } #elif CVR_VIVEPROEYE var ray = new Ray(); if (ViveSR.anipal.Eye.SRanipal_Eye.GetGazeRay(ViveSR.anipal.Eye.GazeIndex.COMBINE, out ray)) { gazeDirection = GameplayReferences.HMD.TransformDirection(ray.direction); } #elif CVR_VARJO if (Varjo.VarjoPlugin.InitGaze()) { var data = Varjo.VarjoPlugin.GetGaze(); if (data.status != Varjo.VarjoPlugin.GazeStatus.INVALID) { var ray = data.gaze; gazeDirection = GameplayReferences.HMD.TransformDirection(new Vector3((float)ray.forward[0], (float)ray.forward[1], (float)ray.forward[2])); } } #elif CVR_NEURABLE gazeDirection = Neurable.Core.NeurableUser.Instance.NeurableCam.GazeRay().direction; #elif CVR_AH gazeDirection = ah_calibrator.GetGazeVector(filterType: FilterType.ExponentialMovingAverage); #elif CVR_SNAPDRAGON gazeDirection = SvrManager.Instance.leftCamera.transform.TransformDirection(SvrManager.Instance.EyeDirection); #endif return(gazeDirection); }