Java Code Examples for com.badlogic.gdx.physics.box2d.PolygonShape#getVertex()

The following examples show how to use com.badlogic.gdx.physics.box2d.PolygonShape#getVertex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderOfPolyFixture.java    From tilt-game-android with MIT License 6 votes vote down vote up
public RenderOfPolyFixture(Fixture fixture, VertexBufferObjectManager pVBO) {
	super(fixture);

	PolygonShape fixtureShape = (PolygonShape) fixture.getShape();
	int vSize = fixtureShape.getVertexCount();
	float[] xPoints = new float[vSize];
	float[] yPoints = new float[vSize];

	Vector2 vertex = Vector2Pool.obtain();
	for (int i = 0; i < fixtureShape.getVertexCount(); i++) {
		fixtureShape.getVertex(i, vertex);
		xPoints[i] = vertex.x * PhysicsConnector.PIXEL_TO_METER_RATIO_DEFAULT;
		yPoints[i] = vertex.y * PhysicsConnector.PIXEL_TO_METER_RATIO_DEFAULT;
	}
	Vector2Pool.recycle(vertex);

	mEntity = new PolyLine(0, 0, xPoints, yPoints, pVBO);
}
 
Example 2
Source File: BuoyancyController.java    From Codelabs with MIT License 5 votes vote down vote up
private List<Vector2> getFixtureVertices(Fixture fixture) {
	PolygonShape polygon = (PolygonShape) fixture.getShape();
	int verticesCount = polygon.getVertexCount();

	List<Vector2> vertices = new ArrayList<Vector2>(verticesCount);
	for (int i = 0; i < verticesCount; i++) {
		Vector2 vertex = new Vector2();
		polygon.getVertex(i, vertex);
		vertices.add(new Vector2(fixture.getBody().getWorldPoint(vertex)));
	}

	return vertices;
}