def.frequencyHz = joint.getFrequency();
def.dampingRatio = joint.getDampingRatio();
break;
}
case FRICTION: {
FrictionJointDef def = new FrictionJointDef();
jd = def;
def.localAnchorA.set(pbToVec(joint.getLocalAnchorA()));
def.localAnchorB.set(pbToVec(joint.getLocalAnchorB()));
def.maxForce = joint.getMaxForce();
def.maxTorque = joint.getMaxTorque();
break;
}
case ROPE: {
RopeJointDef def = new RopeJointDef();
jd = def;
def.localAnchorA.set(pbToVec(joint.getLocalAnchorA()));
def.localAnchorB.set(pbToVec(joint.getLocalAnchorB()));
def.maxLength = joint.getMaxLength();
return null;
}
case CONSTANT_VOLUME: {
ConstantVolumeJointDef def = new ConstantVolumeJointDef();
jd = def;
def.dampingRatio = joint.getDampingRatio();
def.frequencyHz = joint.getFrequency();
if (joint.getBodiesCount() != joint.getJointsCount()) {
throw new IllegalArgumentException(
"Constant volume joint must have bodies and joints defined");
}
for (int i = 0; i < joint.getBodiesCount(); i++) {
int body = joint.getBodies(i);
if (!argBodyMap.containsKey(body)) {
throw new IllegalArgumentException("Index " + body + " is not present in the body map");
}
int jointIndex = joint.getJoints(i);
if (!jointMap.containsKey(jointIndex)) {
throw new IllegalArgumentException("Index " + jointIndex
+ " is not present in the joint map");
}
Joint djoint = jointMap.get(jointIndex);
if (!(djoint instanceof DistanceJoint)) {
throw new IllegalArgumentException(
"Joints for constant volume joint must be distance joints");
}
def.addBodyAndJoint(argBodyMap.get(body), (DistanceJoint) djoint);
}
break;
}
case LINE: {
UnsupportedObjectException e =