Qt3DExtras::QDiffuseSpecularMaterial Class
class Qt3DExtras::QDiffuseSpecularMaterialQDiffuseSpecularMaterial 类提供了 phong 灯光效果的默认实现。更多
Header: | #include <QDiffuseSpecularMaterial> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS 3dextras) target_link_libraries(mytarget PRIVATE Qt6::3dextras) |
qmake: | QT += 3dextras |
在 QML 中: | DiffuseSpecularMaterial |
继承: | Qt3DRender::QMaterial |
状态: | 已废弃 |
属性
|
|
公共功能
QDiffuseSpecularMaterial(Qt3DCore::QNode *parent = nullptr) | |
virtual | ~QDiffuseSpecularMaterial() |
QColor | ambient() const |
QVariant | diffuse() const |
bool | isAlphaBlendingEnabled() const |
QVariant | normal() const |
float | shininess() const |
QVariant | specular() const |
float | textureScale() const |
公共插槽
void | setAlphaBlendingEnabled(bool enabled) |
void | setAmbient(const QColor &ambient) |
void | setDiffuse(const QVariant &diffuse) |
void | setNormal(const QVariant &normal) |
void | setShininess(float shininess) |
void | setSpecular(const QVariant &specular) |
void | setTextureScale(float textureScale) |
信号
void | alphaBlendingEnabledChanged(bool enabled) |
void | ambientChanged(const QColor &ambient) |
void | diffuseChanged(const QVariant &diffuse) |
void | normalChanged(const QVariant &normal) |
void | shininessChanged(float shininess) |
void | specularChanged(const QVariant &specular) |
void | textureScaleChanged(float textureScale) |
详细说明
phong 灯光效果基于环境、漫反射和镜面三种照明成分的组合。这些成分的相对强度由它们的反射系数控制,反射系数以 RGB 三元组建模:
- 环境光是物体在没有任何其他光源的情况下发出的颜色。
- 漫反射(Diffuse)是灯光在物体表面反射时发出的颜色。
- 镜面反射色是在灯光照射下闪亮表面反射时发出的颜色。
- 表面的光泽度由浮点属性控制。
该材质采用了单次渲染通过的效果方法,并对每个片段进行照明。该技术适用于 OpenGL 2、OpenGL 3 或更高版本以及 OpenGL ES 2。
属性文档
alphaBlending : bool
表示在渲染过程中是否会考虑来自漫反射属性的 alpha 信息。默认为 false。
访问函数:
bool | isAlphaBlendingEnabled() const |
void | setAlphaBlendingEnabled(bool enabled) |
Notifier 信号:
void | alphaBlendingEnabledChanged(bool enabled) |
ambient : QColor
保存物体在没有其他光源的情况下发出的环境色。
访问功能:
QColor | ambient() const |
void | setAmbient(const QColor &ambient) |
通知信号:
void | ambientChanged(const QColor &ambient) |
diffuse : QVariant
用于保存材质的漫反射颜色,该颜色会在灯光的粗糙表面反射时发出。可以是纯色值或纹理。
访问功能:
QVariant | diffuse() const |
void | setDiffuse(const QVariant &diffuse) |
通知信号:
void | diffuseChanged(const QVariant &diffuse) |
normal : QVariant
当前材质的法线贴图纹理。该贴图只能是纹理,否则将被忽略。默认情况下不设置此贴图。
访问功能:
QVariant | normal() const |
void | setNormal(const QVariant &normal) |
通知信号:
void | normalChanged(const QVariant &normal) |
shininess : float
表示光泽度指数。光泽度值越高,高光部分越小越亮。
默认值为 150.0。
访问功能:
float | shininess() const |
void | setShininess(float shininess) |
通知信号:
void | shininessChanged(float shininess) |
specular : QVariant
用于保存材质的镜面反射颜色,通过灯光反射出闪亮的表面。可以是纯色值或纹理。
访问功能:
QVariant | specular() const |
void | setSpecular(const QVariant &specular) |
通知信号:
void | specularChanged(const QVariant &specular) |
textureScale : float
保存当前的纹理比例。它会在渲染时作为一个乘数应用到纹理坐标上。默认值为 1.0。
当与 QTextureWrapMode::Repeat 结合使用时,textureScale 提供了一种在表面上平铺纹理的简单方法。例如,如果纹理比例为4.0
,则会产生 16 个(4x4)平铺。
访问函数
float | textureScale() const |
void | setTextureScale(float textureScale) |
Notifier 信号:
void | textureScaleChanged(float textureScale) |
成员函数文档
[explicit]
QDiffuseSpecularMaterial::QDiffuseSpecularMaterial(Qt3DCore::QNode *parent = nullptr)
使用父对象parent 构建一个新的 QDiffuseSpecularMaterial 实例。
[virtual noexcept]
QDiffuseSpecularMaterial::~QDiffuseSpecularMaterial()
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.