override internal void Initialize()
        {
            _mainModule     = _waterfallObject.MainModule;
            _meshModule     = _waterfallObject.MeshModule;
            _materialModule = _waterfallObject.MaterialModule;

            _visibleArea            = new WaterRenderingVisibleArea(_mainModule);
            _renderingCameraFrustum = new WaterRenderingCameraFrustum(_mainModule);

            if (_clipeePoints == null)
            {
                _clipeePoints = new SimpleFixedSizeList <Vector2>(8);
            }

            base.Initialize();
        }
Exemple #2
0
        internal void UpdateArea(SimpleFixedSizeList <Vector2> points, WaterRenderingCameraFrustum cameraFrustum, bool isFullyContainedInWaterBox, bool computePixelSize, float zFar, bool renderRefraction = true, bool renderReflection = false, float reflectionZOffset = 0f, float reflectionAxis = 0f, float reflectionFrustumHeightScalingFactor = 1f)
        {
            IsValid = true;

            var currentCamera = cameraFrustum.CurrentCamera;

            if (isFullyContainedInWaterBox && currentCamera.orthographic && !cameraFrustum.IsIsometric)
            {
                MatchToCurrentCameraOrthographicViewingFrustum(cameraFrustum, computePixelSize, zFar, renderRefraction, renderReflection, reflectionAxis, reflectionZOffset, reflectionFrustumHeightScalingFactor);
                return;
            }

            IsValid = points.Count > 0;
            if (!IsValid)
            {
                return;
            }

            // Compute the AABB of provided points (in water-local space)
            Vector2 boundingBoxMin = points[0];
            Vector2 boundingBoxMax = points[0];

            for (int i = 1, imax = points.Count; i < imax; i++)
            {
                Vector2 point = points[i];

                if (point.x < boundingBoxMin.x)
                {
                    boundingBoxMin.x = point.x;
                }

                if (point.x > boundingBoxMax.x)
                {
                    boundingBoxMax.x = point.x;
                }

                if (point.y < boundingBoxMin.y)
                {
                    boundingBoxMin.y = point.y;
                }

                if (point.y > boundingBoxMax.y)
                {
                    boundingBoxMax.y = point.y;
                }
            }

            if (currentCamera.orthographic)
            {
                if (cameraFrustum.IsIsometric)
                {
                    ComputeIsometricViewingFrustum(cameraFrustum, computePixelSize, boundingBoxMin, boundingBoxMax, zFar, renderRefraction, renderReflection, reflectionAxis, reflectionZOffset, reflectionFrustumHeightScalingFactor);
                }
                else
                {
                    ComputeOrthographicViewingFrustum(cameraFrustum, computePixelSize, boundingBoxMin, boundingBoxMax, zFar, renderRefraction, renderReflection, reflectionAxis, reflectionZOffset, reflectionFrustumHeightScalingFactor);
                }

                return;
            }

            ComputePerspectiveViewingFrustum(cameraFrustum, computePixelSize, boundingBoxMin, boundingBoxMax, zFar, renderRefraction, renderReflection, reflectionAxis, reflectionZOffset, reflectionFrustumHeightScalingFactor, isFullyContainedInWaterBox);
        }