首页 > 解决方案 > 为什么Polyhedron单独渲染效果好,结合完整模型不行

问题描述

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

它本身运行良好,但是当我将它添加到更大的模型时,三角形的一侧不会呈现,并且我收到“UI-WARNING:对象可能不是有效的 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-WARNING:对象可能不是有效的 2 歧管,可能需要修复!”的警告。结合更大的模型进行渲染时

标签: renderingopenscad

解决方案


尝试这个:

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 更喜欢顺时针方向。背面是从后面看,从底部看底部等等。


推荐阅读