How to make a triangle list with ONLY and array of vertices.

Hey all,

So I’m learning the basics of mesh slicing (merely as a skillset I will want to include in something at somepoint down the line…)

I’ve read an article on the Sutherland-Hodgman clipping plane, and I’m starting to implement it into a test scene (slicing a ‘brick’).

However, one thing the article didn’t include (or I just missed it) was how to close up the faces of the meshes that are left when they are separated.

In other words, I split the cube, split the triangles that are ‘sliced’ into new triangles. But the new ‘face’ that’s generated has no triangles.

Now it’s fine if I KNOW it’s a cube that I’m slicing. However when I slice objects with ‘n’ number of vertices along the edges of the slice, how do I work out the triangles for this?

I was thinking of using a triangle fan, but didn’t know if the following methodology would work.

  1. pick a random start point vertex. Also set as point A
  2. Find the closest other vertex to point A and set it as point B.
  3. Find next closest point ignoring A. When found set as C.
  4. Set Triangle coords into mesh triangle array
    %) Set point C as B, and look for next closest vert ignoring previous ones used.
    [Loop back to 3 and repeat as needed]
  5. if only 2 nearest are either A or previous then we’re done.

This makes a really simple logical sense (to me at least) but I’m worried about all these distance checks. Is there another way?

P.S. Just so that you know, This last week I’ve brushed up and learnt a lot of maths to understand the Sutherland/Hodgman system, so I’m happy to go away and study a subject :wink:

There is a handy triangulator script on the wiki that I use. Never bothered to figure out why it works, but it does a decent job.