处理-透视透明的3D形状

时间:2018-07-12 23:25:31

标签: 3d processing

我希望能够透视透明的3D形状。 例如,这:

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);

}

...显示此:

screenshot1

但是我想要这个:

enter image description here

请注意,我刚刚为第二个添加了hint(DISABLE_DEPTH_TEST)。我想要一个没有这个的解决方案,因为您知道它会禁用深度测试。

1 个答案:

答案 0 :(得分:1)

我建议画一个禁用深度测试的盒子。但是在绘制球体之前启用深度测试:

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); 
}

preview

相关问题