How to detect collisions

22 views
Skip to first unread message

Pierre LABATUT

unread,
Aug 18, 2010, 2:59:27 PM8/18/10
to jinn...@googlegroups.com
Hi,

  I use jinngine.physics.DefaultScene, an I wonder what is the right way to be enumerate object collisions.
I don't want to process the result of the broad phase, but I want to detect contact.

Is it ContactConstraintManager.addHandler ?

--
Pierre LABATUT

mo

unread,
Aug 18, 2010, 3:32:51 PM8/18/10
to jinngine
You can use a trigger, like this


scene.addTrigger(new ContactTrigger(box, 2.0, new Callback(){
@Override
public void contactAboveThreshold(Body interactingBody,
ContactConstraint constraint) {
System.out.println("In contact with " + interactingBody );
}
@Override
public void contactBelowThreshold(Body interactingBody,
ContactConstraint constraint) {
System.out.println("No longer in contact with " +
interactingBody );
}
}));



I just made an example illustrating this. Update both jinngine and
jinngine.examples to make it work. Hope that is what you need :)

Pierre LABATUT

unread,
Aug 18, 2010, 6:04:28 PM8/18/10
to jinn...@googlegroups.com
Thanks, that worked as expected.

   I have written my own ContactTrigger to monitor almost everything.
   With a micro threshold I'm able to detect collisions.

--
Pierre LABATUT
Reply all
Reply to author
Forward
0 new messages