/// <summary> /// Fetches the global mesh and initializes the camera and materials. /// </summary> private void InitializePerCall() { // Deactivate any other renderer in the scene. _deactivatedRendererGOs = GeneralToolkit.DeactivateOtherActiveComponents <Renderer>(gameObject); // Create a preview camera manager and initialize it with the camera model's pose and parameters. _previewCameraModel = CameraModel.CreateCameraModel(); _previewCameraModel.transform.position = Vector3.zero; _previewCameraModel.transform.rotation = Quaternion.identity; _previewCameraModel.fieldOfView = 60f * Vector2.one; float focalLength = Camera.FieldOfViewToFocalLength(_previewCameraModel.fieldOfView.x, 1f); _previewCameraManager = new GameObject("Preview Camera Manager").AddComponent <PreviewCameraManager>(); Transform previewCameraTransform = new GameObject("Preview Camera").transform; GeneralToolkit.CreateRenderTexture(ref _previewCameraManager.targetTexture, Vector2Int.one, 0, RenderTextureFormat.ARGB32, false, FilterMode.Point, TextureWrapMode.Clamp); _previewCameraManager.CreatePreviewCamera(_previewCameraManager.gameObject, previewCameraTransform, _previewCameraModel); _previewCameraManager.previewCamera.clearFlags = CameraClearFlags.Color; _previewCameraManager.previewCamera.backgroundColor = Color.clear; // Create the materials. _renderToTextureMapMat = new Material(GeneralToolkit.shaderProcessingGlobalTextureMap); _renderToTextureMapMat.SetFloat(_shaderNameFocalLength, focalLength); _normalizeByAlphaMat = new Material(GeneralToolkit.shaderNormalizeByAlpha); // Initialize the helper object for ULR. _helperULR = gameObject.AddComponent <Rendering.Helper_ULR>(); _helperULR.Reset(); _helperULR.InitializeLinks(); _helperULR.blendCamCount = Rendering.Helper_ULR.maxBlendCamCount; _helperULR.numberOfSourceCameras = PMColorTextureArray.colorData.depth; _helperULR.CreateULRBuffersAndArrays(); _helperULR.InitializeBlendingMaterialParameters(ref _renderToTextureMapMat); _helperULR.currentBlendingMaterial = _renderToTextureMapMat; _helperULR.initialized = true; }
/// <summary> /// Resets the camera parameters and geometry processing parameters. /// </summary> void Reset() { // Reset the camera parameters. if (cameraModel == null) { cameraModel = CameraModel.CreateCameraModel(transform); } cameraModel.Reset(); // Reset the geometry processing parameters. _geometryProcessingMethod = GeneralToolkit.GetOrCreateChildComponent <COLIBRIVR.Processing.PerViewMeshesQSTR>(transform); _geometryProcessingMethod.Reset(); // Get the preview camera manager. _previewCameraManager = GeneralToolkit.GetOrCreateChildComponent <PreviewCameraManager>(transform); // Update the displayed preview. previewIndex = -1; Selected(); }
/// <summary> /// Resets the object's properties. /// </summary> void Reset() { // Reset the key child components. _cameraSetup = CameraSetup.CreateOrResetCameraSetup(transform); _dataHandler = DataHandler.CreateOrResetDataHandler(transform); _previewCameraManager = PreviewCameraManager.CreateOrResetPreviewCameraManager(transform); #if UNITY_EDITOR // Reset parameters to their default values. _cameraPrefab = null; _cameraCount = new Vector2Int(4, 4); _acquireDepthData = false; _copyGlobalMesh = false; _setupType = SetupType.Grid; _setupDirection = SetupDirection.Outwards; _lockSetup = false; // Update the acquisition camera poses to reflect the updated setup. ComputeAcquisitionCameraPoses(); // Create a preview camera from the prefab. CreatePreviewCameraFromPrefab(); #endif //UNITY_EDITOR }