Collision Vertice Detection?

Topics: Developer Forum, User Forum
Jan 5, 2010 at 10:09 PM
I know this kind of thing has been asked many times before, and I apoligize for making another thread on the topic, but could someone explain to me how to detect a vertice of a geometry that is colliding with something? Basically, I have a ball, and no matter what it collides with, I want to know which one of it's vertices collides with another object. The end result I'd like to get is a Vector2 position of the vertice, so that I can spawn an object from it (i.e, smoke for graphical friction effects). Could anyone explain to me how to get the data of a vertice on the ball that is colliding with another object, but without the need for knowing what it is colliding with? I just want to know if the vertice is being touched, and if it is, what it's position is. I'm quite new to the Farseer Engine, but I've an intermediate grasp of XNA and C#. Any help would be awesome. Thanks in advance.
Jan 5, 2010 at 11:05 PM

The contacts passed to OnCollision contain a Position property. This won't necessarily correspond to a specific vertex of your ball, but it is the actual point of contact and works just as well for spawning particle effects or whatever.

Jan 5, 2010 at 11:42 PM
Edited Jan 5, 2010 at 11:53 PM
How do I access the Position property of OnCollision? Sorry, but I'm quite a beginner to Farseer. If anyone could provide any example code I'd be very grateful.
Jan 6, 2010 at 9:08 AM

You first need to subscribe to the OnCollision delegate on your Geom instance:


Geom myGeom = GeomFactory.Instance.Create.......;

myGeom.OnCollision += MyOnCollision;


Then you create a method that gets run once the geometry collides:

private bool MyOnCollision(Geom geomA, Geom geomB, ContactList contactList)
 // Here you can access contactList[0].Position