You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
List<int> triangules = new List<int>();
int numPoints = 4;
//var points = new Point2d[numPoints];
//GetPoints(points, points.Length);
var points = new Point2d[]
{
new Point2d(- 1,-1),
new Point2d(1,-1),
new Point2d(1,1),
new Point2d(- 1,1)
};
// A polygon can be composed of multiple contours which are all tessellated at the same time.
var contour = new ContourVertex[numPoints];
for (int i = 0; i < numPoints; i++)
contour[i].Position = new Vec3(points[i].x, points[i].y, 0);
// Create an instance of the tessellator. Can be reused.
var tess = new Tess();
// Add the contour with a specific orientation, use "Original" if you want to keep the input orientation.
tess.AddContour(contour, ContourOrientation.Clockwise);
// The winding rule determines how the different contours are combined together.
// See http://www.glprogramming.com/red/chapter11.html (section "Winding Numbers and Winding Rules") for more information.
// If you want triangles as output, you need to use "Polygons" type as output and 3 vertices per polygon.
tess.Tessellate(WindingRule.EvenOdd, ElementType.Polygons, 3);
int numTriangles = tess.ElementCount;
for (int i = 0; i < numTriangles; i++)
{
var a = tess.Elements[i * 3 + 0];
var b = tess.Elements[i * 3 + 1];
var c = tess.Elements[i * 3 + 2];
Console.WriteLine(a);
Console.WriteLine(b);
Console.WriteLine(c);
triangules.Add(a);
triangules.Add(b);
triangules.Add(c);
}
The text was updated successfully, but these errors were encountered:
I have the same issue (or similar ?). When making a simple Square, it seems to re-order the "Contour" incorrectly.
// correct order
Vector3[]init=new Vector3[]{new Vector3(0f,0f),new Vector3(0f,0.5f),new Vector3(0.5f,0.5f),new Vector3(0.5f,0f),};// wrong order given by tess.Vertices (using CounterClockwise, but Original or Clockwise have the same issue)
Vector3[]init=new Vector3[]{new Vector3(0f,0f),new Vector3(0.5f,0.5f),new Vector3(0.5f,0f),new Vector3(0f,0.5f),};
At first glance we can see that (0.5f, 0.5f) point should never be adjacent with (0f, 0f) point, or we get a diagonal in the square as "Contour".
Strangely, in my particular case, I still end up with a square by using Tess. But when I try to cut that square in two with Clipper2 I end up with very strange results. But results that make sense if I give Clipper2 that bow knot contour instead of a proper square contour.
Failing on simple example. Any help?
Outputs 0,1,2 and 0, 1, 3
The text was updated successfully, but these errors were encountered: