I have a body with just one fixture attached to it. The shape attached to the fixture is a PolygonShape. For rendering the body, I need access to its vertices' coordinates.
This is what I tried:
Vector2 tmpVector = new Vector2();
Fixture f = body.getFixtureList().get(0);
PolygonShape shape = (PolygonShape)f.getShape();
shape.getVertex(3, tmpVector);
shape.getVertex(2, tmpVector);
shape.getVertex(1, tmpVector);
shape.getVertex(0, tmpVector);
It works when the body is not in contact with other bodies.
The problem is that when the body collides with another body, getFixtureList
returns more than one fixture and this includes those from other bodies.
How do I solve this problem?
All I need to be able to do is access the vertices' positions of the polygon body on the fly.