Ejemplo n.º 1
0
    public void DebugRender(bool debug = true, string Text = "")
    {
        if (!debug)
        {
            ClearDebugRender();
            return;
        }

        if (null == _DebugRender)
        {
            _DebugRender = new UEDebugMeshRender();
        }

        List <Vector3> vlist  = new List <Vector3>();
        List <int>     ilist  = new List <int>();
        List <Color>   clist  = new List <Color>();
        int            iindex = 0;

        for (int i = 0; i < GetFaceNum(); ++i)
        {
            CovFace cf = GetFace(i);
            Vector3 v0 = (GetVertex(cf.GetVID(0)));

            for (int j = 1; j < cf.GetVNum() - 1; ++j)
            {
                vlist.Add(v0);
                ilist.Add(iindex++);
                Vector3 v1 = GetVertex(cf.GetVID(j + 0));
                vlist.Add(v1);
                ilist.Add(iindex++);
                Vector3 v2 = GetVertex(cf.GetVID(j + 1));
                vlist.Add(v2);
                ilist.Add(iindex++);
                Vector3 normal = Vector3.Cross(v0 - v1, v1 - v2);
                normal.Normalize();

                float fdot      = Vector3.Dot(normal, (Vector3.left - Vector3.down));
                float fweight   = Mathf.Max(0, fdot) * .8f;
                Color facecolor = Color.red * (.2f + fweight);
                clist.Add(facecolor);
                clist.Add(facecolor);
                clist.Add(facecolor);
            }
        }

        int index = 0;

        foreach (Vector3 v in vlist)
        {
            _DebugRender.SetPoint(index++, v);
        }
        _DebugRender.CreateLineRender();
        //_DebugRender.AABB = GetAABB();
        _DebugRender.Create(vlist, ilist, clist);

        //if(!string.IsNullOrEmpty(Text))
        //{
        //    _DebugRender.CreateText(Text);
        //}
    }
Ejemplo n.º 2
0
 public void ClearDebugRender()
 {
     //debug
     if (null != _DebugRender)
     {
         _DebugRender.Destroy();
         _DebugRender = null;
     }
 }