/// <summary> /// Returns the data that describes the convergence point of the eyes this frame. See the description of the /// `GazeConvergenceData` for more detail on how to use this information. /// </summary> /// <returns>A struct describing the gaze convergence in HMD-relative space.</returns> public GazeConvergenceData GetGazeConvergence_Immediate() { GazeConvergenceData localConvergence = FoveManager.GetLocalGazeConvergence_Immediate(); var localRay = localConvergence.ray; return(new GazeConvergenceData(TransformLocalRay(localRay), localConvergence.distance)); }
virtual protected bool CanSee() { if (!eyeConvergeRay.IsValid) { return(false); } var left = FoveManager.GetEyeState(Eye.Left); var right = FoveManager.GetEyeState(Eye.Right); var gazeCastPolicy = FoveManager.GazeCastPolicy; switch (gazeCastPolicy) { case GazeCastPolicy.DismissBothEyeClosed: return((left.IsValid && left.value == EyeState.Opened) || (right.IsValid && right.value == EyeState.Opened)); case GazeCastPolicy.DismissOneEyeClosed: return(left.IsValid && right.IsValid && left.value == EyeState.Opened && right.value == EyeState.Opened); case GazeCastPolicy.NeverDismiss: return(true); } throw new NotImplementedException("Unknown gaze cast policy '" + gazeCastPolicy + "'"); }
virtual protected void OnDisable() { FoveManager.UnregisterInterface(this); FoveManager.PoseUpdate.RemoveListener(UpdatePoseData); FoveManager.EyeProjectionUpdate.RemoveListener(UpdateGazeMatrices); FoveManager.EyePositionUpdate.RemoveListener(UpdateEyePosition); FoveManager.GazeUpdate.RemoveListener(UpdateGaze); }
/// <summary> /// Get a set of Unity Ray objects which describe where in the scene each of the user's eyes are looking right /// now.</summary> /// <returns>The set of Unity Ray objects describing the user's eye gaze.</returns> /// <remarks>Typically gaze data is cached at the start of each frame to yield consistent results for each /// frame. This function ignores the cached value and creates a new struct every time, so be careful.</remarks> public EyeRays GetGazeRays_Immediate() { UnityRay left, right; CalculateGazeRays(out left, out right, FoveManager.GetLeftEyeVector_Immediate(), FoveManager.GetRightEyeVector_Immediate()); return(new EyeRays(left, right)); }
private void UnregisterCallbacks() { FoveManager.UnregisterInterface(this); FoveManager.PoseUpdate.RemoveListener(UpdatePoseData); FoveManager.EyeProjectionUpdate.RemoveListener(UpdateGazeMatrices); FoveManager.EyePositionUpdate.RemoveListener(UpdateEyePosition); FoveManager.GazeUpdate.RemoveListener(UpdateGaze); }
virtual protected void OnDisable() { FoveManager.UnregisterInterface(this); FoveManager.AddInUpdate -= UpdateData; if (registerCameraObject) { RemoveCameraObject(); } }
/// <summary> /// Returns the current convergence point of the eyes. See the description of the /// <see cref="GazeConvergenceData"/> for more detail on how to use this information. /// By default, it returns the value of the current frame. /// Set <paramref name="immediate"/> to <c>true</c> to re-query the latest value to the HMD. /// </summary> /// <returns>The gaze convergence in world space.</returns> public GazeConvergenceData GetGazeConvergence(bool immediate = false) { if (!immediate) { return(_eyeConverge); } var localGaze = FoveManager.GetHMDGazeConvergence(true); return(GetWorldSpaceConvergence(ref localGaze.ray, localGaze.distance)); }
virtual protected void UpdateGaze() { if (!fetchGaze) { eyeConvergeRay.error = ErrorCode.Data_NoUpdate; eyeRays.left.error = ErrorCode.Data_NoUpdate; eyeRays.right.error = ErrorCode.Data_NoUpdate; } eyeConvergeRay = GetWorldSpaceConvergence(FoveManager.GetHmdCombinedGazeRay()); eyeRays.left = CalculateWorldGazeVector(eyeOffsets.left, FoveManager.GetHmdGazeVector(Eye.Left)); eyeRays.right = CalculateWorldGazeVector(eyeOffsets.right, FoveManager.GetHmdGazeVector(Eye.Right)); }
private static void EnsureInitialization() { if (m_sResearch != null) { return; } FoveManager.RegisterAddIn(AcceptAddIn); FoveManager.AddInUpdate += UpdateImages; m_sEyesTexture = null; m_sPositionTexture = null; m_sResearch.RegisterCapabilities(ResearchCapabilities.EyeImage | ResearchCapabilities.PositionImage); }
private void RecreateLayer() { FoveManager.UnregisterInterface(this); var createInfo = new CompositorLayerCreateInfo { alphaMode = AlphaMode.Auto, disableDistortion = disableDistortion, disableFading = disableFading, disableTimewarp = disableTimewarp, type = layerType }; FoveManager.RegisterInterface(createInfo, this); }
private static void InitializeStaticMembers() { m_sInstance = FindObjectOfType <FoveManager>(); if (m_sInstance == null) { m_sInstance = new GameObject("~FOVE Manager").AddComponent <FoveManager>(); DontDestroyOnLoad(m_sInstance); } m_worldScale = FoveSettings.WorldScale; m_renderScale = FoveSettings.RenderScale; m_submitNativeFunc = GetSubmitFunctionPtr(); m_wfrpNativeFunc = GetWfrpFunctionPtr(); }
virtual protected void UpdatePoseData() { if (fetchOrientation) { hmdOrientation = FoveManager.GetHmdRotation(); } if (fetchPosition) { hmdPosition = FoveManager.GetHmdPosition(poseType == PlayerPose.Standing); } transform.localPosition = hmdPosition; transform.localRotation = hmdOrientation; }
// Private callbacks and support for HMD events private void RegisterEventCallbacks() { var createInfo = new CompositorLayerCreateInfo { alphaMode = AlphaMode.Auto, disableDistortion = disableDistortion, disableFading = disableFading, disableTimewarp = disableTimewarp, type = layerType }; FoveManager.RegisterInterface(createInfo, this); FoveManager.PoseUpdate.AddListener(UpdatePoseData); FoveManager.EyeProjectionUpdate.AddListener(UpdateGazeMatrices); FoveManager.EyePositionUpdate.AddListener(UpdateEyePosition); FoveManager.GazeUpdate.AddListener(UpdateGaze); }
virtual protected bool CanSee() { var closedEyes = FoveManager.CheckEyesClosed(); switch (gazeCastPolicy) { case GazeCastPolicy.DismissWhenBothEyesClosed: return(closedEyes != Eye.Both); case GazeCastPolicy.DismissWhenOneEyeClosed: return(closedEyes == Eye.Neither); case GazeCastPolicy.NeverDismiss: return(true); } throw new NotImplementedException("Unknown gaze cast policy '" + gazeCastPolicy + "'"); }
/// <summary> /// Get eye rays describing where in the scene each of the user's eyes are looking. /// By default, it returns the value of the current frame. /// Set <paramref name="immediate"/> to <c>true</c> to re-query the latest value to the HMD. /// </summary> /// <returns>Eye rays describing the user's gaze in world space.</returns> public EyeRays GetGazeRays(bool immediate = false) { if (!immediate) { return(new EyeRays(_eyeRayLeft, _eyeRayRight)); } var leftEyeVector = fetchGaze? FoveManager.GetLeftEyeVector(true): Vector3.forward; var rightEyeVector = fetchGaze? FoveManager.GetRightEyeVector(true): Vector3.forward; var leftEyeOffset = FoveManager.GetLeftEyeOffset(true); var rightEyeOffset = FoveManager.GetRightEyeVector(true); Ray left, right; CalculateGazeRays(ref leftEyeOffset, ref rightEyeOffset, ref leftEyeVector, ref rightEyeVector, out left, out right); return(new EyeRays(left, right)); }
private static void InitializeStaticMembers() { m_sInstance = FindObjectOfType <FoveManager>(); if (m_sInstance == null) { m_sInstance = new GameObject("~FOVE Manager").AddComponent <FoveManager>(); DontDestroyOnLoad(m_sInstance); } m_sRenderCamera = m_sInstance.GetComponentInChildren <Camera>(); if (m_sRenderCamera == null) { m_sRenderCamera = new GameObject("~FOVE Renderer").AddComponent <Camera>(); m_sRenderCamera.transform.SetParent(m_sInstance.transform); m_sRenderCamera.enabled = false; } m_worldScale = FoveSettings.WorldScale; m_renderScale = FoveSettings.RenderScale; m_submitNativeFunc = GetSubmitFunctionPtr(); m_wfrpNativeFunc = GetWfrpFunctionPtr(); }
private void UpdateGazeMatrices() { FoveManager.GetProjectionMatrices(_cam.nearClipPlane, _cam.farClipPlane, ref _stereoData[0].projection, ref _stereoData[1].projection); }
virtual protected void UpdateViewParameters() { eyeOffsets = FoveManager.GetEyeOffsets(); projectionMatrices = FoveManager.GetProjectionMatrices(cam.nearClipPlane, cam.farClipPlane); }
private bool CanSee() { return(FoveManager.CheckEyesClosed() != Eye.Both); }