protected override void LoadPreviousValues(params Selectable[] uiElements) { bool prevUseCalibratedCamera = PlayerPrefs.GetInt("ProjectorCalibrationPanel-useCalibratedCamera", default) == 1; useCalibratedCamera = prevUseCalibratedCamera; (uiElements[0] as Toggle).isOn = prevUseCalibratedCamera; onUseCalibratedCamera?.Invoke(prevUseCalibratedCamera); var prevLensDistortionMode = (EDanbiLensUndistortMode)PlayerPrefs.GetInt("ProjectorCalibrationPanel-lensDistortionMode", -1); lensUndistortMode = prevLensDistortionMode; (uiElements[1] as Dropdown).value = (int)prevLensDistortionMode; onLensDistortModeChange?.Invoke(lensUndistortMode); // var prevNewtonThreshold = PlayerPrefs.GetFloat("ProjectorCalibrationPanel-newtonThreshold", default); // newtonThreshold = prevNewtonThreshold; // (uiElements[2] as InputField).text = prevNewtonThreshold.ToString(); // var prevIterativeThreshold = PlayerPrefs.GetFloat("ProjectorCalibrationPanel-iterativeThreshold", default); // iterativeThreshold = prevIterativeThreshold; // (uiElements[3] as InputField).text = prevIterativeThreshold.ToString(); // var prevIterativeSafetyCounter = PlayerPrefs.GetFloat("ProjectorCalibrationPanel-iterativeSafetyCounter", default); // iterativeSafetyCounter = prevIterativeSafetyCounter; // (uiElements[4] as InputField).text = prevIterativeSafetyCounter.ToString(); }
protected override void AddListenerForPanelFields() { base.AddListenerForPanelFields(); var panel = Panel.transform; Dropdown lensUndistortionModeDropdown = default; // GameObject newtonProperties = default; // GameObject iterativeProperties = default; // InputField newtonThresholdInputField = default; // InputField iterativeThresholdInputField = default; // InputField iterativeSafetyCounterInputField = default; // 1. bind the "Calibrated Camera" toggle. var useCalibratedCameraToggle = panel.GetChild(0).GetComponent <Toggle>(); useCalibratedCameraToggle.onValueChanged.AddListener( (bool isOn) => { onUseCalibratedCamera?.Invoke(isOn); useCalibratedCamera = isOn; lensUndistortionModeDropdown.interactable = isOn; onUseCalibratedCamera?.Invoke(useCalibratedCamera); } ); // bind the undistortion Method dropdown. lensUndistortionModeDropdown = panel.GetChild(1).GetComponent <Dropdown>(); lensUndistortionModeDropdown.AddOptions(new List <string> { "no undistort", "direct" }); // , "iterative", "newton" lensUndistortionModeDropdown.onValueChanged.AddListener( (int option) => { switch (option) { case 0: // no undistort lensUndistortMode = EDanbiLensUndistortMode.NotUsing; //newtonProperties.SetActive(false); //iterativeProperties.SetActive(false); break; case 1: // direct lensUndistortMode = EDanbiLensUndistortMode.Direct; //newtonProperties.SetActive(false); //iterativeProperties.SetActive(false); break; // case 2: // iterative // lensUndistortMode = EDanbiLensUndistortMode.Iterative; // newtonProperties.SetActive(false); // iterativeProperties.SetActive(true); // break; // case 3: // newton // lensUndistortMode = EDanbiLensUndistortMode.Newton; // newtonProperties.SetActive(true); // iterativeProperties.SetActive(false); // break; } onLensDistortModeChange?.Invoke(lensUndistortMode); } ); // // bind the newton properties and turn it off. // newtonProperties = panel.GetChild(2).gameObject; // // bind the newton threshold. // newtonThresholdInputField = newtonProperties.transform.GetChild(0).GetComponent<InputField>(); // newtonThresholdInputField.onValueChanged.AddListener( // (string val) => // { // if (float.TryParse(val, out var asFloat)) // { // newtonThreshold = asFloat; // DanbiUISync.onPanelUpdate?.Invoke(this); // } // } // ); // // newtonThresholdInputField.gameObject.SetActive(false); // newtonProperties.SetActive(false); // // bind the iterative properties and turn it off. // iterativeProperties = panel.GetChild(3).gameObject; // // bind the iterative threshold. // iterativeThresholdInputField = iterativeProperties.transform.GetChild(0).GetComponent<InputField>(); // iterativeThresholdInputField.onValueChanged.AddListener( // (string val) => // { // if (float.TryParse(val, out var asFloat)) // { // iterativeThreshold = asFloat; // DanbiUISync.onPanelUpdate?.Invoke(this); // } // } // ); // // bind the iterative safety counter. // iterativeSafetyCounterInputField = iterativeProperties.transform.GetChild(1).GetComponent<InputField>(); // iterativeSafetyCounterInputField.onValueChanged.AddListener( // (string val) => // { // if (float.TryParse(val, out var asFloat)) // { // iterativeSafetyCounter = asFloat; // DanbiUISync.onPanelUpdate?.Invoke(this); // } // } // ); // iterativeProperties.SetActive(false); // lensUndistortionModeDropdown.value = 0; LoadPreviousValues(useCalibratedCameraToggle, lensUndistortionModeDropdown); // , newtonThresholdInputField, iterativeThresholdInputField, iterativeSafetyCounterInputField }
void Awake() { #region bind calibration delegates DanbiUIProjectorCalibratedPanel.onUseCalibratedCamera += (bool use) => { m_useCalibratedProjector = use; SetRenderingCameraTransformation(); }; DanbiUIProjectorCalibratedPanel.onLensDistortModeChange += (EDanbiLensUndistortMode mode) => m_lensUndistortMode = mode; #endregion bind calibration delegates #region bind projector info delegates DanbiUIProjectorInfoPanel.onFovUpdate += (float fov) => { m_fov = fov; Camera.main.fieldOfView = m_fov; }; DanbiUIProjectorInfoPanel.onProjectorHeightUpdate += (float projectorHeight) => { m_projectorHeight = projectorHeight; }; #endregion bind projector info delegates #region bind internal parameters delegates DanbiUIProjectorInternalParametersPanel.onRadialCoefficientXUpdate += (float x) => { m_cameraInternalData.radialCoefficient.x = x; // set main camera by calibrate camera usage. PrepareInternalParametersToMatrix(); }; DanbiUIProjectorInternalParametersPanel.onRadialCoefficientYUpdate += (float y) => { m_cameraInternalData.radialCoefficient.y = y; // set main camera by calibrate camera usage. PrepareInternalParametersToMatrix(); }; DanbiUIProjectorInternalParametersPanel.onRadialCoefficientZUpdate += (float z) => { m_cameraInternalData.radialCoefficient.z = z; // set main camera by calibrate camera usage. PrepareInternalParametersToMatrix(); }; DanbiUIProjectorInternalParametersPanel.onTangentialCoefficientXUpdate += (float x) => { m_cameraInternalData.tangentialCoefficient.x = x; // set main camera by calibrate camera usage. PrepareInternalParametersToMatrix(); }; DanbiUIProjectorInternalParametersPanel.onTangentialCoefficientYUpdate += (float y) => { m_cameraInternalData.tangentialCoefficient.y = y; // set main camera by calibrate camera usage. PrepareInternalParametersToMatrix(); }; DanbiUIProjectorInternalParametersPanel.onPrincipalPointXUpdate += (float x) => { m_cameraInternalData.principalPoint.x = x; // set main camera by calibrate camera usage. PrepareInternalParametersToMatrix(); }; DanbiUIProjectorInternalParametersPanel.onPrincipalPointYUpdate += (float y) => { m_cameraInternalData.principalPoint.y = y; // set main camera by calibrate camera usage. PrepareInternalParametersToMatrix(); }; DanbiUIProjectorInternalParametersPanel.onFocalLengthXUpdate += (float x) => { m_cameraInternalData.focalLength.x = x; // set main camera by calibrate camera usage. PrepareInternalParametersToMatrix(); }; DanbiUIProjectorInternalParametersPanel.onFocalLengthYUpdate += (float y) => { m_cameraInternalData.focalLength.y = y; // set main camera by calibrate camera usage. PrepareInternalParametersToMatrix(); }; #endregion bind internal parameters delegates #region bind external parameters delegates DanbiUIProjectorExternalParametersPanel.onProjectorPositionXUpdate += (float x) => { m_cameraExternalData.projectorPosition.x = x; PrepareExternalParametersToMatrix(); }; DanbiUIProjectorExternalParametersPanel.onProjectorPositionYUpdate += (float y) => { m_cameraExternalData.projectorPosition.y = y; PrepareExternalParametersToMatrix(); }; DanbiUIProjectorExternalParametersPanel.onProjectorPositionZUpdate += (float z) => { m_cameraExternalData.projectorPosition.z = z; PrepareExternalParametersToMatrix(); }; DanbiUIProjectorExternalParametersPanel.onProjectorXAxisXUpdate += (float x) => { m_cameraExternalData.xAxis.x = x; PrepareExternalParametersToMatrix(); }; DanbiUIProjectorExternalParametersPanel.onProjectorXAxisYUpdate += (float y) => { m_cameraExternalData.xAxis.y = y; PrepareExternalParametersToMatrix(); }; DanbiUIProjectorExternalParametersPanel.onProjectorXAxisZUpdate += (float z) => { m_cameraExternalData.xAxis.z = z; PrepareExternalParametersToMatrix(); }; DanbiUIProjectorExternalParametersPanel.onProjectorYAxisXUpdate += (float x) => { m_cameraExternalData.yAxis.x = x; PrepareExternalParametersToMatrix(); }; DanbiUIProjectorExternalParametersPanel.onProjectorYAxisYUpdate += (float y) => { m_cameraExternalData.yAxis.y = y; PrepareExternalParametersToMatrix(); }; DanbiUIProjectorExternalParametersPanel.onProjectorYAxisZUpdate += (float z) => { m_cameraExternalData.yAxis.z = z; PrepareExternalParametersToMatrix(); }; DanbiUIProjectorExternalParametersPanel.onProjectorZAxisXUpdate += (float x) => { m_cameraExternalData.zAxis.x = x; PrepareExternalParametersToMatrix(); }; DanbiUIProjectorExternalParametersPanel.onProjectorZAxisYUpdate += (float y) => { m_cameraExternalData.zAxis.y = y; PrepareExternalParametersToMatrix(); }; DanbiUIProjectorExternalParametersPanel.onProjectorZAxisZUpdate += (float z) => { m_cameraExternalData.zAxis.z = z; PrepareExternalParametersToMatrix(); }; #endregion bind external parameters delegates }