Tesselate.Tesselator.AddVertex C# (CSharp) Méthode

AddVertex() private méthode

private AddVertex ( double x, double y, int data ) : bool
x double
y double
data int
Résultat bool
        bool AddVertex(double x, double y, int data)
        {
            HalfEdge e;
            e = this.lastHalfEdge;
            if (e == null)
            {
                /* Make a self-loop (one vertex, one edge). */
                e = this.mesh.MakeEdge();
                Mesh.meshSplice(e, e.otherHalfOfThisEdge);
            }
            else
            {
                /* Create a new vertex and edge which immediately follow e
                * in the ordering around the left face.
                */
                if (Mesh.meshSplitEdge(e) == null)
                {
                    return false;
                }
                e = e.nextEdgeCCWAroundLeftFace;
            }

            /* The new vertex is now e.Org. */
            e.originVertex.clientIndex = data;
            e.originVertex.C_0 = x;
            e.originVertex.C_1 = y;
            /* The winding of an edge says how the winding number changes as we
            * cross from the edge''s right face to its left face.  We add the
            * vertices in such an order that a CCW contour will add +1 to
            * the winding number of the region inside the contour.
            */
            e.winding = 1;
            e.otherHalfOfThisEdge.winding = -1;
            this.lastHalfEdge = e;
            return true;
        }

Same methods

Tesselator::AddVertex ( double x, double y, double z, int data ) : void

Usage Example

Exemple #1
0
        public float[] TessPolygon(float[] vertex2dCoords, int[] contourEndPoints, out int areaCount)
        {
            vertexts.Clear();//reset
            //
            int ncoords = vertex2dCoords.Length / 2;

            if (ncoords == 0)
            {
                areaCount = 0; return(null);
            }

            int nn = 0;

            for (int i = 0; i < ncoords; ++i)
            {
                vertexts.Add(new Vertex(vertex2dCoords[nn++], vertex2dCoords[nn++]));
            }
            //-----------------------
            tessListener.Reset(vertexts);
            //-----------------------
            tess.BeginPolygon();

            int nContourCount = contourEndPoints.Length;
            int beginAt       = 0;

            for (int m = 0; m < nContourCount; ++m)
            {
                int thisContourEndAt = (contourEndPoints[m] + 1) / 2;
                tess.BeginContour();
                for (int i = beginAt; i < thisContourEndAt; ++i)
                {
                    Vertex v = vertexts[i];
                    tess.AddVertex(v.m_X, v.m_Y, 0, i);
                }
                beginAt = thisContourEndAt + 1;
                tess.EndContour();
            }


            tess.EndPolygon();
            //-----------------------
            List <Vertex> vertextList = tessListener.resultVertexList;
            //-----------------------------
            //switch how to fill polygon
            int j = vertextList.Count;

            float[] vtx = new float[j * 2];
            int     n   = 0;

            for (int p = 0; p < j; ++p)
            {
                var v = vertextList[p];
                vtx[n]     = (float)v.m_X;
                vtx[n + 1] = (float)v.m_Y;
                n         += 2;
            }
            //triangle list
            areaCount = j;
            return(vtx);
        }
All Usage Examples Of Tesselate.Tesselator::AddVertex