Example #1
0
        private IEnumerable <GameObject> FindObjectsInGaze(IEnumerable <GazePoint> gazePoints, Camera camera)
        {
            var points = gazePoints
                         .Where(gazePoint => gazePoint.IsWithinScreenBounds)
                         .Select(gazePoint => gazePoint.Screen);
            var objectsInGaze = new List <GameObject>();

            IEnumerable <RaycastHit> hitInfos;

            if (HitTestFromPoint.FindMultipleObjectsInWorldFromMultiplePoints(out hitInfos, points, camera,
                                                                              MaximumDistance, LayerMask))
            {
                foreach (var raycastHit in hitInfos)
                {
                    objectsInGaze.Add(raycastHit.collider.gameObject);
                }
            }

            return(objectsInGaze);
        }
        public FocusedObject GetFocusedObject(IEnumerable <GazePoint> lastGazePoints, Camera camera)
        {
            var gazePoint = lastGazePoints.Last();

            if (!gazePoint.IsWithinScreenBounds)
            {
                return(FocusedObject.Invalid);
            }

            GameObject focusedObject = null;
            RaycastHit hitInfo;

            if (HitTestFromPoint.FindObjectInWorld(out hitInfo, gazePoint.Screen, camera, MaximumDistance, LayerMask))
            {
                if (GazeFocus.IsFocusableObject(hitInfo.collider.gameObject))
                {
                    focusedObject = hitInfo.collider.gameObject;
                }
            }

            return(new FocusedObject(focusedObject));
        }
Example #3
0
        private IEnumerable <GameObject> FindObjectsInGaze(Vector2 gazePoint, Camera camera)
        {
            var   objectsInGaze = new List <GameObject>();
            float fovealAngle   = 2.0f;
            float distanceGazeOriginToScreen_inches = 24f;
            var   dpi = Screen.dpi > 0 ? Screen.dpi : 100;
            float fovealRadius_inches = Mathf.Tan(fovealAngle * Mathf.Deg2Rad) * distanceGazeOriginToScreen_inches;
            int   fovealRadius_pixels = Mathf.RoundToInt(fovealRadius_inches * dpi);

            var points = PatternGenerator.CreateCircularAreaUniformPattern(gazePoint, fovealRadius_pixels, 4);
            IEnumerable <RaycastHit> hitInfos;

            if (HitTestFromPoint.FindMultipleObjectsInWorldFromMultiplePoints(out hitInfos, points, camera,
                                                                              MaximumDistance, LayerMask))
            {
                foreach (var raycastHit in hitInfos)
                {
                    objectsInGaze.Add(raycastHit.collider.gameObject);
                }
            }

            return(objectsInGaze);
        }