/* (non-Javadoc) * @see org.dyn4j.samples.SimulationFrame#initializeWorld() */ @Override protected void initializeWorld() { // no gravity on a top-down view of a billiards game this.world.setGravity(World.ZERO_GRAVITY); // create all your bodies/joints SimulationBody wallr = new SimulationBody(); wallr.addFixture(Geometry.createRectangle(0.2, 10)); wallr.translate(2, 0); wallr.setMass(MassType.INFINITE); world.addBody(wallr); SimulationBody ball1 = new SimulationBody(); ball1.addFixture( Geometry.createCircle(0.028575), // 2.25 in diameter = 0.028575 m radius 217.97925, // 0.126 oz/in^3 = 217.97925 kg/m^3 0.08, 0.9); ball1.translate(-1.0, 0.0); // ball1.setLinearVelocity(5.36448, 0.0); // 12 mph = 5.36448 m/s ball1.setLinearVelocity(2, 0); // so we can see the bouncing ball1.setMass(MassType.NORMAL); this.world.addBody(ball1); SimulationBody ball2 = new SimulationBody(); ball2.addFixture(Geometry.createCircle(0.028575), 217.97925, 0.08, 0.9); ball2.translate(1.0, 0.0); ball2.setMass(MassType.NORMAL); this.world.addBody(ball2); }