示例#1
0
 private void UpdateOverlays()
 {
     for (int i = 0; i < this.m_overlays.Count; i++)
     {
         WaveOverlay waveOverlay   = this.m_overlays[i];
         float       normalizedAge = waveOverlay.NormalizedAge;
         waveOverlay.FoamTex.alpha       = this.timeLine.Evaluate(normalizedAge) * this.alpha;
         waveOverlay.FoamTex.textureFoam = this.textureFoam;
         waveOverlay.UpdateOverlay();
     }
 }
示例#2
0
 /// <summary>
 /// Need to update the overlays each frame.
 /// </summary>
 void UpdateOverlays()
 {
     for (int i = 0; i < m_overlays.Count; i++)
     {
         WaveOverlay overlay = m_overlays[i];
         //Set the alpha based on the its age and curve
         float a = overlay.NormalizedAge;
         overlay.FoamTex.alpha       = timeLine.Evaluate(a) * alpha;
         overlay.FoamTex.textureFoam = textureFoam;
         //Updates the overlays position, rotation, expansion and its bounding box.
         overlay.UpdateOverlay();
     }
 }
        /// <summary>
        /// Need to update the overlays each frame.
        /// </summary>
        void UpdateOverlays()
        {
            float xmin = float.PositiveInfinity;
            float zmin = float.PositiveInfinity;
            float xmax = float.NegativeInfinity;
            float zmax = float.NegativeInfinity;

            for (int i = 0; i < m_overlays.Count; i++)
            {
                WaveOverlay overlay = m_overlays[i];

                //Set the alpha based on the its age and curve
                float a = overlay.NormalizedAge;
                overlay.FoamTex.alpha       = timeLine.Evaluate(a) * alpha;
                overlay.FoamTex.textureFoam = textureFoam;
                overlay.DrawDistance        = drawDistance;
                //Updates the overlays position, rotation, expansion and its bounding box.
                overlay.UpdateOverlay();

                float half = Mathf.Max(overlay.HalfSize.x, overlay.HalfSize.y);

                for (int j = 0; j < 4; j++)
                {
                    if (overlay.Position.x - half < xmin)
                    {
                        xmin = overlay.Position.x - half;
                    }
                    if (overlay.Position.x + half > xmax)
                    {
                        xmax = overlay.Position.x + half;
                    }
                    if (overlay.Position.z - half < zmin)
                    {
                        zmin = overlay.Position.z - half;
                    }
                    if (overlay.Position.z + half > zmax)
                    {
                        zmax = overlay.Position.z + half;
                    }
                }
            }

            //Caculate the bounds of all the overlays.
            //This will be the overlays parents bounds.

            float range = 0.0f;
            float level = 0.0f;

            if (Ocean.Instance != null)
            {
                level = Ocean.Instance.level;
                range = Ocean.Instance.FindMaxDisplacement(true);
            }

            Vector3 size;

            size.x = xmax - xmin;
            size.y = range * 2.0f;
            size.z = zmax - zmin;

            Vector3 center;

            center.x = (xmax + xmin) * 0.5f;
            center.y = level;
            center.z = (zmax + zmin) * 0.5f;

            if (float.IsInfinity(size.x) || float.IsInfinity(size.y) || float.IsInfinity(size.z))
            {
                BoundingBox = new Bounds();
            }
            else
            {
                BoundingBox = new Bounds(center, size);
            }
        }