{
BodyDef bd = new BodyDef();
bd.position.set(0.0f, 20.0f);
ground = getWorld().createBody(bd);
EdgeShape shape = new EdgeShape();
FixtureDef sd = new FixtureDef();
sd.shape = shape;
sd.density = 0.0f;
sd.restitution = k_restitution;
// Left vertical
shape.set(new Vec2(-20.0f, -20.0f), new Vec2(-20.0f, 20.0f));
ground.createFixture(sd);
// Right vertical
shape.set(new Vec2(20.0f, -20.0f), new Vec2(20.0f, 20.0f));
ground.createFixture(sd);
// Top horizontal
shape.set(new Vec2(-20.0f, 20.0f), new Vec2(20.0f, 20.0f));
ground.createFixture(sd);
// Bottom horizontal
shape.set(new Vec2(-20.0f, -20.0f), new Vec2(20.0f, -20.0f));
ground.createFixture(sd);
}
{
Transform xf1 = new Transform();
xf1.q.set(0.3524f * MathUtils.PI);
Rot.mulToOutUnsafe(xf1.q, new Vec2(1.0f, 0.0f), xf1.p);
Vec2 vertices[] = new Vec2[3];
vertices[0] = Transform.mul(xf1, new Vec2(-1.0f, 0.0f));
vertices[1] = Transform.mul(xf1, new Vec2(1.0f, 0.0f));
vertices[2] = Transform.mul(xf1, new Vec2(0.0f, 0.5f));
PolygonShape poly1 = new PolygonShape();
poly1.set(vertices, 3);
FixtureDef sd1 = new FixtureDef();
sd1.shape = poly1;
sd1.density = 4.0f;
Transform xf2 = new Transform();
xf2.q.set(-0.3524f * MathUtils.PI);
Rot.mulToOut(xf2.q, new Vec2(-1.0f, 0.0f), xf2.p);
vertices[0] = Transform.mul(xf2, new Vec2(-1.0f, 0.0f));
vertices[1] = Transform.mul(xf2, new Vec2(1.0f, 0.0f));
vertices[2] = Transform.mul(xf2, new Vec2(0.0f, 0.5f));
PolygonShape poly2 = new PolygonShape();
poly2.set(vertices, 3);
FixtureDef sd2 = new FixtureDef();
sd2.shape = poly2;
sd2.density = 2.0f;
BodyDef bd = new BodyDef();
bd.type = BodyType.DYNAMIC;
bd.angularDamping = 5.0f;
bd.linearDamping = 0.1f;
bd.position.set(0.0f, 2.0f);
bd.angle = MathUtils.PI;
bd.allowSleep = false;
m_body = getWorld().createBody(bd);
m_body.createFixture(sd1);
m_body.createFixture(sd2);
}
{
PolygonShape shape = new PolygonShape();
shape.setAsBox(0.5f, 0.5f);
FixtureDef fd = new FixtureDef();
fd.shape = shape;
fd.density = 1.0f;
fd.friction = 0.3f;