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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| private void iterateContacts() { for (int i = 0; i < collision.getContactCount() - 1; i++) { String nameOfGeom1 = contact.getGeom1().getName(); String nameOfGeom2 = contact.getGeom2().getName();
contact.setIndex(i); if (nameOfGeom1 != null) { PhysicsObject obj = (PhysicsObject) physicsObjects .get(nameOfGeom1); contact.setMode(Ode.dContactBounce | Ode.dContactApprox1); contact.setBounce(obj.getBounce()); contact.setBounceVel(obj.getBounceVelocity()); contact.setMu(Float.MAX_VALUE); }
contact.setIndex(i + 1); if (nameOfGeom2 != null) { PhysicsObject obj = (PhysicsObject) physicsObjects .get(nameOfGeom2); contact.setMode(Ode.dContactBounce | Ode.dContactApprox1); contact.setBounce(obj.getBounce()); contact.setBounceVel(obj.getBounceVelocity()); contact.setMu(Float.MAX_VALUE); } } } |
Thx, DP