为什么多面体可以很好地渲染,但不能与完整模型结合使用

时间:2019-07-03 08:58:59

标签: rendering openscad

下面的代码是尝试制作一个简单的3d三角形作为较大模型的侧支撑。

它本身可以很好地工作,但是当我将其添加到更大的模型中时,三角形的一侧不会呈现,并且我收到警告。“ UI警告:对象可能不是有效的2流形,可能需要修理!”

更奇怪的是,当我单击“保存”时,将重新绘制模型,并且模型显示完整,缺少一面。

我正在使用OpenScad v.2019.05

我正在通过在它们周围制作一些小对象和hull()来解决此问题。但是,我希望此代码可以工作。

//For some odd reason, this module works well on its own.
//It does does not render correctly when used as part of a larger model.
//Then it will miss a side.
//It shows correctly up when saving though. 

module supportTriangle(height=10, length=10, thickness=10){
    trianglePoints = [
    [ 0, 0, 0 ],
    [ thickness, 0, 0 ],
    [ 0, 0, height ],
    [ thickness, 0, height],
    [ 0, length, 0],
    [ thickness, length, 0]];

    triangleFaces = [
    [ 0, 1, 5, 4 ],
    [ 0, 1, 3, 2 ],
    [ 2, 3, 5, 4 ], 
    [ 0, 4, 2 ],
    [ 1, 3, 5 ]];

    polyhedron(trianglePoints, triangleFaces);

}

我收到以下警告:“ UI警告:对象可能不是有效的2流形,可能需要维修!”与较大模型结合渲染时

1 个答案:

答案 0 :(得分:0)

尝试一下:

module supportTriangle(height=10, length=10, thickness=10){
    trianglePoints = [
    [ 0, 0, 0 ],
    [ thickness, 0, 0 ],
    [ 0, 0, height ],
    [ thickness, 0, height],
    [ 0, length, 0],
    [ thickness, length, 0]];

    triangleFaces = [
    [ 0, 1, 5, 4 ], 
    [ 2,3,1,0], // i reversed these to keep them clockwise 
    [ 4,5,3,2 ], // i reversed these to keep them clockwise 
    [ 0, 4, 2 ],
    [ 1, 3, 5 ]];

    polyhedron(trianglePoints, triangleFaces);

}
supportTriangle(10,10,10);
cube(5,center=true); // just an extra thing to make it error if order is wrong

请参阅: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#polyhedron 所有面都必须具有沿相同方向排列的点。从外部向内看每个面孔时,OpenSCAD倾向于顺时针 。从背面观看背面,从底部观看底部,等等。