Example #1
0
    public CovFace GetNeighborFace(CovFace face, int vID1, int vID2)
    {
        for (int i = 0; i < GetFaceNum(); i++)
        {
            CovFace cface = GetFace(i);
            if (cface == face)
            {
                continue;
            }
            int j;
            for (j = 0; j < cface.GetVNum() - 1; j++)
            {
                if ((cface.GetVID(j) == vID1 && cface.GetVID(j + 1) == vID2) ||
                    (cface.GetVID(j) == vID2 && cface.GetVID(j + 1) == vID1))
                {
                    return(cface);
                }
            }

            if ((cface.GetVID(j) == vID1 && cface.GetVID(0) == vID2) ||
                (cface.GetVID(j) == vID2 && cface.GetVID(0) == vID1))
            {
                return(cface);
            }
        }
        return(null);
    }
Example #2
0
    public Vector3 GetSupportPlaneNormal(int vID1, int vID2)
    {
        Vector3 normal = Vector3.zero;
        float   maxY   = 0;

        for (int i = 0; i < GetFaceNum(); i++)
        {
            CovFace cface = GetFace(i);
            int     j;
            for (j = 0; j < cface.GetVNum() - 1; j++)
            {
                if ((cface.GetVID(j) == vID1 && cface.GetVID(j + 1) == vID2) ||
                    (cface.GetVID(j) == vID2 && cface.GetVID(j + 1) == vID1))
                {
                    if (cface.Normal.y > maxY)
                    {
                        maxY   = cface.Normal.y;
                        normal = cface.Normal;
                    }
                    break;
                }
            }

            if ((cface.GetVID(j) == vID1 && cface.GetVID(0) == vID2) ||
                (cface.GetVID(j) == vID2 && cface.GetVID(0) == vID1))
            {
                if (cface.Normal.y > maxY)
                {
                    maxY   = cface.Normal.y;
                    normal = cface.Normal;
                }
            }
        }
        return(normal);
    }
Example #3
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);
        //}
    }
Example #4
0
    public void Set(CovFace face)
    {
        Normal = face.Normal;
        Dist   = face.Dist;

        for (int i = 0; i < face.GetVNum(); i++)
        {
            int vid = face.GetVID(i);
            AddElement(vid);
        }
    }