private void CameraSetup(int index, string sourceName) { Camera sourceCam = JUtil.GetCameraByName(sourceName); if (sourceCam != null) { var cameraBody = new GameObject(); cameraBody.name = typeof(RasterPropMonitor).Name + index + cameraBody.GetInstanceID(); cameraObject[index] = cameraBody.AddComponent <Camera>(); // Just in case to support JSITransparentPod. cameraObject[index].cullingMask &= ~(1 << 16 | 1 << 20); cameraObject[index].CopyFrom(sourceCam); cameraObject[index].enabled = false; cameraObject[index].aspect = cameraAspect; // Minor hack to bring the near clip plane for the "up close" // cameras drastically closer to where the cameras notionally // are. Experimentally, these two cameras have N/F of 0.4 / 300.0, // or 750:1 Far/Near ratio. Changing this to 8192:1 brings the // near plane to 37cm or so, which hopefully is close enough to // see nearby details without creating z-fighting artifacts. if (!skipFarCamera && (index == 5 || index == 6)) { cameraObject[index].nearClipPlane = cameraObject[index].farClipPlane / 8192.0f; } } }
/* Correction. You can actually do this, so this method is unnecessary. * So much the better. * * // Since apparently, current versions of ModuleManager do not allow multiple * // "HAS" directives, the easier course of action to only apply this module to * // pods that are not transparent is to apply it to every pod, * // and then make it self-destruct if the pod is in fact transparent. * public override void OnStart(StartState state) * { * if (state != StartState.Editor) { * foreach (PartModule thatModule in part.Modules) { * if (thatModule is JSITransparentPod) { * Destroy(this); * } * } * } * } * */ // During Startup we need to reset the var JUtil.cameraMaskShowsIVA, as sometimes it gets out of sync with the actual Camera Mask. // JUtil.cameraMaskShowsIVA is used in the following two methods to correctly draw non Transparent pods. // So this will check the culling mask of 'Camera 00' and reset that var once at OnStart. public override void OnStart(StartState state) { if (state != StartState.Editor) { Camera sourceCam = JUtil.GetCameraByName("Camera 00"); if (sourceCam != null) { JUtil.cameraMaskShowsIVA = ((sourceCam.cullingMask & (1 << 16)) != 0) && ((sourceCam.cullingMask & (1 << 20)) != 0); } } }
private void CameraSetup(int index, string sourceName) { Camera sourceCam = JUtil.GetCameraByName(sourceName); if (sourceCam != null) { var cameraBody = new GameObject(); cameraBody.name = typeof(RasterPropMonitor).Name + index + cameraBody.GetInstanceID(); cameraObject[index] = cameraBody.AddComponent <Camera>(); // Just in case to support JSITransparentPod. cameraObject[index].cullingMask &= ~(1 << 16 | 1 << 20); cameraObject[index].CopyFrom(sourceCam); cameraObject[index].enabled = false; cameraObject[index].targetTexture = screenTexture; cameraObject[index].aspect = cameraAspect; } }
public static void SetCameraCullingMaskForIVA(string cameraName, bool flag) { Camera thatCamera = JUtil.GetCameraByName(cameraName); if (thatCamera != null) { if (flag) { thatCamera.cullingMask |= 1 << 16 | 1 << 20; } else { thatCamera.cullingMask &= ~(1 << 16 | 1 << 20); } } else { Debug.Log("Could not find camera \"" + cameraName + "\" to change it's culling mask, check your code."); } }