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 ...
//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*/)); }
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);
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)); }
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 ...
Float maxY = null; for (int i = 0; i < polygonShape.getVertexCount(); i++) { Vec2 nextVertex = polygonShape.getVertex(i); float x = nextVertex.x; float y = nextVertex.y;
for (int i = 1; i < thePolyShape.getVertexCount(); i++) { aCanvas.drawLine( toPosition(thePolyShape.getVertex(i - 1), theBodyPosition, theRotatedAngle), toPosition(thePolyShape.getVertex(i), theBodyPosition, theRotatedAngle), theBody.isAwake()); toPosition(thePolyShape.getVertex(thePolyShape.getVertexCount() - 1), theBodyPosition, theRotatedAngle), toPosition(thePolyShape.getVertex(0), theBodyPosition, theRotatedAngle), theBody .isAwake());