QT3D中的透明对象 [英] Transparent object in QT3D

查看:30
本文介绍了QT3D中的透明对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够在QT3D中更改网格对象的透明度。我使用Scene3D组件作为根,它包含默认的ForwardRenender。

components: [
    RenderSettings {
        activeFrameGraph: ForwardRenderer {
            clearColor: Qt.rgba(0, 0, 0, 1)
            camera: camera


        }
    },
    // Event Source will be set by the Qt3DQuickWindow
    InputSettings { }
]
我的3D对象由网格、变换和PhongMaterial组成。

如有任何帮助,我们将不胜感激。

推荐答案

代码正常。您可以更改模型以查看效果。完整代码为:

import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Scene3D 2.0
import Qt3D.Core 2.0
import Qt3D.Render 2.0
import Qt3D.Extras 2.0
import Qt3D.Input 2.0 

Teapot{
    x: 0; y:0; z:0;
    material: PhongAlphaMaterial{
        ambient: Qt.rgba( 1, 0, 0, 1.0 )
        diffuse: Qt.rgba( 1, 0, 0, 1.0 )
        specular: Qt.rgba(1, 0, 0, 1.0 )
        shininess: 1.0
        alpha: 0.5
    }
}

茶壶图片

这篇关于QT3D中的透明对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆