/// <inheritdoc /> public bool Equals([AllowNull] Camera other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Up == other.Up || Up != null && Up.Equals(other.Up) ) && ( Center == other.Center || Center != null && Center.Equals(other.Center) ) && ( Eye == other.Eye || Eye != null && Eye.Equals(other.Eye) ) && ( Projection == other.Projection || Projection != null && Projection.Equals(other.Projection) )); }
void Update() { if (!Application.isPlaying) { return; } if (!VRMode.IsRunningInVRMode && !_IsOff) { if (!GazeManager.Instance.IsCalibrating) { // If running in 'remote' mode and not calibrating, we position eyes // and set size based on distance _EyesDistance = GazeFrameCache.Instance.GetLastUserPosition().Z; _DepthMod = (1 - _EyesDistance) * .25f; Vector3 scaleVec = new Vector3((float)(_DepthMod), (float)(_DepthMod), (float)_EyeBaseScale.z); Eye left = GazeFrameCache.Instance.GetLastLeftEye(); Eye right = GazeFrameCache.Instance.GetLastRightEye(); double angle = GazeFrameCache.Instance.GetLastEyesAngle(); if (null != left) { if (!left.Equals(_LastLeftEye)) { _LastLeftEye = left; if (!_LeftEye.IsRendererEnabled()) { _LeftEye.SetRendererEnabled(true); } //position GO based on screen coordinates Point2D gp = UnityGazeUtils.GetRelativeToScreenSpace(left.PupilCenterCoordinates); _LeftEye.SetWorldPositionFromGaze(_Camera, gp, _LeftEye.transform.localPosition.z); _LeftEye.transform.localScale = scaleVec * _EyeScaleInitSize; _LeftEye.transform.localEulerAngles = new Vector3(_LeftEye.transform.localEulerAngles.x, _LeftEye.transform.localEulerAngles.y, (float)-angle); } } else { if (_LeftEye.IsRendererEnabled()) { _LeftEye.SetRendererEnabled(false); } } if (null != right) { if (!right.Equals(_LastRightEye)) { _LastRightEye = right; if (!_RightEye.IsRendererEnabled()) { _RightEye.SetRendererEnabled(true); } //position GO based on screen coordinates Point2D gp = UnityGazeUtils.GetRelativeToScreenSpace(right.PupilCenterCoordinates); _RightEye.SetWorldPositionFromGaze(_Camera, gp, _RightEye.transform.localPosition.z); _RightEye.transform.localScale = scaleVec * _EyeScaleInitSize; _RightEye.transform.localEulerAngles = new Vector3(_RightEye.transform.localEulerAngles.x, _RightEye.transform.localEulerAngles.y, (float)-angle); } } else { if (_RightEye.IsRendererEnabled()) { _RightEye.SetRendererEnabled(false); } } } } else { if (_LeftEye.IsRendererEnabled()) { _LeftEye.SetRendererEnabled(false); } if (_RightEye.IsRendererEnabled()) { _RightEye.SetRendererEnabled(false); } } }
void Update() { if (!Application.isPlaying) { return; } if (!VRMode.IsRunningInVRMode && !_IsOff) { if (!GazeManager.Instance.IsCalibrating) { // If running in 'remote' mode and not calibrating, we position eyes // and set size based on distance _EyesDistance = GazeFrameCache.Instance.GetLastUserPosition().Z; _DepthMod = (1 - _EyesDistance) * .25f; Vector3 scaleVec = new Vector3((float)(_DepthMod), (float)(_DepthMod), (float)_EyeBaseScale.z); Eye left = GazeFrameCache.Instance.GetLastLeftEye(); Eye right = GazeFrameCache.Instance.GetLastRightEye(); double angle = GazeFrameCache.Instance.GetLastEyesAngle(); if (null != left) { if (!left.Equals(_LastLeftEye)) { _LastLeftEye = left; if (!_LeftEye.IsRendererEnabled()) { _LeftEye.SetRendererEnabled(true); } //position GO based on screen coordinates Point2D gp = UnityGazeUtils.GetRelativeToScreenSpace(left.PupilCenterCoordinates); //////////////// // normalize coordinates to top right corner //float xMin = 0, xMax = Screen.width, yMin = 0, yMax = Screen.height; float xMin = 0, xMax = xScreen, yMin = 0, yMax = yScreen; float xOffset = xMax * (1 - _ResizeMultiplier), yOffset = yMax * (1 - _ResizeMultiplier); gp.X = (((gp.X - xMin) / (xMax - xMin)) * _ResizeMultiplier * xMax + xOffset); gp.Y = (((gp.Y - yMin) / (yMax - yMin)) * _ResizeMultiplier * yMax + yOffset) - yMax * (1 - _ResizeMultiplier); //////////////// _LeftEye.SetWorldPositionFromGaze(_Camera, gp, _LeftEye.transform.localPosition.z); _LeftEye.transform.localScale = scaleVec * _EyeScaleInitSize; _LeftEye.transform.localEulerAngles = new Vector3(_LeftEye.transform.localEulerAngles.x, _LeftEye.transform.localEulerAngles.y, (float)-angle); } } else { if (_LeftEye.IsRendererEnabled()) { _LeftEye.SetRendererEnabled(false); } } if (null != right) { if (!right.Equals(_LastRightEye)) { _LastRightEye = right; if (!_RightEye.IsRendererEnabled()) { _RightEye.SetRendererEnabled(true); } //position GO based on screen coordinates Point2D gp = UnityGazeUtils.GetRelativeToScreenSpace(right.PupilCenterCoordinates); //////////////// // normalize coordinates to top right corner //float xMin = 0, xMax = Screen.width, yMin = 0, yMax = Screen.height; float xMin = 0, xMax = xScreen, yMin = 0, yMax = yScreen; float xOffset = xMax * (1 - _ResizeMultiplier), yOffset = yMax * (1 - _ResizeMultiplier); gp.X = (((gp.X - xMin) / (xMax - xMin)) * _ResizeMultiplier * xMax + xOffset); gp.Y = (((gp.Y - yMin) / (yMax - yMin)) * _ResizeMultiplier * yMax + yOffset) - yMax * (1 - _ResizeMultiplier); //////////////// _RightEye.SetWorldPositionFromGaze(_Camera, gp, _RightEye.transform.localPosition.z); _RightEye.transform.localScale = scaleVec * _EyeScaleInitSize; _RightEye.transform.localEulerAngles = new Vector3(_RightEye.transform.localEulerAngles.x, _RightEye.transform.localEulerAngles.y, (float)-angle); } } else { if (_RightEye.IsRendererEnabled()) { _RightEye.SetRendererEnabled(false); } } } } else { if (_LeftEye.IsRendererEnabled()) { _LeftEye.SetRendererEnabled(false); } if (_RightEye.IsRendererEnabled()) { _RightEye.SetRendererEnabled(false); } } }
public bool Equals(GazeToDisplayCoordinateMappingRecord other) { return(Gaze.Equals(other.Gaze) && HeadPose.Equals(other.HeadPose) && Face.Equals(other.Face) && Display.Equals(other.Display)); }
public bool Equals([AllowNull] Camera other) { if(other == null) return false; if(ReferenceEquals(this, other)) return true; return (Up == other.Up && Up != null && other.Up != null && Up.Equals(other.Up)) && (Center == other.Center && Center != null && other.Center != null && Center.Equals(other.Center)) && (Eye == other.Eye && Eye != null && other.Eye != null && Eye.Equals(other.Eye)) && (Projection == other.Projection && Projection != null && other.Projection != null && Projection.Equals(other.Projection)); }