lo,
Is this the right way to iterate the contacts and set the friction and bounce factors?
here is the code, please ignore all the PhysicsObject…etc code, its just a holding place for data.
private void iterateContacts() {
for (int i = 0; i < collision.getContactCount() - 1; i++) {
// obtain the names of the contacts that
// have collided
String nameOfGeom1 = contact.getGeom1().getName();
String nameOfGeom2 = contact.getGeom2().getName();
// set the index
contact.setIndex(i);
if (nameOfGeom1 != null) {
// get the PhysicsObject
PhysicsObject obj = (PhysicsObject) physicsObjects
.get(nameOfGeom1);
// apply the contact information
contact.setMode(Ode.dContactBounce | Ode.dContactApprox1);
contact.setBounce(obj.getBounce());
contact.setBounceVel(obj.getBounceVelocity());
contact.setMu(Float.MAX_VALUE);
}
// set the index
contact.setIndex(i + 1);
if (nameOfGeom2 != null) {
// get the PhysicsObject
PhysicsObject obj = (PhysicsObject) physicsObjects
.get(nameOfGeom2);
// apply the contact information
contact.setMode(Ode.dContactBounce | Ode.dContactApprox1);
contact.setBounce(obj.getBounce());
contact.setBounceVel(obj.getBounceVelocity());
contact.setMu(Float.MAX_VALUE);
}
}
}
Thx, DP