I am very new to the Farseer Physics project and I think it will handle my collision detections needs quite nicely. I have looked but I cant seem to find just a basic tutorial on how to set up a collision detection scheme between two polygons ( in this
case textures that are triangular in shape ) from scratch. Can anyone point me in the direction of where I can find a from the ground up tutorial? I've looked at the Manual it can only help me so much as I tend to understand better by looking through code
and how it works. Any help would be greatly appreciated! Thanks
Dec 15, 2008 at 10:57 AM
All shapes in Farseer Physics are threated like polygons. We have 2 sample packs that you can look at, one of them is the simple samples that teach you the basics such as gravity, collision detection, forces and collision groups.
The other sample pack is a little more advanced, but it has stuff such as texture-to-polygon generator if you need something like that in the future.
Some people think that it's too simple to be true, but creating a polygon is just 3 lines of code (if you don't count the polygon declaration):
Vertices verts =
Body polyBody = BodyFactory.Instance.CreatePolygonBody(PhysicsSimulator, verts, 1);
polyBody.Position = new
Geom polyGeom =
GeomFactory.Instance.CreatePolygonGeom(PhysicsSimulator, polyBody, verts, 0);
The "verts" list should contain all the polygons that make up your shape. Remember that they should be centered around 0, 0