Search code examples
3d-modelling3d-modelopenscad

How can I get a polyhedron to fill in faces properly in OpenSCAD?


I'm new to OpenSCAD. I'm trying to create a basic triangular wedge which is going to be part of a larger component. But I'm already running into trouble. Using the following code I get the points in the correct spots; however, it seems the faces are kind of "bent inward." In other words the faces of the polyhedron don't fill in all the way.

polyhedron(
    points = [
        [-0.3, 0.15, 0],
        [-0.4, 0.15, 0],
        [-0.3, 0.6, 0],
        [-0.4, 0.6, 0],
        [-0.3, 0.15, -0.7],
        [-0.4, 0.15, -0.7]
    ],
    faces = [
        [0,1,2,3],
        [2,3,4,5],
        [1,3,5],
        [0,2,4],
        [0,1,4,5]
    ]
);

Here are some screenshots from different angles to illustrate what I mean by "bent inward":

angle #1 angle #2 angle #3

What have I done wrong?


Solution

  • look here: openscad documentation polyhedron

    Point ordering for faces When looking at the face from the outside inwards, the points must be clockwise.

    you can highlight wrong oreintated faces

    correct faces e.g.:

    faces = [
            [1,3,2,0],
            [2,3,5,4],
            [1,5,3],
            [0,2,4],
            [0,4,5,1]
        ]