Exemplo n.º 1
0
        /// <summary>
        /// Gets all the query-able overlays that contain xz pos.
        /// </summary>
        public void GetQueryableContaining(float x, float z, bool overrideIqnoreQuerys, bool clipOnly)
        {
            m_containingOverlays.Clear();

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

                if (overlay.Hide)
                {
                    continue;
                }

                bool b1 = !clipOnly && (overrideIqnoreQuerys || !overlay.HeightTex.ignoreQuerys) && overlay.HeightTex.IsDrawable;
                bool b2 = (overrideIqnoreQuerys || !overlay.ClipTex.ignoreQuerys) && overlay.ClipTex.IsDrawable;

                if (!b1 && !b2)
                {
                    continue;
                }

                float u, v;
                if (overlay.Contains(x, z, out u, out v))
                {
                    QueryableOverlayResult result;
                    result.overlay = overlay;
                    result.u       = u;
                    result.v       = v;

                    m_containingOverlays.Add(result);
                }
            }
        }
        /// <summary>
        /// Remove any overlays that have a age longer that there duration.
        /// </summary>
        void RemoveOverlays()
        {
            LinkedList <WaveOverlay> remove = new LinkedList <WaveOverlay>();

            var e1 = m_overlays.GetEnumerator();

            while (e1.MoveNext())
            {
                WaveOverlay overlay = e1.Current;

                if (overlay.Age >= overlay.Duration)
                {
                    remove.AddLast(overlay);
                    //Set kill to true to remove from oceans overlay manager.
                    overlay.Kill = true;
                }
            }

            var e2 = remove.GetEnumerator();

            while (e2.MoveNext())
            {
                m_overlays.Remove(e2.Current);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns true if any overlay in manager contains the xz pos.
        /// </summary>
        public bool QueryableContains(float x, float z, bool overrideIqnoreQuerys)
        {
            for (int i = 0; i < m_queryableOverlays.Count; i++)
            {
                WaveOverlay overlay = m_queryableOverlays[i];

                if (overlay.Hide)
                {
                    continue;
                }

                bool b1 = (overrideIqnoreQuerys || !overlay.HeightTex.ignoreQuerys) && overlay.HeightTex.IsDrawable;
                bool b2 = (overrideIqnoreQuerys || !overlay.ClipTex.ignoreQuerys) && overlay.ClipTex.IsDrawable;

                if (!b1 && !b2)
                {
                    continue;
                }

                if (overlay.Contains(x, z))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns true if any overlay in manager contains the xz pos.
        /// </summary>
        public bool QueryableContains(float x, float z, bool overrideIqnoreQuerys)
        {
            var e = m_queryableOverlays.GetEnumerator();

            while (e.MoveNext())
            {
                WaveOverlay overlay = e.Current;

                if (overlay.Hide)
                {
                    continue;
                }

                bool b1 = (overrideIqnoreQuerys || !overlay.HeightTex.ignoreQuerys) && overlay.HeightTex.IsDrawable;
                bool b2 = (overrideIqnoreQuerys || !overlay.ClipTex.ignoreQuerys) && overlay.ClipTex.IsDrawable;

                if (!b1 && !b2)
                {
                    continue;
                }

                if (overlay.Contains(x, z))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets all the query-able overlays that contain xz pos.
        /// </summary>
        public void GetQueryableContaining(float x, float z, bool overrideIqnoreQuerys, bool clipOnly)
        {
            m_containingOverlays.Clear();

            var e = m_queryableOverlays.GetEnumerator();

            while (e.MoveNext())
            {
                WaveOverlay overlay = e.Current;

                if (overlay.Hide)
                {
                    continue;
                }

                bool b1 = !clipOnly && (overrideIqnoreQuerys || !overlay.HeightTex.ignoreQuerys) && overlay.HeightTex.IsDrawable;
                bool b2 = (overrideIqnoreQuerys || !overlay.ClipTex.ignoreQuerys) && overlay.ClipTex.IsDrawable;

                if (!b1 && !b2)
                {
                    continue;
                }

                float u, v;
                if (overlay.Contains(x, z, out u, out v))
                {
                    QueryableOverlayResult result;
                    result.overlay = overlay;
                    result.u       = u;
                    result.v       = v;

                    m_containingOverlays.Add(result);
                }
            }
        }
Exemplo n.º 6
0
        void RenderNormalOverlays(RenderTexture target)
        {
            if (target == null)
            {
                return;
            }

            Matrix4x4 rotation = new Matrix4x4();

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

                RotateY(rotation, overlay.Rotation);

                m_overlayMat.SetMatrix("Ceto_Overlay_Rotation", rotation);
                m_overlayMat.SetFloat("Ceto_Overlay_Alpha", Mathf.Max(0.0f, overlay.NormalTex.alpha));
                m_overlayMat.SetFloat("Ceto_Overlay_MaskAlpha", Mathf.Max(0.0f, overlay.NormalTex.maskAlpha));
                m_overlayMat.SetTexture("Ceto_Overlay_Normal", (overlay.NormalTex.tex != null) ? overlay.NormalTex.tex : m_blankNormal);
                m_overlayMat.SetTexture("Ceto_Overlay_NormalMask", (overlay.NormalTex.mask != null) ? overlay.NormalTex.mask : Texture2D.blackTexture);
                m_overlayMat.SetFloat("Ceto_Overlay_MaskMode", (float)overlay.NormalTex.maskMode);

                Blit(overlay.Corners, overlay.NormalTex.scaleUV, overlay.NormalTex.offsetUV, target, m_overlayMat, (int)OVERLAY_PASS.NORMAL_ADD);
            }
        }
Exemplo n.º 7
0
 public void GetQueryableContaining(float x, float z, bool overrideIqnoreQuerys, bool clipOnly)
 {
     this.m_containingOverlays.Clear();
     List <WaveOverlay> .Enumerator enumerator = this.m_queryableOverlays.GetEnumerator();
     while (enumerator.MoveNext())
     {
         WaveOverlay current = enumerator.Current;
         if (!current.Hide)
         {
             bool flag  = !clipOnly && (overrideIqnoreQuerys || !current.HeightTex.ignoreQuerys) && current.HeightTex.IsDrawable;
             bool flag2 = (overrideIqnoreQuerys || !current.ClipTex.ignoreQuerys) && current.ClipTex.IsDrawable;
             if (flag || flag2)
             {
                 float u;
                 float v;
                 if (current.Contains(x, z, out u, out v))
                 {
                     QueryableOverlayResult item;
                     item.overlay = current;
                     item.u       = u;
                     item.v       = v;
                     this.m_containingOverlays.Add(item);
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
        void RenderFoamOverlays(RenderTexture target)
        {
            if (target == null)
            {
                return;
            }

            int pass = (FoamOverlayBlendMode == OVERLAY_BLEND_MODE.ADD) ? (int)OVERLAY_PASS.FOAM_ADD : (int)OVERLAY_PASS.FOAM_MAX;

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



                m_overlayMat.SetFloat("Ceto_Overlay_Alpha", Mathf.Max(0.0f, overlay.FoamTex.alpha));
                m_overlayMat.SetFloat("Ceto_Overlay_MaskAlpha", Mathf.Max(0.0f, overlay.FoamTex.maskAlpha));
                m_overlayMat.SetTexture("Ceto_Overlay_Foam", (overlay.FoamTex.tex != null) ? overlay.FoamTex.tex : Texture2D.blackTexture);
                m_overlayMat.SetTexture("Ceto_Overlay_FoamMask", (overlay.FoamTex.mask != null) ? overlay.FoamTex.mask : Texture2D.blackTexture);
                m_overlayMat.SetFloat("Ceto_Overlay_MaskMode", (float)overlay.FoamTex.maskMode);
                m_overlayMat.SetVector("Ceto_TextureFoam", (overlay.FoamTex.textureFoam) ? TEXTURE_FOAM : DONT_TEXTURE_FOAM);

                Blit(overlay.Corners, overlay.FoamTex.scaleUV, overlay.FoamTex.offsetUV, target, m_overlayMat, pass);
            }
        }
Exemplo n.º 9
0
 public void Add(WaveOverlay overlay)
 {
     if (overlay.Kill)
     {
         return;
     }
     this.m_waveOverlays.AddLast(overlay);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Add the specified overlay.
        /// </summary>
        public void Add(WaveOverlay overlay)
        {
            if (overlay.Kill == true)
            {
                return;
            }

            m_waveOverlays.AddLast(overlay);
        }
Exemplo n.º 11
0
 public void Update()
 {
     this.HasHeightOverlay = false;
     this.HasNormalOverlay = false;
     this.HasFoamOverlay   = false;
     this.HasClipOverlay   = false;
     this.MaxDisplacement  = 1f;
     this.m_queryableOverlays.Clear();
     this.m_removeOverlays.Clear();
     LinkedList <WaveOverlay> .Enumerator enumerator = this.m_waveOverlays.GetEnumerator();
     while (enumerator.MoveNext())
     {
         WaveOverlay current = enumerator.Current;
         if (current.Kill)
         {
             this.m_removeOverlays.Add(current);
         }
         else if (!current.Hide)
         {
             bool flag = false;
             if (current.HeightTex.IsDrawable)
             {
                 this.HasHeightOverlay = true;
                 flag = true;
                 if (current.HeightTex.alpha > this.MaxDisplacement)
                 {
                     this.MaxDisplacement = current.HeightTex.alpha;
                 }
             }
             if (current.NormalTex.IsDrawable)
             {
                 this.HasNormalOverlay = true;
             }
             if (current.FoamTex.IsDrawable)
             {
                 this.HasFoamOverlay = true;
             }
             if (current.ClipTex.IsDrawable)
             {
                 this.HasClipOverlay = true;
                 flag = true;
             }
             if (flag)
             {
                 this.m_queryableOverlays.Add(current);
             }
         }
     }
     this.MaxDisplacement = Mathf.Min(this.MaxDisplacement, 20f);
     List <WaveOverlay> .Enumerator enumerator2 = this.m_removeOverlays.GetEnumerator();
     while (enumerator2.MoveNext())
     {
         this.m_waveOverlays.Remove(enumerator2.Current);
     }
 }
Exemplo n.º 12
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();
     }
 }
Exemplo n.º 13
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();
     }
 }
Exemplo n.º 14
0
 private void RenderClipOverlays(RenderTexture target)
 {
     if (target == null)
     {
         return;
     }
     for (int i = 0; i < this.m_clipOverlays.Count; i++)
     {
         WaveOverlay waveOverlay = this.m_clipOverlays[i];
         this.m_overlayMat.SetFloat("Ceto_Overlay_Alpha", Mathf.Max(0f, waveOverlay.ClipTex.alpha));
         this.m_overlayMat.SetTexture("Ceto_Overlay_Clip", (!(waveOverlay.ClipTex.tex != null)) ? Texture2D.blackTexture : waveOverlay.ClipTex.tex);
         this.Blit(waveOverlay.Corners, waveOverlay.ClipTex.scaleUV, waveOverlay.ClipTex.offsetUV, target, this.m_overlayMat, 3);
     }
 }
Exemplo n.º 15
0
 private void RenderNormalOverlays(RenderTexture target)
 {
     if (target == null)
     {
         return;
     }
     for (int i = 0; i < this.m_normalOverlays.Count; i++)
     {
         WaveOverlay waveOverlay = this.m_normalOverlays[i];
         this.m_overlayMat.SetFloat("Ceto_Overlay_Alpha", Mathf.Max(0f, waveOverlay.NormalTex.alpha));
         this.m_overlayMat.SetFloat("Ceto_Overlay_MaskAlpha", Mathf.Max(0f, waveOverlay.NormalTex.maskAlpha));
         this.m_overlayMat.SetTexture("Ceto_Overlay_Normal", (!(waveOverlay.NormalTex.tex != null)) ? this.m_blankNormal : waveOverlay.NormalTex.tex);
         this.m_overlayMat.SetTexture("Ceto_Overlay_NormalMask", (!(waveOverlay.NormalTex.mask != null)) ? Texture2D.blackTexture : waveOverlay.NormalTex.mask);
         this.m_overlayMat.SetFloat("Ceto_Overlay_MaskMode", (float)waveOverlay.NormalTex.maskMode);
         this.Blit(waveOverlay.Corners, waveOverlay.NormalTex.scaleUV, waveOverlay.NormalTex.offsetUV, target, this.m_overlayMat, 1);
     }
 }
Exemplo n.º 16
0
        void RenderClipOverlays(RenderTexture target)
        {
            if (target == null)
            {
                return;
            }

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

                m_overlayMat.SetFloat("Ceto_Overlay_Alpha", Mathf.Max(0.0f, overlay.ClipTex.alpha));
                m_overlayMat.SetTexture("Ceto_Overlay_Clip", (overlay.ClipTex.tex != null) ? overlay.ClipTex.tex : Texture2D.blackTexture);

                Blit(overlay.Corners, overlay.ClipTex.scaleUV, overlay.ClipTex.offsetUV, target, m_overlayMat, (int)OVERLAY_PASS.CLIP_ADD);
            }
        }
Exemplo n.º 17
0
        private void RenderHeightOverlays(RenderTexture target)
        {
            if (target == null)
            {
                return;
            }
            int pass = (this.HeightOverlayBlendMode != OVERLAY_BLEND_MODE.ADD) ? 4 : 0;

            for (int i = 0; i < this.m_heightOverlays.Count; i++)
            {
                WaveOverlay waveOverlay = this.m_heightOverlays[i];
                this.m_overlayMat.SetFloat("Ceto_Overlay_Alpha", waveOverlay.HeightTex.alpha);
                this.m_overlayMat.SetFloat("Ceto_Overlay_MaskAlpha", Mathf.Max(0f, waveOverlay.HeightTex.maskAlpha));
                this.m_overlayMat.SetTexture("Ceto_Overlay_Height", (!(waveOverlay.HeightTex.tex != null)) ? Texture2D.blackTexture : waveOverlay.HeightTex.tex);
                this.m_overlayMat.SetTexture("Ceto_Overlay_HeightMask", (!(waveOverlay.HeightTex.mask != null)) ? Texture2D.blackTexture : waveOverlay.HeightTex.mask);
                this.m_overlayMat.SetFloat("Ceto_Overlay_MaskMode", (float)waveOverlay.HeightTex.maskMode);
                this.Blit(waveOverlay.Corners, waveOverlay.HeightTex.scaleUV, waveOverlay.HeightTex.offsetUV, target, this.m_overlayMat, pass);
            }
        }
Exemplo n.º 18
0
        void RenderClipOverlays(IEnumerable <WaveOverlay> overlays, RenderTexture target)
        {
            if (target == null)
            {
                return;
            }

            var e = overlays.GetEnumerator();

            while (e.MoveNext())
            {
                WaveOverlay overlay = e.Current;

                m_overlayMat.SetFloat("Ceto_Overlay_Alpha", Mathf.Max(0.0f, overlay.ClipTex.alpha));
                m_overlayMat.SetTexture("Ceto_Overlay_Clip", (overlay.ClipTex.tex != null) ? overlay.ClipTex.tex : Texture2D.blackTexture);

                Blit(overlay.Corners, overlay.ClipTex.scaleUV, overlay.ClipTex.offsetUV, target, m_overlayMat, (int)OVERLAY_PASS.CLIP);
            }
        }
Exemplo n.º 19
0
        private void RenderFoamOverlays(RenderTexture target)
        {
            if (target == null)
            {
                return;
            }
            int pass = (this.FoamOverlayBlendMode != OVERLAY_BLEND_MODE.ADD) ? 5 : 2;

            for (int i = 0; i < this.m_foamOverlays.Count; i++)
            {
                WaveOverlay waveOverlay = this.m_foamOverlays[i];
                this.m_overlayMat.SetFloat("Ceto_Overlay_Alpha", Mathf.Max(0f, waveOverlay.FoamTex.alpha));
                this.m_overlayMat.SetFloat("Ceto_Overlay_MaskAlpha", Mathf.Max(0f, waveOverlay.FoamTex.maskAlpha));
                this.m_overlayMat.SetTexture("Ceto_Overlay_Foam", (!(waveOverlay.FoamTex.tex != null)) ? Texture2D.blackTexture : waveOverlay.FoamTex.tex);
                this.m_overlayMat.SetTexture("Ceto_Overlay_FoamMask", (!(waveOverlay.FoamTex.mask != null)) ? Texture2D.blackTexture : waveOverlay.FoamTex.mask);
                this.m_overlayMat.SetFloat("Ceto_Overlay_MaskMode", (float)waveOverlay.FoamTex.maskMode);
                this.m_overlayMat.SetVector("Ceto_TextureFoam", (!waveOverlay.FoamTex.textureFoam) ? OverlayManager.DONT_TEXTURE_FOAM : OverlayManager.TEXTURE_FOAM);
                this.Blit(waveOverlay.Corners, waveOverlay.FoamTex.scaleUV, waveOverlay.FoamTex.offsetUV, target, this.m_overlayMat, pass);
            }
        }
Exemplo n.º 20
0
 public bool QueryableContains(float x, float z, bool overrideIqnoreQuerys)
 {
     List <WaveOverlay> .Enumerator enumerator = this.m_queryableOverlays.GetEnumerator();
     while (enumerator.MoveNext())
     {
         WaveOverlay current = enumerator.Current;
         if (!current.Hide)
         {
             bool flag  = (overrideIqnoreQuerys || !current.HeightTex.ignoreQuerys) && current.HeightTex.IsDrawable;
             bool flag2 = (overrideIqnoreQuerys || !current.ClipTex.ignoreQuerys) && current.ClipTex.IsDrawable;
             if (flag || flag2)
             {
                 if (current.Contains(x, z))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 21
0
        void RenderHeightOverlays(RenderTexture target)
        {
            if (target == null)
            {
                return;
            }

            int pass = (HeightOverlayBlendMode == OVERLAY_BLEND_MODE.ADD) ? (int)OVERLAY_PASS.HEIGHT_ADD : (int)OVERLAY_PASS.HEIGHT_MAX;

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

                m_overlayMat.SetFloat("Ceto_Overlay_Alpha", overlay.HeightTex.alpha);
                m_overlayMat.SetFloat("Ceto_Overlay_MaskAlpha", Mathf.Max(0.0f, overlay.HeightTex.maskAlpha));
                m_overlayMat.SetTexture("Ceto_Overlay_Height", (overlay.HeightTex.tex != null) ? overlay.HeightTex.tex : Texture2D.blackTexture);
                m_overlayMat.SetTexture("Ceto_Overlay_HeightMask", (overlay.HeightTex.mask != null) ? overlay.HeightTex.mask : Texture2D.blackTexture);
                m_overlayMat.SetFloat("Ceto_Overlay_MaskMode", (float)overlay.HeightTex.maskMode);

                Blit(overlay.Corners, overlay.HeightTex.scaleUV, overlay.HeightTex.offsetUV, target, m_overlayMat, pass);
            }
        }
Exemplo n.º 22
0
        void RenderNormalOverlays(IEnumerable <WaveOverlay> overlays, RenderTexture target)
        {
            if (target == null)
            {
                return;
            }

            var e = overlays.GetEnumerator();

            while (e.MoveNext())
            {
                WaveOverlay overlay = e.Current;

                m_overlayMat.SetFloat("Ceto_Overlay_Alpha", Mathf.Max(0.0f, overlay.NormalTex.alpha));
                m_overlayMat.SetFloat("Ceto_Overlay_MaskAlpha", Mathf.Max(0.0f, overlay.NormalTex.maskAlpha));
                m_overlayMat.SetTexture("Ceto_Overlay_Normal", (overlay.NormalTex.tex != null) ? overlay.NormalTex.tex : m_blankNormal);
                m_overlayMat.SetTexture("Ceto_Overlay_NormalMask", (overlay.NormalTex.mask != null) ? overlay.NormalTex.mask : Texture2D.blackTexture);
                m_overlayMat.SetFloat("Ceto_Overlay_MaskMode", (float)overlay.NormalTex.maskMode);

                Blit(overlay.Corners, overlay.NormalTex.scaleUV, overlay.NormalTex.offsetUV, target, m_overlayMat, (int)OVERLAY_PASS.NORMAL);
            }
        }
Exemplo n.º 23
0
        void RenderFoamOverlays(IEnumerable <WaveOverlay> overlays, RenderTexture target)
        {
            if (target == null)
            {
                return;
            }

            var e = overlays.GetEnumerator();

            while (e.MoveNext())
            {
                WaveOverlay overlay = e.Current;

                m_overlayMat.SetFloat("Ceto_Overlay_Alpha", Mathf.Max(0.0f, overlay.FoamTex.alpha));
                m_overlayMat.SetFloat("Ceto_Overlay_MaskAlpha", Mathf.Max(0.0f, overlay.FoamTex.maskAlpha));
                m_overlayMat.SetTexture("Ceto_Overlay_Foam", (overlay.FoamTex.tex != null) ? overlay.FoamTex.tex : Texture2D.blackTexture);
                m_overlayMat.SetTexture("Ceto_Overlay_FoamMask", (overlay.FoamTex.mask != null) ? overlay.FoamTex.mask : Texture2D.blackTexture);
                m_overlayMat.SetFloat("Ceto_Overlay_MaskMode", (float)overlay.FoamTex.maskMode);
                m_overlayMat.SetVector("Ceto_TextureFoam", (overlay.FoamTex.textureFoam) ? TEXTURE_FOAM : DONT_TEXTURE_FOAM);

                Blit(overlay.Corners, overlay.FoamTex.scaleUV, overlay.FoamTex.offsetUV, target, m_overlayMat, (int)OVERLAY_PASS.FOAM);
            }
        }
Exemplo n.º 24
0
 /// <summary>
 /// Remove the specified overlay.
 /// </summary>
 public void Remove(WaveOverlay overlay)
 {
     m_waveOverlays.Remove(overlay);
 }
Exemplo n.º 25
0
 public void RenderWaveOverlays(Camera cam, WaveOverlayData data)
 {
     if (!this.m_beenCleared)
     {
         this.ClearBuffers(data);
         this.m_beenCleared = true;
     }
     if (this.m_waveOverlays.Count == 0)
     {
         return;
     }
     this.GetFrustumPlanes(cam.projectionMatrix * cam.worldToCameraMatrix);
     this.m_heightOverlays.Clear();
     this.m_normalOverlays.Clear();
     this.m_foamOverlays.Clear();
     this.m_clipOverlays.Clear();
     LinkedList <WaveOverlay> .Enumerator enumerator = this.m_waveOverlays.GetEnumerator();
     while (enumerator.MoveNext())
     {
         WaveOverlay current = enumerator.Current;
         if (!current.Hide && GeometryUtility.TestPlanesAABB(this.m_planes, current.BoundingBox))
         {
             if (current.HeightTex.IsDrawable)
             {
                 this.m_heightOverlays.Add(current);
             }
             if (current.NormalTex.IsDrawable)
             {
                 this.m_normalOverlays.Add(current);
             }
             if (current.FoamTex.IsDrawable)
             {
                 this.m_foamOverlays.Add(current);
             }
             if (current.ClipTex.IsDrawable)
             {
                 this.m_clipOverlays.Add(current);
             }
         }
     }
     this.RenderHeightOverlays(data.height);
     this.RenderNormalOverlays(data.normal);
     this.RenderFoamOverlays(data.foam);
     this.RenderClipOverlays(data.clip);
     if (data.normal != null)
     {
         Shader.SetGlobalTexture("Ceto_Overlay_NormalMap", data.normal);
     }
     else
     {
         Shader.SetGlobalTexture("Ceto_Overlay_NormalMap", Texture2D.blackTexture);
     }
     if (data.height != null)
     {
         Shader.SetGlobalTexture("Ceto_Overlay_HeightMap", data.height);
     }
     else
     {
         Shader.SetGlobalTexture("Ceto_Overlay_HeightMap", Texture2D.blackTexture);
     }
     if (data.foam != null)
     {
         Shader.SetGlobalTexture("Ceto_Overlay_FoamMap", data.foam);
     }
     else
     {
         Shader.SetGlobalTexture("Ceto_Overlay_FoamMap", Texture2D.blackTexture);
     }
     if (data.clip != null)
     {
         Shader.SetGlobalTexture("Ceto_Overlay_ClipMap", data.clip);
     }
     else
     {
         Shader.SetGlobalTexture("Ceto_Overlay_ClipMap", Texture2D.blackTexture);
     }
     this.m_beenCleared = false;
 }
Exemplo n.º 26
0
        /// <summary>
        /// Renders the wave overlays for this camera.
        /// </summary>
        public void RenderWaveOverlays(Camera cam, WaveOverlayData data)
        {
            if (!m_beenCleared)
            {
                ClearBuffers(data);
                m_beenCleared = true;
            }

            if (m_waveOverlays.Count == 0)
            {
                return;
            }

            // Plane[] planes = GeometryUtility.CalculateFrustumPlanes(cam);

            GetFrustumPlanes(cam.projectionMatrix * cam.worldToCameraMatrix);

            m_heightOverlays.Clear();
            m_normalOverlays.Clear();
            m_foamOverlays.Clear();
            m_clipOverlays.Clear();

            var e = m_waveOverlays.GetEnumerator();

            while (e.MoveNext())
            {
                WaveOverlay overlay = e.Current;

                if (!overlay.Hide && GeometryUtility.TestPlanesAABB(m_planes, overlay.BoundingBox))
                {
                    if (overlay.HeightTex.IsDrawable)
                    {
                        m_heightOverlays.Add(overlay);
                    }

                    if (overlay.NormalTex.IsDrawable)
                    {
                        m_normalOverlays.Add(overlay);
                    }

                    if (overlay.FoamTex.IsDrawable)
                    {
                        m_foamOverlays.Add(overlay);
                    }

                    if (overlay.ClipTex.IsDrawable)
                    {
                        m_clipOverlays.Add(overlay);
                    }
                }
            }

            RenderHeightOverlays(data.height);
            RenderNormalOverlays(data.normal);
            RenderFoamOverlays(data.foam);
            RenderClipOverlays(data.clip);

            //If buffer has been created apply it to shaders
            if (data.normal != null)
            {
                Shader.SetGlobalTexture("Ceto_Overlay_NormalMap", data.normal);
            }
            else
            {
                Shader.SetGlobalTexture("Ceto_Overlay_NormalMap", Texture2D.blackTexture);
            }

            if (data.height != null)
            {
                Shader.SetGlobalTexture("Ceto_Overlay_HeightMap", data.height);
            }
            else
            {
                Shader.SetGlobalTexture("Ceto_Overlay_HeightMap", Texture2D.blackTexture);
            }

            if (data.foam != null)
            {
                Shader.SetGlobalTexture("Ceto_Overlay_FoamMap", data.foam);
            }
            else
            {
                Shader.SetGlobalTexture("Ceto_Overlay_FoamMap", Texture2D.blackTexture);
            }

            if (data.clip != null)
            {
                Shader.SetGlobalTexture("Ceto_Overlay_ClipMap", data.clip);
            }
            else
            {
                Shader.SetGlobalTexture("Ceto_Overlay_ClipMap", Texture2D.blackTexture);
            }

            m_beenCleared = false;
        }
Exemplo n.º 27
0
        /// <summary>
        /// Updates what type of overlays manager has,
        /// removes any overlays marked as kill
        /// and sorts the overlays that can be queried.
        /// </summary>
        public void Update()
        {
            HasHeightOverlay = false;
            HasNormalOverlay = false;
            HasFoamOverlay   = false;
            HasClipOverlay   = false;

            MaxDisplacement = 1.0f;

            m_queryableOverlays.Clear();
            m_removeOverlays.Clear();

            var e1 = m_waveOverlays.GetEnumerator();

            while (e1.MoveNext())
            {
                WaveOverlay overlay = e1.Current;

                if (overlay.Kill)
                {
                    m_removeOverlays.Add(overlay);
                }
                else if (!overlay.Hide)
                {
                    bool canQuery = false;

                    if (overlay.HeightTex.IsDrawable)
                    {
                        HasHeightOverlay = true;
                        canQuery         = true;

                        if (overlay.HeightTex.alpha > MaxDisplacement)
                        {
                            MaxDisplacement = overlay.HeightTex.alpha;
                        }
                    }

                    if (overlay.NormalTex.IsDrawable)
                    {
                        HasNormalOverlay = true;
                    }

                    if (overlay.FoamTex.IsDrawable)
                    {
                        HasFoamOverlay = true;
                    }

                    if (overlay.ClipTex.IsDrawable)
                    {
                        HasClipOverlay = true;
                        canQuery       = true;
                    }

                    //if overlay has a drawable height or clip texture
                    //then this overlay can be queried.
                    if (canQuery)
                    {
                        m_queryableOverlays.Add(overlay);
                    }
                }
            }

            MaxDisplacement = Mathf.Min(MaxDisplacement, Ocean.MAX_OVERLAY_WAVE_HEIGHT);

            for (int i = 0; i < m_removeOverlays.Count; i++)
            {
                m_waveOverlays.Remove(m_removeOverlays[i]);
            }
        }
Exemplo n.º 28
0
        /// <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);
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Renders the wave overlays for this camera.
        /// </summary>
        public void RenderWaveOverlays(Camera cam, WaveOverlayData data)
        {
            if (!m_beenCleared)
            {
                ClearBuffers(data);
                m_beenCleared = true;
            }

            if (m_waveOverlays.Count == 0)
            {
                return;
            }

            //Copy camera planes into m_planes array.
            GetFrustumPlanes(cam.projectionMatrix * cam.worldToCameraMatrix);

            m_heightOverlays.Clear();
            m_normalOverlays.Clear();
            m_foamOverlays.Clear();
            m_clipOverlays.Clear();

            //rest the bounds check for the overlay parent if set.
            var e = m_waveOverlays.GetEnumerator();

            while (e.MoveNext())
            {
                if (e.Current.ParentBounds != null)
                {
                    e.Current.ParentBounds.BoundsChecked = false;
                }
            }

            e = m_waveOverlays.GetEnumerator();
            while (e.MoveNext())
            {
                WaveOverlay overlay = e.Current;

                //If camera farther than draw distance dont draw overlay.
                float distance = (overlay.Position - cam.transform.position).magnitude;
                if (distance > overlay.DrawDistance)
                {
                    continue;
                }

                //If overlay has a parent check if its bounds is visible.
                bool parentVisible = true;
                if (overlay.ParentBounds != null)
                {
                    parentVisible = false;

                    if (overlay.ParentBounds.BoundsChecked)
                    {
                        parentVisible = overlay.ParentBounds.BoundsVisible;
                    }
                    else
                    {
                        parentVisible = GeometryUtility.TestPlanesAABB(m_planes, overlay.ParentBounds.BoundingBox);
                        overlay.ParentBounds.BoundsVisible = parentVisible;
                        overlay.ParentBounds.BoundsChecked = true;
                    }
                }

                //Parent not visible so continue.
                if (!parentVisible)
                {
                    continue;
                }

                //Parent is visible so update overlay bounds.
                //Use a stamp so bounds will not be updated again if second camera renders it.
                if (overlay.BoundsUpdateStamp != Time.frameCount)
                {
                    overlay.CalculateBounds();
                    overlay.BoundsUpdateStamp = Time.frameCount;
                }

                //Create a alpha based on the draw distance.
                //Used to fade in the overlay as the camera enters the draw distance.
                //Only used for the foam atm.
                float distanceAlpha = 0.0f;
                if (overlay.DrawDistance != 0.0f && !float.IsInfinity(overlay.DrawDistance))
                {
                    distanceAlpha = distance / overlay.DrawDistance;
                }

                overlay.DistanceAlpha = 1.0f - distanceAlpha * distanceAlpha * distanceAlpha;

                if (!overlay.Hide && GeometryUtility.TestPlanesAABB(m_planes, overlay.BoundingBox))
                {
                    if (overlay.HeightTex.IsDrawable)
                    {
                        m_heightOverlays.Add(overlay);
                    }

                    if (overlay.NormalTex.IsDrawable)
                    {
                        m_normalOverlays.Add(overlay);
                    }

                    if (overlay.FoamTex.IsDrawable)
                    {
                        m_foamOverlays.Add(overlay);
                    }

                    if (overlay.ClipTex.IsDrawable)
                    {
                        m_clipOverlays.Add(overlay);
                    }
                }
            }
            //OYM:  这一部分是处理renderer,计算坐标
            RenderHeightOverlays(data.height);
            RenderNormalOverlays(data.normal);
            RenderFoamOverlays(data.foam);
            RenderClipOverlays(data.clip);

            //If buffer has been created apply it to shaders
            //OYM:  这里是渲染到海面上
            if (data.normal != null)
            {
                Shader.SetGlobalTexture("Ceto_Overlay_NormalMap", data.normal);
            }
            else
            {
                Shader.SetGlobalTexture("Ceto_Overlay_NormalMap", Texture2D.blackTexture);
            }

            if (data.height != null)
            {
                Shader.SetGlobalTexture("Ceto_Overlay_HeightMap", data.height);
            }
            else
            {
                Shader.SetGlobalTexture("Ceto_Overlay_HeightMap", Texture2D.blackTexture);
            }

            if (data.foam != null)
            {
                Shader.SetGlobalTexture("Ceto_Overlay_FoamMap", data.foam);
                //CetoTest.AddPicture(data.foam);
            }
            else
            {
                Shader.SetGlobalTexture("Ceto_Overlay_FoamMap", Texture2D.blackTexture);
            }

            if (data.clip != null)
            {
                Shader.SetGlobalTexture("Ceto_Overlay_ClipMap", data.clip);
                //CetoTest.AddPicture(data.clip);
            }
            else
            {
                Shader.SetGlobalTexture("Ceto_Overlay_ClipMap", Texture2D.blackTexture);
            }

            m_beenCleared = false;
        }
Exemplo n.º 30
0
 /// <summary>
 /// Remove the specified overlay.
 /// </summary>
 public void Remove(WaveOverlay overlay)
 {
     m_waveOverlays.Remove(overlay);
 }
Exemplo n.º 31
0
        /// <summary>
        /// Add the specified overlay.
        /// </summary>
        public void Add(WaveOverlay overlay)
        {
            if(overlay.Kill == true)
                return;

            m_waveOverlays.AddLast(overlay);
        }