コード例 #1
0
 private void OnDrawGizmos()
 {
     //Gizmos.color = Color.red;
     //Gizmos.DrawWireMesh(AntiPortalHelper.GetCube(), this.transform.position, this.transform.rotation, Vector3.Scale(this.extends, this.transform.localScale)*2.0f);
     Gizmos.color = new Color(1.0f, 0.0f, 0.0f, 0.5f);
     Gizmos.DrawMesh(AntiPortalHelper.GetCube(), this.transform.position, this.transform.rotation, Vector3.Scale(this.extents, this.transform.localScale) * 2.0f);
     //Gizmos.color = Color.red;
     //Gizmos.DrawWireMesh(AntiPortalHelper.GetCube(), this.transform.position, this.transform.rotation, Vector3.Scale(this.extends, this.transform.localScale) * 2.0f);
 }
コード例 #2
0
    private void OnPostRender()
    {
        if (this.occludeeVisable.Count > 0)
        {
#if UNITY_EDITOR
            if (this.isDebugMode)
            {
                //debug mode
                GL.Clear(true, false, Color.black);
                if (this.lineMaterial == null)
                {
                    this.lineMaterial = new Material(Shader.Find("Hidden/Internal-Colored"));
                }
                this.lineMaterial.SetPass(0);
                GL.Begin(GL.LINES);
                //Draw culled occludee
                GL.Color(Color.red);
                for (int i = 0; i < this.occludees.Count; i++)
                {
                    if (this.occludeeVisable[i] == false)
                    {
                        Bounds    bound = this.occludees[i].GetBounds();
                        Vector3[] wire  = AntiPortalHelper.GetBoundsWire(bound);
                        foreach (Vector3 v in wire)
                        {
                            GL.Vertex(v);
                        }
                    }
                }

                //Draw culled occluder
                GL.Color(Color.blue);
                for (int i = 0; i < this.occluders.Count; i++)
                {
                    if (this.occluderVisable[i] == false)
                    {
                        Vector3[] wire = this.occluders[i].GetWire();
                        foreach (Vector3 v in wire)
                        {
                            GL.Vertex(v);
                        }
                    }
                }

                GL.End();

                //draw culled occludee in editor view
                this.occludedBounds.Clear();
                for (int i = 0; i < this.occludees.Count; i++)
                {
                    if (this.occludeeVisable[i] == false)
                    {
                        this.occludedBounds.Add(this.occludees[i].GetBounds());
                    }
                }

                int culledNum = 0;
                for (int i = 0; i < this.occludees.Count; i++)
                {
                    if (this.occludeeVisable[i] == false)
                    {
                        culledNum++;
                    }
                }
                //Debug.Log("Total: " + this.occludees.Count);
                //Debug.Log("Culled: " + culledNum);
            }
#endif

            float fTime = Time.realtimeSinceStartup;
            for (int i = 0; i < this.occludees.Count; i++)
            {
                this.occludees[i].SetVisable(true);
            }
            setVisableTime += Time.realtimeSinceStartup - fTime;
            //Debug.Log("Visable cost: " + setVisableTime * 1000);
        }


        this.occludees.Clear();
        this.occluders.Clear();

        this.occludeeVisable.Clear();
        this.occluderVisable.Clear();
        this.rendererNum = 0;
    }