Qt3DExtras::QDiffuseSpecularMaterial Class
class Qt3DExtras::QDiffuseSpecularMaterialQDiffuseSpecularMaterial 类提供了 Phong 照明效果的默认实现。更多内容...
| 头文件: | #include <qdiffusespecularmaterial.h> |
| 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 三元组的形式建模:
- 环境光是指物体在没有其他光源的情况下发出的颜色。
- 漫反射是指物体表面在光线照射下产生粗糙反射时发出的颜色。
- 镜面反射是指光线在光滑表面上反射时呈现的颜色。
- 表面的光泽度由一个浮点属性控制。
该材质采用单渲染通道的方法,并执行基于片段的照明计算。提供了适用于 OpenGL 2、OpenGL 3 或更高版本以及 OpenGL ES 2 的技术实现。
属性文档
alphaBlending : bool
指示在渲染过程中是否考虑来自“漫反射”属性的透明度信息。默认值为 false。
访问函数:
| bool | isAlphaBlendingEnabled() const |
| void | setAlphaBlendingEnabled(bool enabled) |
通知器信号:
| 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) |
通知器信号:
| void | textureScaleChanged(float textureScale) |
成员函数文档
[explicit] QDiffuseSpecularMaterial::QDiffuseSpecularMaterial(Qt3DCore::QNode *parent = nullptr)
创建一个新的 QDiffuseSpecularMaterial 实例,其父对象为parent 。
[virtual noexcept] QDiffuseSpecularMaterial::~QDiffuseSpecularMaterial()
销毁“QDiffuseSpecularMaterial ”。
© 2026 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.