I’m building a fairly simple runtime .obj importer, and I’m using FPoly.Triangulate() to convert larger polygons into triangles. It seems to work fairly well, however, even on relatively simple models, it often throws a bunch of “Triangulation of poly failed”.
Is this just a problem with the function or is there something I can do to the model to ensure it doesn’t happen?
(This is my code to convert a polygon to an array of triangles)
TArray<FGeneratedMeshTriangle> AProceduralMeshActor::CreateTrianglesFromVerticeList(TArray<FVector> inVertices)
{
TArray<FGeneratedMeshTriangle> outTriangles;
FPoly newPolygon;
for (int i = 0; i < inVertices.Num(); i++)
{
newPolygon.InsertVertex(i,inVertices[i]);
}
TArray<FPoly> outPolys;
newPolygon.Triangulate(GetWorld()->GetBrush(), outPolys);
for (int i = 0; i < outPolys.Num(); i++)
{
FGeneratedMeshTriangle asTriangle;
asTriangle.Vertex2 = (FVector)outPolys[i].Vertices[0];
asTriangle.Vertex1 = (FVector)outPolys[i].Vertices[1];
asTriangle.Vertex0 = (FVector)outPolys[i].Vertices[2];
outTriangles.Add(asTriangle);
}
return outTriangles;
}