Box2D Forums

It is currently Thu May 23, 2013 10:14 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Three point collision
PostPosted: Sat Jan 28, 2012 12:03 pm 
Offline

Joined: Sat Jan 28, 2012 11:13 am
Posts: 6
Hello. I have posted this elsewhere but I haven't had any feedback from this. I was hoping posting here to the Box2d experts may provide greater enlightenment

I am using a contact listener to work out when two fixtures collide. This is working as expected.

What I am attempting to do is flag up if three objects collide. An example of this would be only flag a collision if three tiles are touching each other in some sort of 'chain'. I am unsure the best way of doing this and wanted to ask if there is already a standard approach.

Is it possible to simply check if an object is touching anything else? I have looked through the API but can't seem to find anything. If this is possible I could recursively loop through each of the 'collided/connected' objects and notice a three point collision if I end up recursing through three objects.

Thank you


Top
 Profile  
 
PostPosted: Sun Jan 29, 2012 1:45 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
As well as the contact listener which tells you when contacts start and end, you can get a list of the current contacts for each body at any time with GetContactList to do something like what you are talking about. Just remember to also check that the contact really IsTouching.
Check the section "9.3 Accessing Contacts" in the manual, this page might be helpful too:
http://www.iforce2d.net/b2dtut/collision-anatomy


Top
 Profile  
 
PostPosted: Sun Feb 12, 2012 4:41 am 
Offline

Joined: Sat Jan 28, 2012 11:13 am
Posts: 6
This was a great help. Thank you. I wrote a recursive method that loops through each of the collided bodies until it found one with three touching parts.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group