super(id, env, params);
this.distance = radius * distancefactor;
double initialOffset = -1.*gridSize/2. * distance;
DVector3 initialPos = new DVector3(initialOffset, initialOffset, 2.5);
// int bodycounter = 0;
bodyMatrix = new DBody[gridSize][gridSize];
geomMatrix = new DGeom[gridSize][gridSize];
int numberOfJoints = (gridSize)*(gridSize-1) + (gridSize-1)*(gridSize);// + (width-1)*(height-1)*2;
DUniversalJoint[] joints2 = new DUniversalJoint[numberOfJoints];
// place spheres
for (int x = 0; x < gridSize; x++) {
for (int y = 0; y < gridSize; y++) {
bodyMatrix[x][y] = OdeHelper.createBody(env.getWorld());
bodies.add(bodyMatrix[x][y]);
bodyMatrix[x][y].setPosition(initialPos.get0()+x*distance,
initialPos.get1() + y * distance,
initialPos.get2());
DMass mass = OdeHelper.createMass();
mass.setSphereTotal(sphereMass, radius);
masses.add(mass);
bodyMatrix[x][y].setMass(mass);
geomMatrix[x][y] = OdeHelper.createSphere(env.getSpace(),