Oct 20, 2010 at 4:47 PM
Edited Oct 21, 2010 at 4:14 PM
Hello, farseer noob here.
I'm trying to create a PolygonShape (green terrain) as shown in the video below:
(first vertex is the top left green edge and I add my vertices clockwise until I'm back at the start)
PolygonShape polygonShape = new PolygonShape(vertices); // vertices = 8 x Vector2's
Fixture polygonFixture = body.CreateFixture(polygonShape);
assert failing here in the FPE code:
// Ensure the polygon is convex and the interior
// is to the left of each edge.
for (int i = 0; i < vertices.Count; ++i)
int i1 = i;
int i2 = i + 1 < vertices.Count ? i + 1 : 0;
Vector2 edge = Vertices[i2] - Vertices[i1];
for (int j = 0; j < vertices.Count; ++j)
// Don't check vertices on the current edge.
if (j == i1 || j == i2)
Vector2 r = Vertices[j] - Vertices[i1];
// Your polygon is non-convex (it has an indentation) or
// has colinear edges.
MathUtils.Cross(ref edge, ref r, out s);
Debug.Assert(s > 0.0f); //FAILS HERE
I guess the obvious answer is that my shape is non-convex... if so, how to add a concave shape like in the video?