title: Box2D Body with Texture?
body: <p>I know how to apply sprite to a Box2d body, but is there a way to apply a texture to it? Basically what I am trying to do is to have one texture, let's say 32x32, and then just repeat it all over the body, like the ground in this image:</p>
  <p><img src="https://i.stack.imgur.com/E5uwy.png" alt="enter image description here" /></p>
  <p>Is this possible in LibGDX?</p>
  <p>EDIT:</p>
  <p>My latest try:</p>
  <pre class="lang-java prettyprint-override"><code>Fixture fixture = body.createFixture(fixtureDef);
          Vector2 mTmp = new Vector2();
          PolygonShape shape = (PolygonShape) fixture.getShape();
          int vertexCount = shape.getVertexCount();
          float[] vertices = new float[vertexCount * 2];
          for (int k = 0; k &lt; vertexCount; k++) {
              shape.getVertex(k, mTmp);
              mTmp.rotate(body.getAngle()* MathUtils.radiansToDegrees);
              mTmp.add(body.getPosition()); 
              vertices[k * 2] = mTmp.x * PIXELS_PER_METER;
              vertices[k * 2 + 1] = mTmp.y * PIXELS_PER_METER;
          }
          short triangles[] = new EarClippingTriangulator().computeTriangles(vertices).toArray();
  
          Texture texture = new Texture(Gdx.files.internal(&quot;data/block.png&quot;));
          texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
  
          TextureRegion textureRegion = new TextureRegion(texture, 0, 0, texture.getWidth(), texture.getHeight());
          
          PolygonRegion region = new PolygonRegion(textureRegion, vertices, triangles);
          
          poly = new PolygonSprite(region);
  </code></pre>
  <p>and in rendering:</p>
  <pre><code>polyBatch.begin();
          poly.draw(polyBatch);
          polyBatch.end();
  </code></pre>
  <p>but it doesn't draw anything.</p>
  <p>After importing different shape of level, I get this result:</p>
  <p><img src="https://i.stack.imgur.com/HhZ2e.png" alt="enter image description here" /></p>
  <p>Only one polygon ( shown inside of red circle ) gets the texture. Whole level is imported as a JSON file</p>