Beispiel #1
0
        /// <summary>
        /// On any camera being rendered to, add the camera to the list of cameras to which transfer data by way of a helper class.
        /// </summary>
        void OnRenderObject()
        {
            Camera currentCamera = Camera.current;

            if (_helperULRCameras == null)
            {
                _helperULRCameras = new List <Camera>();
            }
            if (!_helperULRCameras.Contains(currentCamera))
            {
                if (PMGlobalMeshEF.globalMesh != null)
                {
                    Helper_ULRCamera helperULRCamera = GeneralToolkit.GetOrAddComponent <Helper_ULRCamera>(currentCamera.gameObject);
                    int totalVertexCount             = PMGlobalMeshEF.globalMesh.vertexCount;
                    helperULRCamera.AddRenderedObject(this, totalVertexCount);
                    _helperULRCameras.Add(currentCamera);
                }
            }
            if (initialized)
            {
                // Update the buffers with the parameters of the source cameras.
                FillULRArrays();
                UpdateULRBuffers();
                // Update the blending material with the buffers.
                UpdateBlendingMaterialParameters(ref currentBlendingMaterial);
#if UNITY_EDITOR
                cameraSetup.SetColorIsIndices(ref currentBlendingMaterial);
#endif //UNITY_EDITOR
            }
        }
Beispiel #2
0
 /// <summary>
 /// Clears all created objects.
 /// </summary>
 public void ClearAll()
 {
     if (_sourceCamsWorldXYZBuffer != null)
     {
         _sourceCamsWorldXYZBuffer.Release();
     }
     if (_sourceCamsFieldsOfViewBuffer != null)
     {
         _sourceCamsFieldsOfViewBuffer.Release();
     }
     if (_sourceCamsDistanceRangesBuffer != null)
     {
         _sourceCamsDistanceRangesBuffer.Release();
     }
     if (_sourceCamsViewMatricesBuffer != null)
     {
         _sourceCamsViewMatricesBuffer.Release();
     }
     if (_helperULRCameras != null && _helperULRCameras.Count > 0)
     {
         for (int iter = 0; iter < _helperULRCameras.Count; iter++)
         {
             Camera currentCamera = _helperULRCameras[iter];
             if (currentCamera != null)
             {
                 Helper_ULRCamera helperULRCamera = currentCamera.GetComponent <Helper_ULRCamera>();
                 if (helperULRCamera != null)
                 {
                     DestroyImmediate(helperULRCamera);
                 }
             }
         }
         _helperULRCameras.Clear();
     }
 }