コード例 #1
0
        /// <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));
        }
コード例 #2
0
        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 + "'");
        }
コード例 #3
0
 virtual protected void OnDisable()
 {
     FoveManager.UnregisterInterface(this);
     FoveManager.PoseUpdate.RemoveListener(UpdatePoseData);
     FoveManager.EyeProjectionUpdate.RemoveListener(UpdateGazeMatrices);
     FoveManager.EyePositionUpdate.RemoveListener(UpdateEyePosition);
     FoveManager.GazeUpdate.RemoveListener(UpdateGaze);
 }
コード例 #4
0
        /// <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));
        }
コード例 #5
0
 private void UnregisterCallbacks()
 {
     FoveManager.UnregisterInterface(this);
     FoveManager.PoseUpdate.RemoveListener(UpdatePoseData);
     FoveManager.EyeProjectionUpdate.RemoveListener(UpdateGazeMatrices);
     FoveManager.EyePositionUpdate.RemoveListener(UpdateEyePosition);
     FoveManager.GazeUpdate.RemoveListener(UpdateGaze);
 }
コード例 #6
0
 virtual protected void OnDisable()
 {
     FoveManager.UnregisterInterface(this);
     FoveManager.AddInUpdate -= UpdateData;
     if (registerCameraObject)
     {
         RemoveCameraObject();
     }
 }
コード例 #7
0
        /// <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));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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();
        }
コード例 #12
0
        virtual protected void UpdatePoseData()
        {
            if (fetchOrientation)
            {
                hmdOrientation = FoveManager.GetHmdRotation();
            }

            if (fetchPosition)
            {
                hmdPosition = FoveManager.GetHmdPosition(poseType == PlayerPose.Standing);
            }

            transform.localPosition = hmdPosition;
            transform.localRotation = hmdOrientation;
        }
コード例 #13
0
        // 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);
        }
コード例 #14
0
        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 + "'");
        }
コード例 #15
0
        /// <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));
        }
コード例 #16
0
        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();
        }
コード例 #17
0
 private void UpdateGazeMatrices()
 {
     FoveManager.GetProjectionMatrices(_cam.nearClipPlane, _cam.farClipPlane, ref _stereoData[0].projection, ref _stereoData[1].projection);
 }
コード例 #18
0
 virtual protected void UpdateViewParameters()
 {
     eyeOffsets         = FoveManager.GetEyeOffsets();
     projectionMatrices = FoveManager.GetProjectionMatrices(cam.nearClipPlane, cam.farClipPlane);
 }
コード例 #19
0
 private bool CanSee()
 {
     return(FoveManager.CheckEyesClosed() != Eye.Both);
 }