Ejemplo n.º 1
0
        /** Closes a polyline by triangulating all it's vertices with it's baricenter, visualizing it as a polygon FROM OUTSIDE**/
        public void closePolylineOutside(Polyline poly)
        {
            Vertex baricenter = new Vertex();

            baricenter.setPosition(poly.calculateBaricenter());
            baricenter.setUV(poly.calculateBaricenterUV());
            int baricenterIndex = getNumVertices();

            addVertex(baricenter);
            //addHoleIndex (baricenterIndex); //Special case when closing after a hole, helps to disimulate triangulation
            for (int i = 0; i < poly.getSize(); ++i)
            {
                //Left-hand!!
                addTriangle(poly.getVertex(i + 1).getIndex(), poly.getVertex(i).getIndex(), baricenterIndex);
            }
        }
Ejemplo n.º 2
0
        /**Duplicates first vertex and set it at last position with UV coord (1,y). This has to be called as the last
         * of all the polyline modifier functions **/
        public void duplicateFirstVertex()
        {
            InitialPolyline newPolyline = new InitialPolyline(getSize() + 1);

            for (int i = 0; i < getSize(); ++i)
            {
                newPolyline.setVertex(i, getVertex(i));
            }
            Vertex lastV = new Vertex(getVertex(0));

            newPolyline.setVertex(getSize(), lastV);
            Vector2 newUV = lastV.getUV();

            newUV.x = 1.0f;
            lastV.setUV(newUV);
            this.mVertices = newPolyline.mVertices;
        }