• Create Account

We're offering banner ads on our site from just \$5!

#ActualChris528

Posted 13 August 2013 - 09:24 PM

If all faces are convex (they usually are), just turn them into the equivalent of triangle fans, i.e. the first triangle is vertices 0-1-2, the next is 0-2-3, the next 0-3-4, then 0-4-5, and so on.

I was thinking of doing the exact same thing before I asked here but couldn't figure it out, even after working on it for hours.

After messing around with the code a bit this morning I used your suggestion, and finally got a working loop that calculates all the triangles.(even for 32 sided cylinders)

#12Chris528

Posted 13 August 2013 - 05:04 PM

If all faces are convex (they usually are), just turn them into the equivalent of triangle fans, i.e. the first triangle is vertices 0-1-2, the next is 0-2-3, the next 0-3-4, then 0-4-5, and so on.

I was thinking of doing the exact same thing before I asked here but couldn't figure it out, even after working on it for hours.

After messing around with the code a bit this morning I used your suggestion, and finally got a working loop that calculates all the triangles.(even for 32 sided cylinders)

void triangulate(std::vector<Vector3> facePoints, std::vector<Vector3> &faceTriangles)
{
for(int i = 0; (i+2)<facePoints.size(); i++)
{
faceTriangles.push_back(facePoints[0]);
faceTriangles.push_back(facePoints[i+1]);
faceTriangles.push_back(facePoints[i+2]);
}
}


#11Chris528

Posted 13 August 2013 - 04:59 PM

If all faces are convex (they usually are), just turn them into the equivalent of triangle fans, i.e. the first triangle is vertices 0-1-2, the next is 0-2-3, the next 0-3-4, then 0-4-5, and so on.

I was thinking of doing the exact same thing before I asked here but couldn't figure it out, even after working on it for hours.

After messing around with the code a bit this morning I used your suggestion, and finally got a working loop that calculates all the triangles.(even for 32 sided cylinders)

#10Chris528

Posted 13 August 2013 - 04:58 PM

If all faces are convex (they usually are), just turn them into the equivalent of triangle fans, i.e. the first triangle is vertices 0-1-2, the next is 0-2-3, the next 0-3-4, then 0-4-5, and so on.

I was thinking of doing the exact same thing but couldn't figure it out, even after working on it for hours.

After messing around with the code a bit this morning I used your suggestion, and finally got a working loop that calculates all the triangles.(even for 32 sided cylinders)

#9Chris528

Posted 13 August 2013 - 04:58 PM

If all faces are convex (they usually are), just turn them into the equivalent of triangle fans, i.e. the first triangle is vertices 0-1-2, the next is 0-2-3, the next 0-3-4, then 0-4-5, and so on.

I was thinking of doing the exact same thing but couldn't figure it out, even after working on it for hours.

After messing around with the code a bit this morning using your suggestion,I finally got a working loop that calculates all the triangles.(even for 32 sided cylinders)

#8Chris528

Posted 13 August 2013 - 04:58 PM

If all faces are convex (they usually are), just turn them into the equivalent of triangle fans, i.e. the first triangle is vertices 0-1-2, the next is 0-2-3, the next 0-3-4, then 0-4-5, and so on.