【问题标题】:Processing - See through transparent 3D shapes处理 - 透视透明 3D 形状
【发布时间】:2018-11-14 10:38:50
【问题描述】:

我希望能够看穿透明的 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);

}

...显示这个:

但我想要这个:

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

【问题讨论】:

    标签: 3d processing


    【解决方案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); 
    }
    

    【讨论】:

    • 您知道这是处理的预期行为,还是解决错误的方法?这也适用于 2 个形状,但如果场景有数百个形状怎么办?
    猜你喜欢
    • 2011-05-28
    • 1970-01-01
    • 1970-01-01
    • 2013-10-07
    • 1970-01-01
    • 2014-02-14
    • 2021-03-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多