private EyeXMask CreateMask(UnityEngine.Rect locationRect, int screenHeight) { var mask = new EyeXMask(maskType); int size = mask.Size; for (int row = 0; row < size; row++) { var y = screenHeight - (locationRect.yMin + (row + 0.5f) * locationRect.height / (size - 1)); for (int col = 0; col < size; col++) { var x = locationRect.xMin + (col + 0.5f) * locationRect.width / (size - 1); var ray = Camera.main.ScreenPointToRay(new Vector3(x, y, 0)); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo) && hitInfo.collider.gameObject.Equals(gameObject)) { mask[row, col] = MaskWeights.Default; } } } return(mask); }
private void UpdateInteractorLocation(EyeXInteractor interactor) { var location = GetProjectedRect(); EyeXMask mask = null; if (location.isValid && maskType != EyeXMaskType.None) { // Create a mask for the interactor and move it to the top. mask = CreateMask(location.rect, Screen.height); location.relativeZ = Camera.main.farClipPlane; } interactor.Location = location; interactor.Mask = mask; }
private EyeXMask CreateMask(UnityEngine.Rect locationRect, int screenHeight) { var mask = new EyeXMask(maskType); int size = mask.Size; for (int row = 0; row < size; row++) { var y = screenHeight - (locationRect.yMin + (row + 0.5f) * locationRect.height / (size - 1)); for (int col = 0; col < size; col++) { var x = locationRect.xMin + (col + 0.5f) * locationRect.width / (size - 1); var ray = Camera.main.ScreenPointToRay(new Vector3(x, y, 0)); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo) && hitInfo.collider.gameObject.Equals(gameObject)) { mask[row, col] = MaskWeights.Default; } } } return mask; }