private QSBTool GetToolByType(ToolType type) { if (CameraBody == null) { DebugLog.ToConsole($"Warning - Tried to GetToolByType({type}) on player {PlayerId}, but CameraBody was null.", MessageType.Warning); return(null); } var tools = CameraBody.GetComponentsInChildren <QSBTool>(); if (tools == null || tools.Length == 0) { DebugLog.ToConsole($"Warning - Couldn't find any QSBTools for player {PlayerId}.", MessageType.Warning); return(null); } var tool = tools.FirstOrDefault(x => x.Type == type); if (tool == null) { DebugLog.ToConsole($"Warning - No tool found on player {PlayerId} matching ToolType {type}.", MessageType.Warning); } return(tool); }
public override bool Init() { //get camera GameObject camera; if (!getActorByName(cameraName, out camera)) { Debug.LogError("actor name [" + cameraName + "] not found. cannot change focus"); return(false); } cameraBody = camera.GetComponent <CameraBody>() as CameraBody; //try to parse target as a coordinate Vector3 focusPosition; if (targetName.TryParseVector3(out focusPosition)) { Extensions.Log("focus @" + focusPosition); return(true); } //try to find the target as an actor if (target == null && !getActorByName(targetName, out target)) { Extensions.Log("actor name [" + targetName + "] not found. cannot change focus"); return(false); } Extensions.Log("focus target[{0}] @{1} tracking[{2}]", targetName, target.transform.position, tracking); return(true); }
// Start is called before the first frame update void Start() { doVignette = false; Vignette.SetActive(false); Camera.SetActive(true); meshRenderers = CameraBody.GetComponentsInChildren <MeshRenderer>(); }
void OnEnable() { _unitOfMeasure = serializedObject.FindProperty("_unitOfMeasure"); _rigTransform = serializedObject.FindProperty("_rigTransform"); _description = serializedObject.FindProperty("_cameraDesc"); _lensKitName = serializedObject.FindProperty("_lensKitName"); _lensKitIndex = serializedObject.FindProperty("_lensKitIndex"); _lensIndex = serializedObject.FindProperty("_lensIndex"); _fstopIndex = serializedObject.FindProperty("_fstopIndex"); _focusDistance = serializedObject.FindProperty("_focusDist"); _dofDistTotal = serializedObject.FindProperty("_dofDistTotal"); _dofNearLimit = serializedObject.FindProperty("_dofNearLimit"); _dofFarLimit = serializedObject.FindProperty("_dofFarLimit"); _focusTransform = serializedObject.FindProperty("_focusTransform"); _clickToFocus = serializedObject.FindProperty("_clickToFocus"); _centerOnSubject = serializedObject.FindProperty("_centerOnSubject"); _fpOffset = serializedObject.FindProperty("_fpOffset"); _showGizmos = serializedObject.FindProperty("_showGizmos"); _filmFormatName = serializedObject.FindProperty("_filmFormatName"); _screenSizeName = serializedObject.FindProperty("_screenSizeName"); cb = target as CameraBody; // Populate film formats List <ProCamsLensDataTable.FilmFormatData> .Enumerator filmFormatList = ProCamsLensDataTable.Instance.FilmFormatDataEmumerator; _ffList = new string[ProCamsLensDataTable.Instance.NumFilmFormats]; int i = 0; while (filmFormatList.MoveNext()) { ProCamsLensDataTable.FilmFormatData formatData = filmFormatList.Current; _ffList[i] = formatData._formatName; if (_filmFormatName.stringValue == formatData._formatName) { _currentFilmFormatIndex = i; } ++i; } PopulateLens(); // Populate FStop options _fstopOptions = new string[FStop.list.Length]; int num = FStop.list.Length; for (i = 0; i < num; ++i) { _fstopOptions[i] = FStop.list[i].name; } if (UnityEditorInternal.InternalEditorUtility.HasPro()) { CameraBody.CameraPreview = new RenderTexture( PlayerSettings.defaultScreenWidth, PlayerSettings.defaultScreenHeight, (int)RenderTextureFormat.ARGB32); } }
void OnEnable () { _unitOfMeasure = serializedObject.FindProperty("_unitOfMeasure"); _rigTransform = serializedObject.FindProperty("_rigTransform"); _description = serializedObject.FindProperty("_cameraDesc"); _lensKitName = serializedObject.FindProperty("_lensKitName"); _lensKitIndex = serializedObject.FindProperty("_lensKitIndex"); _lensIndex = serializedObject.FindProperty("_lensIndex"); _fstopIndex = serializedObject.FindProperty("_fstopIndex"); _focusDistance = serializedObject.FindProperty("_focusDist"); _dofDistTotal = serializedObject.FindProperty("_dofDistTotal"); _dofNearLimit = serializedObject.FindProperty("_dofNearLimit"); _dofFarLimit = serializedObject.FindProperty("_dofFarLimit"); _focusTransform = serializedObject.FindProperty("_focusTransform"); _clickToFocus = serializedObject.FindProperty("_clickToFocus"); _centerOnSubject = serializedObject.FindProperty("_centerOnSubject"); _fpOffset = serializedObject.FindProperty("_fpOffset"); _showGizmos = serializedObject.FindProperty("_showGizmos"); _filmFormatName = serializedObject.FindProperty("_filmFormatName"); _screenSizeName = serializedObject.FindProperty("_screenSizeName"); cb = target as CameraBody; // Populate film formats List<ProCamsLensDataTable.FilmFormatData>.Enumerator filmFormatList = ProCamsLensDataTable.Instance.FilmFormatDataEmumerator; _ffList = new string[ProCamsLensDataTable.Instance.NumFilmFormats]; int i = 0; while(filmFormatList.MoveNext()) { ProCamsLensDataTable.FilmFormatData formatData = filmFormatList.Current; _ffList[i] = formatData._formatName; if (_filmFormatName.stringValue == formatData._formatName) { _currentFilmFormatIndex = i; } ++i; } PopulateLens(); // Populate FStop options _fstopOptions = new string[FStop.list.Length]; int num = FStop.list.Length; for(i = 0; i < num; ++i) { _fstopOptions[i] = FStop.list[i].name; } if (UnityEditorInternal.InternalEditorUtility.HasPro()) { CameraBody.CameraPreview = new RenderTexture( PlayerSettings.defaultScreenWidth, PlayerSettings.defaultScreenHeight, (int)RenderTextureFormat.ARGB32 ); } }
private bool findCamera() { if (camera == null && !getActorByName(cameraName, out camera)) { Debug.LogError(string.Format("could not find camera[{0}] at time d:s[{1}:{2}]. This is really bad. What did you do to the camera?", cameraName, ElPresidente.Instance.CurrentDiscourseTime, ElPresidente.Instance.CurrentStoryTime)); return(false); } cameraBody = camera.GetComponentInChildren <CameraBody>(); if (cameraBody == null) { Debug.LogError(string.Format("could not find cameraBody component as child of camera[{0}] at time d:s[{1}:{2}]. Why isn't your camera a cinema suites camera?", cameraName, ElPresidente.Instance.CurrentDiscourseTime, ElPresidente.Instance.CurrentStoryTime)); return(false); } return(true); }
void Create() { if (_cb == null) { if (sname.Length <= 0) { sname = "3D Camera"; } GameObject go = new GameObject(sname, typeof(CameraBody)); _cb = go.GetComponent <CameraBody>(); Undo.RegisterCreatedObjectUndo(go, "Created Camera"); } _cb.CameraDescription = sname; Stereo3D s3d = _cb.gameObject.AddComponent <Stereo3D>(); s3d.SelectedRig = _selectedRig; s3d.Interaxial = _interaxial; s3d.Convergence = _convergence; s3d.State = _sstate; Camera cam = _cb.NodalCamera; cam.nearClipPlane = 0.01f; cam.gameObject.AddComponent <Stereo3DRenderer>(); SceneView sv = SceneView.lastActiveSceneView; if (sv == null) { sv = SceneView.sceneViews[0] as SceneView; } sv.Focus(); Camera c = SceneView.GetAllSceneCameras()[0]; _cb.transform.rotation = Quaternion.LookRotation(c.transform.forward); _cb.transform.position = c.transform.position; }
void Awake () { bool lc = false, rc = false, to = false; _cameraBody = GetComponent<CameraBody>(); foreach (Transform t in _cameraBody.NodalCamera.transform) { if (!lc) { if (lc = t.name == "left_cam") _leftCam = t.gameObject; } if (!rc) { if (rc = t.name == "right_cam") _rightCam = t.gameObject; } if (!to) { if (to = t.name == "track") _trackObject = t.gameObject; } } if (!lc) _leftCam = new GameObject ("left_cam", typeof(Camera), typeof(CSDOFScatter)); if (!rc) _rightCam = new GameObject ("right_cam", typeof(Camera), typeof(CSDOFScatter)); if (!to) _trackObject = new GameObject ("track"); _leftCam.transform.parent = _cameraBody.NodalCamera.transform; _rightCam.transform.parent = _cameraBody.NodalCamera.transform; _trackObject.transform.parent = _cameraBody.NodalCamera.transform; _leftCam.transform.position = Vector3.zero; _rightCam.transform.position = Vector3.zero; if (_leftCamRT != null) _leftCamRT.Release(); if (_rightCamRT != null) _rightCamRT.Release(); _leftCamRT = new RenderTexture(Screen.width, Screen.height, 24); _rightCamRT = new RenderTexture(Screen.width, Screen.height, 24); }
public void InitializeMiniMap(List <string> actors) { unmarkedActors = actors; miniMapLayerId = LayerMask.NameToLayer("MiniMap"); terrainLayerId = LayerMask.NameToLayer("Terrain"); cameraFrustumLayerId = LayerMask.NameToLayer("CameraFrustum"); GameObject proCam; if (!ElPresidente.createdGameObjects.TryGet("Pro Cam", out proCam)) { Debug.LogError("Pro Cam not found for minimap render"); } else { mainCameraBody = proCam.GetComponent <CameraBody>(); } createMiniMapArtifacts(); miniMapCamera = initializeCamera(); }
/// <summary> /// Create the camera body script. /// </summary> /// <param name='go'> /// CameraBody GameObject. The root node GameObject. /// </param> private CameraBody SetupCameraBodyScript(GameObject go) { CameraBody cb = go.GetComponent <CameraBody>(); ProCamsLensDataTable.FilmFormatData curFilmFormat = ProCamsLensDataTable.Instance.GetFilmFormat(_ffList[_currentFilmFormatIndex]); cb.FilmFormatName = curFilmFormat._formatName; if (curFilmFormat != null) { cb.ScreenSizeName = ProCamsLensDataTable.Instance.GetScreenSize(curFilmFormat, _resolutionList[_currentScreenSizeIndex]).name; ProCamsLensDataTable.LensKitData lensKitData = curFilmFormat.GetLensKitData(_lensKitIndex); if (lensKitData != null) { cb.LensKitName = lensKitData._lensKit; cb.IndexOfLensKit = _lensKitIndex; cb.LensFOVList = lensKitData._fovDataset.ToArray(); cb.IndexOfLens = _lensIndex; } } cb.UnitOfMeasure = _unitOfMeasure; // Depth of field cb.IndexOfFStop = _fstopIndex; cb.FocusDistance = _focusDistance; // Camera Description cb.CameraSpecs = ", " + cb.LensKitName; cb.CameraSpecs = cb.CameraSpecs.Replace("/", ""); // Camera Name cb.CameraDescription = _cameraName; go.name = cb.CameraDescription;// +cb.CameraSpecs; // Rig cb.RigTransform = _rigTransform; return(cb); }
void Create() { if (_cb == null) { if (sname.Length <= 0) sname = "3D Camera"; GameObject go = new GameObject(sname, typeof(CameraBody)); _cb = go.GetComponent<CameraBody>(); Undo.RegisterCreatedObjectUndo(go, "Created Camera"); } _cb.CameraDescription = sname; Stereo3D s3d = _cb.gameObject.AddComponent<Stereo3D>(); s3d.SelectedRig = _selectedRig; s3d.Interaxial = _interaxial; s3d.Convergence = _convergence; s3d.State = _sstate; Camera cam = _cb.NodalCamera; cam.nearClipPlane = 0.01f; cam.gameObject.AddComponent<Stereo3DRenderer>(); SceneView sv = SceneView.lastActiveSceneView; if (sv == null) sv = SceneView.sceneViews[0] as SceneView; sv.Focus(); Camera c = SceneView.GetAllSceneCameras()[0]; _cb.transform.rotation = Quaternion.LookRotation(c.transform.forward); _cb.transform.position = c.transform.position; }
/// <summary> /// Draws the camera preview. /// </summary> /// <param name='updatePreview'> /// Update preview. /// </param> private void DrawCameraPreview(bool updatePreview) { if (updatePreview && UnityEditorInternal.InternalEditorUtility.HasPro()) { _javelinCamera = CreateCameraBody(); if (_javelinCamera == null) { DestroyCameraBody(); return; } CameraBody cb = SetupCameraBodyScript(_javelinCamera); Camera cbNodalCamera = cb.NodalCamera; cb.CallUpdate(); int dsWidth = PlayerSettings.defaultScreenWidth; int dsHeight = PlayerSettings.defaultScreenHeight; if (_rt == null || (_rt.width != dsWidth || _rt.height != dsHeight)) { _rt = new RenderTexture( dsWidth, dsHeight, (int)RenderTextureFormat.ARGB32); } CameraClearFlags ccf = cbNodalCamera.clearFlags; cbNodalCamera.targetTexture = _rt; cbNodalCamera.clearFlags = CameraClearFlags.Skybox; cbNodalCamera.Render(); cbNodalCamera.clearFlags = ccf; cbNodalCamera.targetTexture = null; EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); Rect scale = GUILayoutUtility.GetLastRect(); //EditorGUIUtility.LookLikeInspector(); //EditorGUIUtility.LookLikeControls(scale.width/2); // Every other draw will detect the width as 1 // This will reset scale.width to the previous value that was not 1 if (scale.width == 1 && _lastScale != 1) { scale.width = _lastScale; } if (scale.width != 1) { _lastScale = scale.width; } // Padding around the window float max_width = scale.width - 30f; float scale_factor = max_width / dsWidth; EditorGUILayout.BeginHorizontal(); GUILayout.Height(100); int width = (int)(dsWidth * scale_factor); int height = (int)(dsHeight * scale_factor); Rect rect = new Rect(scale.x + 15f, scale.y + 10f, width, height); GUI.DrawTexture(rect, _rt, ScaleMode.ScaleAndCrop, false); EditorGUILayout.EndHorizontal(); GUILayout.Space(height + 19f); DestroyCameraBody(); } else { return; } }
void DrawCBField () { _cb = (CameraBody)EditorGUILayout.ObjectField("Camera Body", _cb, typeof(CameraBody),true); }
void Awake() { bool lc = false, rc = false, to = false; _cameraBody = GetComponent <CameraBody>(); foreach (Transform t in _cameraBody.NodalCamera.transform) { if (!lc) { if (lc = t.name == "left_cam") { _leftCam = t.gameObject; } } if (!rc) { if (rc = t.name == "right_cam") { _rightCam = t.gameObject; } } if (!to) { if (to = t.name == "track") { _trackObject = t.gameObject; } } } if (!lc) { _leftCam = new GameObject("left_cam", typeof(Camera), typeof(CSDOFScatter)); } if (!rc) { _rightCam = new GameObject("right_cam", typeof(Camera), typeof(CSDOFScatter)); } if (!to) { _trackObject = new GameObject("track"); } _leftCam.transform.parent = _cameraBody.NodalCamera.transform; _rightCam.transform.parent = _cameraBody.NodalCamera.transform; _trackObject.transform.parent = _cameraBody.NodalCamera.transform; _leftCam.transform.position = Vector3.zero; _rightCam.transform.position = Vector3.zero; if (_leftCamRT != null) { _leftCamRT.Release(); } if (_rightCamRT != null) { _rightCamRT.Release(); } _leftCamRT = new RenderTexture(Screen.width, Screen.height, 24); _rightCamRT = new RenderTexture(Screen.width, Screen.height, 24); }
void Awake() { _cb = GetComponent <CameraBody>() as CameraBody; }
void DrawCBField() { _cb = (CameraBody)EditorGUILayout.ObjectField("Camera Body", _cb, typeof(CameraBody), true); }
void Awake() { _cb = GetComponent<CameraBody>() as CameraBody; }
private QSBTool GetToolByType(ToolType type) { return(CameraBody?.GetComponentsInChildren <QSBTool>() .FirstOrDefault(x => x.Type == type)); }
static void DrawFieldOfViewMarkers(Transform transform, GizmoType gizmoType) { CameraBody cb = transform.GetComponent <CameraBody>(); ProCamsLensDataTable.FilmFormatData curFilmFormat = null; if (cb != null) { curFilmFormat = ProCamsLensDataTable.Instance.GetFilmFormat(cb.FilmFormatName); } if (curFilmFormat != null && cb != null && cb.ShowGizmos && cb.LensFOVList[cb.IndexOfLens] != null) { float aspect = curFilmFormat._aspect; GUIStyle style = new GUIStyle(); style.normal.textColor = new Color(0, 60, 160, 255); float nearInches = Mathf.Floor((cb.DOFNearLimit - Mathf.Floor(cb.DOFNearLimit)) * 12); float nearFeet = Mathf.Floor(cb.DOFNearLimit); Transform ct = cb.NodalCamera.transform; Matrix4x4 oldMatrix = Handles.matrix; Handles.matrix = Matrix4x4.TRS(ct.position, ct.rotation, ct.lossyScale); if (cb.UnitOfMeasure == UnitOfMeasure.Imperial) { Vector3 dofNearPos = Vector3.forward * cb.DOFNearLimit * 0.3048f + Vector3.left * ((cb.DOFNearLimit * aspect) / cb.LensFOVList[cb.IndexOfLens]._focalLength); Vector3 dofFarPos = Vector3.forward * cb.DOFFarLimit * 0.3048f + Vector3.left * ((cb.DOFFarLimit * aspect) / cb.LensFOVList[cb.IndexOfLens]._focalLength); Vector3 dofFocusPos = Vector3.forward * cb.FocusDistance * 0.3048f; Handles.Label(dofNearPos, "" + nearFeet + "' " + nearInches + "\"", style); float farInches = Mathf.Floor((cb.DOFFarLimit - Mathf.Floor(cb.DOFFarLimit)) * 12); float farFeet = Mathf.Floor(cb.DOFFarLimit); if (cb.DOFFarLimit >= 0) { Handles.Label(dofFarPos, "" + farFeet + "' " + farInches + "\"", style); } style.normal.textColor = Color.yellow; float dofInches = Mathf.Floor((cb.FocusDistance - Mathf.Floor(cb.FocusDistance)) * 12); float dofFeet = Mathf.Floor(cb.FocusDistance); Handles.Label(dofFocusPos, "" + dofFeet + "' " + dofInches + "\"", style); } else { Vector3 dofNearPos = Vector3.forward * cb.DOFNearLimit * 0.3048f + Vector3.left * ((cb.DOFNearLimit * aspect) / cb.LensFOVList[cb.IndexOfLens]._focalLength); Vector3 dofFarPos = Vector3.forward * cb.DOFFarLimit * 0.3048f + Vector3.left * ((cb.DOFFarLimit * aspect) / cb.LensFOVList[cb.IndexOfLens]._focalLength); Vector3 dofFocusPos = Vector3.forward * cb.FocusDistance; Handles.Label(dofNearPos, (cb.DOFNearLimit * 0.3048f).ToString("0.00") + "m", style); //float farInches = Mathf.Floor((cb.DOFFarLimit - Mathf.Floor(cb.DOFFarLimit)) * 12); //float farFeet = Mathf.Floor(cb.DOFFarLimit); if (cb.DOFFarLimit >= 0) { Handles.Label(dofFarPos, (cb.DOFFarLimit * 0.3048f).ToString("0.00") + "m", style); } style.normal.textColor = Color.yellow; Handles.Label(dofFocusPos, cb.FocusDistance.ToString("0.00") + "m", style); } Handles.matrix = oldMatrix; } }