Get Collision-Points...

Jan 2, 2010 at 1:46 PM

Hi,

I'm pretty new to the Farseer Physics Engine, so I still have some problems.. The thing I would like to do is to get the actual Contact-/Collision-Points of a Geom-Object. I tried it with the OnCollision()-method, but I don't really understand that one.

So my question: Is there an easy way to get all (that means it does not matter with which other Geom-Object it collides) the actual Contact-Points of a Geom-Object? I am thinking of something like (pseudo):

for (int i=0; i<myGeom.getCollisionPoints().length; i++)
{
    //...
    //check sth. with myGeom.getCollisionPoints().at(i).Normal;
    //...
}

Thanks in advance,

Mark

Coordinator
Jan 2, 2010 at 3:19 PM

The OnCollision delegate does what you want. You need to subscribe to it like this:

myGeom.OnCollision += myOnCollisionCallback;

Then you create the callback that gets called by the delegate:

private bool myOnCollisionCallback(Geom g1, Geom g2, ContatList contacts)
{
}

Inside the contacts variable you have all the contacts generated by the collision. You have the normals and position of the contacts. May I remind you that normals are relative to the creation order of the geometries.

Jan 2, 2010 at 3:36 PM

Great, thank you, this works.

And also thanks for the hint with the normals - this is the next Point I am going to deal with.