本页内容

Qt3DExtras::QDiffuseSpecularMapMaterial Class

class Qt3DExtras::QDiffuseSpecularMapMaterial

QDiffuseSpecularMapMaterial 提供了 Phong 照明效果的默认实现,其中漫反射和镜面反射光成分是从纹理贴图中读取的。更多内容...

头文件: #include <qdiffusespecularmapmaterial.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3dextras)
target_link_libraries(mytarget PRIVATE Qt6::3dextras)
qmake: QT += 3dextras
继承自: Qt3DRender::QMaterial
状态: 已弃用

该类已弃用。我们强烈建议不要在新代码中使用它。

属性

公共函数

QDiffuseSpecularMapMaterial(Qt3DCore::QNode *parent = nullptr)
virtual ~QDiffuseSpecularMapMaterial()
QColor ambient() const
Qt3DRender::QAbstractTexture *diffuse() const
float shininess() const
Qt3DRender::QAbstractTexture *specular() const
float textureScale() const

公共槽位

void setAmbient(const QColor &ambient)
void setDiffuse(Qt3DRender::QAbstractTexture *diffuse)
void setShininess(float shininess)
void setSpecular(Qt3DRender::QAbstractTexture *specular)
void setTextureScale(float textureScale)

信号

void ambientChanged(const QColor &ambient)
void diffuseChanged(Qt3DRender::QAbstractTexture *diffuse)
void shininessChanged(float shininess)
void specularChanged(Qt3DRender::QAbstractTexture *specular)
void textureScaleChanged(float textureScale)

详细说明

该类已弃用;请改用Qt3DExtras::QDiffuseSpecularMaterial 。

镜面反射光效基于环境光、漫反射光和镜面反射光这三个光照成分的组合。这些成分的相对强度通过其反射系数来控制,这些系数被建模为 RGB 三元组:

  • 环境光是指在没有其他光源的情况下,物体所发出的颜色。
  • 漫反射是指粗糙表面在光照下反射出的颜色。
  • 镜面反射是指光线在光亮表面上反射时发出的颜色。
  • 表面的光泽度由一个浮点属性控制。

该材质采用单渲染通道方法,并执行基于片段的照明。提供了适用于 OpenGL 2、OpenGL 3 或更高版本以及 OpenGL ES 2 的技术。

属性文档

ambient : QColor

保存在没有其他光源的情况下,物体发出的当前环境色。

访问函数:

QColor ambient() const
void setAmbient(const QColor &ambient)

通知信号:

void ambientChanged(const QColor &ambient)

diffuse : Qt3DRender::QAbstractTexture*

存储当前的漫反射贴图。

默认情况下,漫反射纹理具有以下属性:

  • 线性缩放和放大滤波器
  • 启用Mipmap的线性Mipmap
  • 循环平铺模式
  • 最大各向异性为 16.0

访问函数:

Qt3DRender::QAbstractTexture *diffuse() const
void setDiffuse(Qt3DRender::QAbstractTexture *diffuse)

通知信号:

void diffuseChanged(Qt3DRender::QAbstractTexture *diffuse)

shininess : float

将当前的光泽度作为浮点数值保存。光泽度数值越高,高光区域越小且越亮。

默认值为 150.0。

访问函数:

float shininess() const
void setShininess(float shininess)

通知器信号:

void shininessChanged(float shininess)

specular : Qt3DRender::QAbstractTexture*

存储当前的高光贴图。

默认情况下,镜面贴图具有以下属性:

  • 线性缩放滤镜
  • 启用Mipmap的线性Mipmap
  • 循环平铺模式
  • 最大各向异性为 16.0

访问函数:

Qt3DRender::QAbstractTexture *specular() const
void setSpecular(Qt3DRender::QAbstractTexture *specular)

通知信号:

void specularChanged(Qt3DRender::QAbstractTexture *specular)

textureScale : float

保存当前的纹理缩放比例。渲染时,该值将作为乘数应用于纹理坐标。默认值为 1.0。

当与 QTextureWrapMode::Repeat 结合使用时,textureScale 提供了一种将纹理平铺到整个表面的简便方法。例如,纹理缩放比例为4.0 时,将生成 16 个(4×4)平铺块。

访问函数:

float textureScale() const
void setTextureScale(float textureScale)

通知器信号:

void textureScaleChanged(float textureScale)

成员函数文档

[explicit] QDiffuseSpecularMapMaterial::QDiffuseSpecularMapMaterial(Qt3DCore::QNode *parent = nullptr)

创建一个新的 QDiffuseSpecularMapMaterial 实例,其父对象为parent 。

[virtual noexcept] QDiffuseSpecularMapMaterial::~QDiffuseSpecularMapMaterial()

销毁该QDiffuseSpecularMapMaterial 实例。

© 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.