[英]Processing - See through transparent 3D shapes
I would like to be able to see through transparent 3D shapes. 我希望能够透过透明的3D形状看到。 For example, this: 例如,这个:
void setup() {
size(400, 400, P3D);
}
void draw() {
clear();
translate(width/2, height/2, -width/2);
stroke(255);
fill(0, 255, 255, 100);
box(width);
noStroke();
lights();
fill(255);
sphere(100);
}
...displays this: ...显示这个:
but I want this: 但我想要这个:
Note that I just added hint(DISABLE_DEPTH_TEST)
for the second one. 请注意,我刚为第二个添加了hint(DISABLE_DEPTH_TEST)
。 I would like a solution without this because, you know, it disables the depth test. 我想要一个没有这个的解决方案因为,你知道,它会禁用深度测试。
I recommend to draw the box with disabled depth test. 我建议使用禁用深度测试绘制框。 But enable the depth test before the sphere is drawn: 但是在绘制球体之前启用深度测试:
void draw() {
clear();
translate(width/2, height/2, -width/2);
hint(DISABLE_DEPTH_TEST);
stroke(255);
fill(0, 255, 255, 100);
box(width);
hint(ENABLE_DEPTH_TEST);
noStroke();
lights();
fill(255);
sphere(100);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.