예제 #1
0
		public PConcavePolygonShape(float[] xvers, float[] yvers, float density) {
			fig = new PFigure();
			tri = new PTriangulator();
			poly = new PPolygonizer();
			numVertices = xvers.Length;
			localVers = new Vector2f[numVertices];
			vers = new Vector2f[numVertices];
			_dens = density;
			for (int i = 0; i < numVertices; i++) {
				localVers[i] = new Vector2f(xvers[i], yvers[i]);
				vers[i] = new Vector2f(xvers[i], yvers[i]);
			}
	
			fig.Figure(localVers, numVertices);
			numVertices = fig.numVertices;
			localVers = new Vector2f[numVertices];
			vers = new Vector2f[numVertices];
			for (int i_0 = 0; i_0 < numVertices; i_0++) {
				localVers[i_0] = new Vector2f(fig.done[i_0].x, fig.done[i_0].y);
				vers[i_0] = new Vector2f(fig.done[i_0].x, fig.done[i_0].y);
			}
			tri.Triangulate(fig.done, fig.numVertices);
			poly.Polygonize(tri.triangles, tri.numTriangles);
			convexes = new PConvexPolygonShape[1024];
			for (int i_1 = 0; i_1 < poly.numPolygons; i_1++) {
				convexes[i_1] = new PConvexPolygonShape(poly.polygons[i_1].xs,
						poly.polygons[i_1].ys, _dens);
			}
			numConvexes = poly.numPolygons;
			CalcMassData();
			_type = PShapeType.CONCAVE_SHAPE;
		}
예제 #2
0
        public PConcavePolygonShape(float[] xvers, float[] yvers, float density)
        {
            fig         = new PFigure();
            tri         = new PTriangulator();
            poly        = new PPolygonizer();
            numVertices = xvers.Length;
            localVers   = new Vector2f[numVertices];
            vers        = new Vector2f[numVertices];
            _dens       = density;
            for (int i = 0; i < numVertices; i++)
            {
                localVers[i] = new Vector2f(xvers[i], yvers[i]);
                vers[i]      = new Vector2f(xvers[i], yvers[i]);
            }

            fig.Figure(localVers, numVertices);
            numVertices = fig.numVertices;
            localVers   = new Vector2f[numVertices];
            vers        = new Vector2f[numVertices];
            for (int i_0 = 0; i_0 < numVertices; i_0++)
            {
                localVers[i_0] = new Vector2f(fig.done[i_0].x, fig.done[i_0].y);
                vers[i_0]      = new Vector2f(fig.done[i_0].x, fig.done[i_0].y);
            }
            tri.Triangulate(fig.done, fig.numVertices);
            poly.Polygonize(tri.triangles, tri.numTriangles);
            convexes = new PConvexPolygonShape[1024];
            for (int i_1 = 0; i_1 < poly.numPolygons; i_1++)
            {
                convexes[i_1] = new PConvexPolygonShape(poly.polygons[i_1].xs,
                                                        poly.polygons[i_1].ys, _dens);
            }
            numConvexes = poly.numPolygons;
            CalcMassData();
            _type = PShapeType.CONCAVE_SHAPE;
        }