Box2D Forums

It is currently Fri May 24, 2013 9:02 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Mar 13, 2012 12:49 am 
Offline

Joined: Mon Mar 05, 2012 7:18 am
Posts: 25
Location: Sevilla
Is it possible to get the normal of each edge for a Contact List of a colliding dynamic body????


Top
 Profile  
 
PostPosted: Tue Mar 13, 2012 6:21 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
There is no standard method provided to get that. Contacts only have a normal vector showing the quickest way for the two fixtures to be pushed apart, because that is the goal of the collision response.

At least, that would be my answer if I understand your question correctly, but it's not quite clear what you mean... for example in the case below, what is the answer?


Attachments:
normals.png
normals.png [ 13.74 KiB | Viewed 667 times ]
Top
 Profile  
 
PostPosted: Thu Mar 15, 2012 4:01 am 
Offline

Joined: Mon Mar 05, 2012 7:18 am
Posts: 25
Location: Sevilla
Well, in that case, we would get more than one contact point (maybe two) from body->GetContactList(), each contact pertinent to a different edge. I Would like to get the normal vector of each one of those edges.. then find know its orientation and do a calcle to find which faces of our body are colliding.

I thought contact->manifold->localNormal was going to be this normal, but it is not... localNormal from the manifold of a contact doesn't give me the right information, and I dont know how to find the edge's vertex and be able to calcle its normal.


Top
 Profile  
 
PostPosted: Thu Mar 15, 2012 7:47 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
Finding the current position of the vertices can be done like http://www.iforce2d.net/b2dtut/gotchas#getfixturepoints , and then the normal will be just the perpendicular line to each edge. But the real problem is knowing which edges to do this for, and unfortunately I think you are on your own there. You might be able to get some tips from the file b2CollidePolygon.cpp because Box2D needs to do some very similar computation, but it also takes some shortcuts because it doesn't need all the information you are looking for.


Top
 Profile  
 
PostPosted: Fri Mar 16, 2012 3:31 am 
Offline

Joined: Mon Mar 05, 2012 7:18 am
Posts: 25
Location: Sevilla
I see... nah, we will used those sensor fixtures for collision sides, it is working quite well :) but i was wondering if the older method could be done here.

Thanks for all!
P.S: As soon as the game is finished i'll post it somewhere in the forum!!


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

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 2 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:
Powered by phpBB® Forum Software © phpBB Group