int jointCounter = 0;
// attach vertical constraints
for (int x = 0; x < width; x++) {
for (int y = 0; y < height - 1; y++) {
DBallJoint joint = joints[jointCounter];
joint = OdeHelper.createBallJoint(env.getWorld());
joint.attach(bodyMatrix[x][y],bodyMatrix[x][y + 1]);
joint.setParam(DJoint.PARAM_N.dParamCFM1, cfmAng1);
joint.setParam(DJoint.PARAM_N.dParamERP1, erpAng1);
joint.setParam(DJoint.PARAM_N.dParamFMax1, fmaxAng1);
jointCounter++;
}
}
//
// attach horizontal constraints
for (int x = 0; x < width - 1; x++) {
for (int y = 0; y < height; y++) {
DBallJoint joint = joints[jointCounter];
joint = OdeHelper.createBallJoint(env.getWorld());
joint.attach(bodyMatrix[x][y],bodyMatrix[x + 1][y]);
joint.setParam(DJoint.PARAM_N.dParamCFM1, cfmAng1);
joint.setParam(DJoint.PARAM_N.dParamERP1, erpAng1);
joint.setParam(DJoint.PARAM_N.dParamFMax1, fmaxAng1);
jointCounter++;
}
}
// attach diagonal constraints
for (int x = 0; x < width - 1; x++) {
for (int y = 0; y < height - 1; y++) {
DBallJoint joint = joints[jointCounter];
joint = OdeHelper.createBallJoint(env.getWorld());
joint.attach(bodyMatrix[x][y],bodyMatrix[x + 1][y + 1]);
joint.setParam(DJoint.PARAM_N.dParamCFM1, cfmAng1);
joint.setParam(DJoint.PARAM_N.dParamERP1, erpAng1);
joint.setParam(DJoint.PARAM_N.dParamFMax1, fmaxAng1);
jointCounter++;
}
}
////
// attach diagonal constraints
for (int x = 0; x < width-1; x++) {
for (int y = 0; y < height - 1; y++) {
DBallJoint joint = joints[jointCounter];
joint = OdeHelper.createBallJoint(env.getWorld());
joint.attach(bodyMatrix[x+1][y],bodyMatrix[x][y + 1]);
joint.setParam(DJoint.PARAM_N.dParamCFM1, cfmAng1);
joint.setParam(DJoint.PARAM_N.dParamERP1, erpAng1);
joint.setParam(DJoint.PARAM_N.dParamFMax1, fmaxAng1);
jointCounter++;
}
}
}