// This makes a polygon from the path
        public EarClipPolygon MakePolygon(bool startfront)
        {
            EarClipPolygon p       = new EarClipPolygon();
            bool           forward = startfront;

            // Any sides at all?
            if (Count > 0)
            {
                p.AddLast(forward ? new EarClipVertex(base[0].Start.Position, base[0].Front) : new EarClipVertex(base[0].End.Position, base[0].Back));

                // Add all lines, but the first
                for (int i = 1; i < Count; i++)
                {
                    // Traverse direction changes?
                    if ((base[i - 1].Start == base[i].Start) ||
                        (base[i - 1].End == base[i].End))
                    {
                        forward = !forward;
                    }

                    // Add next vertex
                    p.AddLast(forward ? new EarClipVertex(base[i].Start.Position, base[i].Front) : new EarClipVertex(base[i].End.Position, base[i].Back));
                }
            }

            return(p);
        }
Ejemplo n.º 2
0
        // This makes a polygon from the path
        public EarClipPolygon MakePolygon()
        {
            EarClipPolygon p = new EarClipPolygon();

            // Any sides at all?
            if (Count > 0)
            {
                // Add all sides
                for (int i = 0; i < Count; i++)
                {
                    // On front or back?
                    if (base[i].IsFront)
                    {
                        p.AddLast(new EarClipVertex(base[i].Line.End.Position, base[i]));
                    }
                    else
                    {
                        p.AddLast(new EarClipVertex(base[i].Line.Start.Position, base[i]));
                    }
                }
            }

            return(p);
        }