{
BodyDef bd = new BodyDef();
bd.position.set(0.0f, 0.0f);
ground = getWorld().createBody(bd);
PolygonShape shape = new PolygonShape();
shape.setAsBox(5.0f, 0.5f);
ground.createFixture(shape, 0);
shape.setAsBox(1.0f, 0.2f, new Vec2(0.0f, 4.0f), -0.2f);
ground.createFixture(shape, 0);
shape.setAsBox(1.5f, 0.2f, new Vec2(-1.2f, 5.2f), -1.5f);
ground.createFixture(shape, 0);
shape.setAsBox(0.5f, 50.0f, new Vec2(5.0f, 0.0f), 0.0f);
ground.createFixture(shape, 0);
shape.setAsBox(0.5f, 3.0f, new Vec2(-8.0f, 0.0f), 0.0f);
ground.createFixture(shape, 0);
shape.setAsBox(2.0f, 0.1f, new Vec2(-6.0f, -2.8f), 0.1f);
ground.createFixture(shape, 0);
CircleShape cd = new CircleShape();
cd.m_radius = 0.5f;
cd.m_p.set(-0.5f, -4.0f);
ground.createFixture(cd, 0);
}
liquid = new Body[nParticles];
float massPerParticle = totalMass / nParticles;
// PointDef pd = new PointDef();
// pd.mass = massPerParticle;
// pd.restitution = 0.0f;
// pd.filter.groupIndex = -10;
CircleShape pd = new CircleShape();
FixtureDef fd = new FixtureDef();
fd.shape = pd;
fd.density = 1f;
fd.filter.groupIndex = -10;
pd.m_radius = .05f;
fd.restitution = 0.4f;
fd.friction = 0.0f;
float cx = 0.0f;
float cy = 25.0f;
for (int i = 0; i < nParticles; ++i) {
BodyDef bd = new BodyDef();
bd.position =
new Vec2(MathUtils.randomFloat(cx - boxWidth * .5f, cx + boxWidth * .5f),
MathUtils.randomFloat(cy - boxHeight * .5f, cy + boxHeight * .5f));
bd.fixedRotation = true;
bd.type = BodyType.DYNAMIC;
Body b = getWorld().createBody(bd);
b.createFixture(fd).setUserData(LIQUID_INT);
MassData md = new MassData();
md.mass = massPerParticle;
md.I = 1.0f;
b.setMassData(md);
b.setSleepingAllowed(false);
liquid[i] = b;
}
PolygonShape polyDef = new PolygonShape();
polyDef.setAsBox(MathUtils.randomFloat(0.3f, 0.7f), MathUtils.randomFloat(0.3f, 0.7f));
BodyDef bodyDef = new BodyDef();
bodyDef.position = new Vec2(0.0f, 25.0f);
bodyDef.type = BodyType.DYNAMIC;
bod = getWorld().createBody(bodyDef);
bod.createFixture(polyDef, 1f);