我需要能够在QT3D中更改网格对象的透明度。我使用Scene3D组件作为根,其中包含默认的ForwardRenderer。
components: [
RenderSettings {
activeFrameGraph: ForwardRenderer {
clearColor: Qt.rgba(0, 0, 0, 1)
camera: camera
}
},
// Event Source will be set by the Qt3DQuickWindow
InputSettings { }
]
我的3D对象由Mesh,Transform和PhongMaterial组成。
非常感谢任何帮助。
答案 0 :(得分:1)
代码没问题。您可以更改模型以查看效果。完整的代码是:
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
}
}
茶壶图片
答案 1 :(得分:0)
Just use PhongAlphaMaterial:
PhongAlphaMaterial{
id: redMaterial
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.4
}