This project has moved and is read-only. For the latest updates, please go here.

Solid Polygons

Topics: Developer Forum, User Forum
Oct 10, 2009 at 2:11 AM
Edited Oct 10, 2009 at 2:20 AM


When using Farseer, I need to maintain texture consistency by having a grid inside the polygon. I may not understand all the inner workings of Farseer, but this is what I have tried.

In Demo3, after creation of the polygon from bitmap, I call this function to add vertices to existing ones in a grid-like fashion:

protected Vertices CreateGrid(Vertices Verts)
if (Verts == null || Verts.Count < 3)
return Verts;

            Geom G = new Geom(new Body(), Verts, 1.0f);
            AABB Box = G.AABB;
int GridSize = 25;
for (int iY = 0; iY < Box.Height / GridSize; iY++ )
for (int iX = 0; iX < Box.Width / GridSize; iX++)
                    Vector2 V = new Vector2(iX * GridSize, iY * GridSize) + Box.Min;

            Vector2[] Temp = new Vector2[Verts.Count];
short[] Indices = new short[Verts.Count];

            Vertices.Triangulate(Verts.ToArray(), Vertices.WindingOrder.CounterClockwise, out Temp, out Indices);
            Verts = new Vertices(Temp);
return Verts;

The result displays vertices inside the hole of the polygon, meaning that texture-to-polygon doesn't traverse holes inside bitmaps. Are there any plans to fix this in nearby future?
This isn't the major bug, I may even fix it myself given the time.

Additionally, I need this to work with polygon CSG of Demo7, but it seems that Vertices.Triangulate doesn't seem work when I create rectangle/circle and grid"ify" it. And in general, when adding/removing vertices from the original list and re-indexing it doesn't seem to produce correct results.
Should I use external triangulation libraries to help me with this or does this issue gets addressed in nearby patch?