贴吧有人想做这个:
可以看出他想要的是一组四棱锥。很规整嘛,决定用三角块拼起来实现,代码如下:
module item(x1,x2,y1,y2,h){
xa=x1>x2?x1:x2;
xi=x2<x1?x2:x1;
ya=y1>y2?y1:y2;
yi=y2<y1?y2:y1;
polyhedron(
points=[
[xa,ya,0],
[xa,yi,0],
[xi,yi,0],
[xi,ya,0], // the four points at base
[0,0,h] // the apex point
],
faces=[
[0,1,4],[1,2,4],[2,3,4],[3,0,4],// each triangle side
[1,0,3],[2,1,3] // two triangles for square base
]
);
}
item(-10,-2,-10,-2,10);
item(-10,-2, 10, 2,10);
item( 10, 2,-10,-2,10);
item( 10, 2, 10, 2,10);