com.badlogic.gdx.physics.box2d.ChainShape Java Examples

The following examples show how to use com.badlogic.gdx.physics.box2d.ChainShape. 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: Box2dLightTest.java    From box2dlights with Apache License 2.0 6 votes vote down vote up
private void createPhysicsWorld() {

		world = new World(new Vector2(0, 0), true);
		
		float halfWidth = viewportWidth / 2f;
		ChainShape chainShape = new ChainShape();
		chainShape.createLoop(new Vector2[] {
				new Vector2(-halfWidth, 0f),
				new Vector2(halfWidth, 0f),
				new Vector2(halfWidth, viewportHeight),
				new Vector2(-halfWidth, viewportHeight) });
		BodyDef chainBodyDef = new BodyDef();
		chainBodyDef.type = BodyType.StaticBody;
		groundBody = world.createBody(chainBodyDef);
		groundBody.createFixture(chainShape, 0);
		chainShape.dispose();
		createBoxes();
	}
 
Example #2
Source File: Piece.java    From fluid-simulator-v2 with Apache License 2.0 5 votes vote down vote up
public Piece (float radius, BodyType type, boolean isComposite) {
		ChainShape shape = new ChainShape();
//		ArrayList<Vector2> vectors = createArc(0, 0, radius, 180, 360, 0.07f, false);
//		vectors.add(new Vector2(vectors.get(vectors.size() - 1).x - 1, vectors.get(vectors.size() - 1).y));
//		vectors.add(0, new Vector2(vectors.get(0).x+1, vectors.get(0).y));
//		vectors.addAll(createArc(0, 0, radius-1, 0, -180, 0.07f, true));
//		Vector2[] finalVectors = new Vector2[vectors.size()];
//		((ChainShape)shape).createLoop(vectors.toArray(finalVectors));
//		vectors.clear();
//		finalVectors = null;
		this.shape = shape;
		this.pos = new Vector2();
		this.type = type;
	}
 
Example #3
Source File: Piece.java    From fluid-simulator-v2 with Apache License 2.0 5 votes vote down vote up
/** Chain Shape */
public Piece (BodyType type, Vector2... pos) {
	this.shape = new ChainShape();
	((ChainShape)this.shape).createLoop(pos);
	this.pos = null;
	this.type = type;
}
 
Example #4
Source File: Box2DFactory.java    From Codelabs with MIT License 4 votes vote down vote up
public static Shape createChainShape(Vector2[] vertices) {
	ChainShape chainShape = new ChainShape();
	chainShape.createChain(vertices);

	return chainShape;
}