private void DrawUnitOfMeasureField() { UnitOfMeasure temp = (UnitOfMeasure)EditorGUILayout.EnumPopup("Unit of Measure", _unitOfMeasure); if (temp != _unitOfMeasure) { if (temp == UnitOfMeasure.Imperial) { _focusDistance = ProCamsUtility.Convert(_focusDistance, Units.Meter, Units.Foot); } else { _focusDistance = ProCamsUtility.Convert(_focusDistance, Units.Foot, Units.Meter); } _unitOfMeasure = temp; } }
private void DrawUnitOfMeasureField() { UnitOfMeasure temp = (UnitOfMeasure)EditorGUILayout.EnumPopup("Unit of Measure", (UnitOfMeasure)_unitOfMeasure.enumValueIndex); if (temp != (UnitOfMeasure)_unitOfMeasure.enumValueIndex) { if (temp == UnitOfMeasure.Imperial) { _focusDistance.floatValue = ProCamsUtility.Convert(_focusDistance.floatValue, Units.Meter, Units.Foot); } else { _focusDistance.floatValue = ProCamsUtility.Convert(_focusDistance.floatValue, Units.Foot, Units.Meter); } _unitOfMeasure.enumValueIndex = (int)temp; } }
private void DrawDepthOfFieldField() { float dofTotal, dofNear, dofFar; dofTotal = _dofDistTotal.floatValue; dofNear = _dofNearLimit.floatValue; dofFar = _dofFarLimit.floatValue; if (((UnitOfMeasure)_unitOfMeasure.enumValueIndex == UnitOfMeasure.Imperial)) { float totalR, nearT, farT; totalR = Mathf.Floor((dofTotal - Mathf.Floor(dofTotal)) * 12); dofTotal = Mathf.Floor(dofTotal); nearT = Mathf.Floor((dofNear - Mathf.Floor(dofNear)) * 12); dofNear = Mathf.Floor(dofNear); farT = Mathf.Floor((dofFar - Mathf.Floor(dofFar)) * 12); dofFar = Mathf.Floor(dofFar); string dof = dofTotal >= 0 ? "" + dofTotal + "' " + totalR + "\"" : "INF"; EditorGUILayout.LabelField("Depth of Field", dof); EditorGUILayout.LabelField("Near Limit", "" + dofNear + "' " + nearT + "\""); string farLimit = dofFar >= 0 ? "" + dofFar + "' " + farT + "\"" : "INF"; EditorGUILayout.LabelField("Far Limit", farLimit); } else { float dof = ProCamsUtility.Convert(dofTotal, Units.Foot, Units.Meter); float dn = ProCamsUtility.Convert(dofNear, Units.Foot, Units.Meter); float df = ProCamsUtility.Convert(dofFar, Units.Foot, Units.Meter); string dofString = dofTotal >= 0 ? dof.ToString("0.00") + "m": "INF"; EditorGUILayout.LabelField("Depth of Field", dofString); EditorGUILayout.LabelField("Near Limit", dn.ToString("0.00") + "m"); string farLimit = dofFar >= 0 ? df.ToString("0.00") + "m" : "INF"; EditorGUILayout.LabelField("Far Limit", farLimit); } }
/// <summary> /// Updates the depth of field. /// Variables for dof change the original dof script. /// </summary> void UpdateDepthOfField() { CalculateDepthOfField(); _dofComponents = _nodalCamera.GetComponentsInChildren <CSDOFScatter>(); foreach (CSDOFScatter dofs in _dofComponents) { dofs.aperture = _lensFOVList[_lensIndex]._focalLength / FStop.list[_fstopIndex].fstop; if (_unitOfMeasure == UnitOfMeasure.Imperial) { dofs.focalLength = ProCamsUtility.Convert(_focusDist, Units.Foot, Units.Meter); } else { dofs.focalLength = _focusDist; } } }
/// <summary> /// Calculates the depth of field. /// </summary> private void CalculateDepthOfField() { float F = ProCamsUtility.Convert(_lensFOVList[_lensIndex]._focalLength, Units.Millimeter, Units.Inch); float f = FStop.list[_fstopIndex].fstop; float S; if (_unitOfMeasure == UnitOfMeasure.Imperial) { S = ProCamsUtility.Convert(_focusDist, Units.Foot, Units.Inch); } else { S = ProCamsUtility.Convert(_focusDist, Units.Meter, Units.Inch); } float H = (F * F) / (f * 0.001f); float DN = (H * S) / (H + (S - F)); float DF = (H * S) / (H - (S - F)); float D = DF - DN; D = ProCamsUtility.Convert(D, Units.Inch, Units.Foot); D = ProCamsUtility.Truncate(D, 2); DN = ProCamsUtility.Convert(DN, Units.Inch, Units.Foot); DN = ProCamsUtility.Truncate(DN, 2); DF = ProCamsUtility.Convert(DF, Units.Inch, Units.Foot); DF = ProCamsUtility.Truncate(DF, 2); _dofDistTotal = D; _dofNearLimit = DN; _dofFarLimit = DF; S = ProCamsUtility.Convert(S, Units.Inch, Units.Meter); }
private void DrawFocusTransformField() { _focusTransform.objectReferenceValue = EditorGUILayout.ObjectField( "Drag & Drop to Focus", _focusTransform.objectReferenceValue, typeof(Transform), true); if (_focusTransform.objectReferenceValue != null) { Transform t = _focusTransform.objectReferenceValue as Transform; float distanceValue = Vector3.Distance(cb.NodalCamera.transform.position, t.position); if (((UnitOfMeasure)_unitOfMeasure.enumValueIndex == UnitOfMeasure.Imperial)) { distanceValue = ProCamsUtility.Convert(distanceValue, Units.Meter, Units.Foot); } _focusDistance.floatValue = distanceValue; _focusTransform.objectReferenceValue = null; } }
/// <summary> /// Draws the depth of field field. /// </summary> private void DrawDepthOfFieldField() { float F, f, H, S, DN, DF, D, TI, NI, FI; //float focalLength = ProCamsDataTable.list[_lensKitIndex].lenses[_lensIndex].length; float focalLength = 0; ProCamsLensDataTable.FilmFormatData curFilmFormat = ProCamsLensDataTable.Instance.GetFilmFormat(_ffList[_currentFilmFormatIndex]); if (curFilmFormat != null) { ProCamsLensDataTable.FOVData fovData = curFilmFormat.GetFOVData(_lensKitIndex, _lensIndex); if (fovData != null) { focalLength = fovData._focalLength; } } F = ProCamsUtility.Convert( focalLength, Units.Millimeter, // from mm Units.Inch); // to inches f = FStop.list[_fstopIndex].fstop; H = (F * F) / (f * 0.001f); // 0.001 = Circle of Confusion if (_unitOfMeasure == UnitOfMeasure.Imperial) { S = ProCamsUtility.Convert(_focusDistance, Units.Foot, Units.Inch); } else { S = ProCamsUtility.Convert(_focusDistance, Units.Meter, Units.Inch); } DN = (H * S) / (H + (S - F)); // near depth of field DF = (H * S) / (H - (S - F)); // far depth of field D = DF - DN; // depth of field if (_unitOfMeasure == UnitOfMeasure.Imperial) { // rounding to two decimal places D = ProCamsUtility.Convert(D, Units.Inch, Units.Foot); // from inches to feet D = Mathf.Floor(D * 100) / 100f; DN = ProCamsUtility.Convert(DN, Units.Inch, Units.Foot); DN = Mathf.Floor(DN * 100) / 100f; DF = ProCamsUtility.Convert(DF, Units.Inch, Units.Foot); DF = Mathf.Floor(DF * 100) / 100f; TI = Mathf.Floor( ProCamsUtility.Convert( D - Mathf.Floor(D), Units.Foot, Units.Inch)); NI = Mathf.Floor( ProCamsUtility.Convert( DN - Mathf.Floor(DN), Units.Foot, Units.Inch)); FI = Mathf.Floor( ProCamsUtility.Convert( DF - Mathf.Floor(DF), Units.Foot, Units.Inch)); D = Mathf.Floor(D); DN = Mathf.Floor(DN); DF = Mathf.Floor(DF); if (D >= 0) { EditorGUILayout.LabelField("Depth of Field", "" + D + "' " + TI + "\""); } else { EditorGUILayout.LabelField("Depth of Field", "INF"); } EditorGUILayout.LabelField("Near Depth", "" + DN + "' " + NI + "\""); if (DF >= 0) { EditorGUILayout.LabelField("Far Depth", "" + DF + "' " + FI + "\""); } else { EditorGUILayout.LabelField("Far Depth", "INF"); } } else { float dof = ProCamsUtility.Convert(D, Units.Inch, Units.Meter); float dn = ProCamsUtility.Convert(DN, Units.Inch, Units.Meter); float df = ProCamsUtility.Convert(DF, Units.Inch, Units.Meter); if (D >= 0) { EditorGUILayout.LabelField("Depth of Field", dof.ToString("0.00") + "m"); } else { EditorGUILayout.LabelField("Depth of Field", "INF"); } EditorGUILayout.LabelField("Near Depth", dn.ToString("0.00") + "m"); if (DF >= 0) { EditorGUILayout.LabelField("Far Depth", df.ToString("0.00") + "m"); } else { EditorGUILayout.LabelField("Far Depth", "INF"); } } }