Face vertex order in custom polyhedron

Hi everyone-

I have been using CreatePolyhedron to make shapes and I was under the impression that the vertex order in a face did not matter as long as I wen in the correct order around the perimeter.

But in this example the faces with 6 vertices render differently when I use [0,1,2,3,4,5] order and [1,2,3,4,5,0] order.

Any ideas as to why?



I’m not sure why you’re under the impression that the vertex order doesn’t matter, but it looks to me like the shape in the playground is not a polyhedron? Maybe you should use CreatePolygon, instead?

@bghgary and @sebavan say it IS a polyhedron, so don’t listen to me :slight_smile:

I looked into this more deeply and I’m seeing that CreatePolyhedron triangulates the faces using the first index given for the face as the first point in each triangle in the face. So, the assumption that vertex order doesn’t matter only holds if the face is convex. If the face is concave, like in your playground, then the order definitely matters, and there are some concave shapes that aren’t even possible to achieve with CreatePolyhedron.

I think my original suggestion of using CreatePolygon for each face and then combining the resulting meshes is maybe the best solution for concave faces.

cc’ing our geometry expert @Evgeni_Popov to fact-check this for us.

The order is important because the triangles are created like this:

If face=[f0,f1,f2,f3,f4]
Triangles=(f0,f2,f1), (f0,f3,f2), (f0,f4,f3)

Now, if face=[f1,f2,f3,f4,f0]
Triangles=(f1,f3,f2), (f1,f4,f3), (f1,f0,f4) which are not the same triangles than above.


Got it. So it looks like CreatePolyhedron not going to work, especially if I want to create steps of arbitrary length. Using CreatePolygon and extruding it works fine:

Thanks, doc and Evgeni!

@PatrickRyan I wonder if this would be a good doc candidate as well ?

1 Like