context.beginPath(); context.moveTo(vertices[0].x, vertices[0].y); for (int i = 1; i < poly.getVertexCount(); ++i) { context.lineTo(vertices[i].x, vertices[i].y);
public void draw(Graphics2D graphics, int width, int height) { PolygonShape polygonShape = (PolygonShape) body.getFixtureList().getShape(); Vec2[] vertices = polygonShape.getVertices(); Vec2[] verticesTransform = new Vec2[polygonShape.getVertexCount()]; for(int i = 0; i < polygonShape.getVertexCount(); i++) { verticesTransform[i] = body.getWorldPoint(vertices[i]); System.out.println(verticesTransform[i]); } DrawShape.drawPolygon(graphics, verticesTransform, verticesTransform.length, Color.WHITE); }
PolygonShape src = (PolygonShape) f.getShape(); for (int i = 0; i < src.getVertexCount(); ++i) { Vec2 srcPt = src.getVertex(i); // build polygon up of these points and draw ...
PolygonShape shape = (PolygonShape) fixture.getShape(); int vertexCount = shape.getVertexCount(); float[] vertices = new float[vertexCount * 2]; for (int k = 0; k < vertexCount; k++) { shape.getVertex(k, mTmp); mTmp.rotate(body.getAngle()* MathUtils.radiansToDegrees); mTmp.add(bodyPos); vertices[k * 2] = mTmp.x * PIXELS_PER_METER; vertices[k * 2 + 1] = mTmp.y * PIXELS_PER_METER; } short triangles[] = new EarClippingTriangulator() .computeTriangles(vertices) .toArray(); PolygonRegion region = new PolygonRegion( textureRegion, vertices, triangles);
//Assuming only 1 fixture per body and a polygon shape Array<Vector2>verts = new Array<Vector2>(); Fixture f = body.getFixtureList().get(0); PolygonShape s = f.shape; for (int i = 0; i < s.getVertexCount(); i++) { verts.add(s.getVertex(i, /*I couldn't figure out what this param is supposed to be*/)); }
Array<Vector2> verts = new Array<Vector2>(); Fixture f = body.getFixtureList().get(0); PolygonShape s = f.shape; // this is needed to temporarily keep the vertex, getVertex is a void method Vector2 tmp = new Vector2(); for (int i = 0; i < s.getVertexCount(); i++) { // fill tmp with the vertex s.getVertex(i, tmp)); verts.add(new Vector2(tmp)); }
Float minY = null; Float maxY = null; for (int i = 0; i < polygonShape.getVertexCount(); i++) { Vec2 nextVertex = polygonShape.getVertex(i); float x = nextVertex.x;
int count1 = poly1.getVertexCount(); int count2 = poly2.getVertexCount(); Vec2[] n1s = poly1.m_normals; Vec2[] v1s = poly1.m_vertices;
PolygonShape src = (PolygonShape) f.getShape(); Transform t = new Transform(); t.set(new Vec2(0,0), body.getAngle()); for (int i = 0; i < src.getVertexCount(); ++i) { Vec2 srcPt = Transform.mul(t, src.getVertex(i)); // build polygon up of these points and draw ...
public final void findIncidentEdge(final ClipVertex[] c, final PolygonShape poly1, final Transform xf1, int edge1, final PolygonShape poly2, final Transform xf2) { int count1 = poly1.getVertexCount(); final Vec2[] normals1 = poly1.m_normals; int count2 = poly2.getVertexCount(); final Vec2[] vertices2 = poly2.m_vertices; final Vec2[] normals2 = poly2.m_normals;
if (theShape.getType() == ShapeType.POLYGON) { PolygonShape thePolyShape = (PolygonShape) theShape; for (int i = 1; i < thePolyShape.getVertexCount(); i++) { aCanvas.drawLine( toPosition(thePolyShape.getVertex(i - 1), theBodyPosition, theRotatedAngle), toPosition(thePolyShape.getVertex(thePolyShape.getVertexCount() - 1), theBodyPosition, theRotatedAngle), toPosition(thePolyShape.getVertex(0), theBodyPosition, theRotatedAngle), theBody
case POLYGON: final PolygonShape poly = (PolygonShape) shape; m_count = poly.getVertexCount(); m_radius = poly.getRadius(); for (int i = 0; i < m_count; i++) {
float separation = -Float.MAX_VALUE; final float radius = polygon.getRadius() + circle.getRadius(); final int vertexCount = polygon.getVertexCount(); float s; final Vec2[] vertices = polygon.m_vertices;
int count1 = poly1.getVertexCount(); final Vec2[] vertices1 = poly1.m_vertices;
int vertexCount = poly.getVertexCount(); assert (vertexCount <= JBoxSettings.maxPolygonVertices); Vec2[] vertices = tlvertices.get(JBoxSettings.maxPolygonVertices);
m_polygonB.count = polygonB.getVertexCount(); for (int i = 0; i < polygonB.getVertexCount(); ++i) { Transform.mulToOutUnsafe(m_xf, polygonB.m_vertices[i], m_polygonB.vertices[i]); Rotation.mulToOutUnsafe(m_xf.q, polygonB.m_normals[i], m_polygonB.normals[i]);