本页内容

Qt3DExtras::QNormalDiffuseMapMaterial Class

class Qt3DExtras::QNormalDiffuseMapMaterial

QNormalDiffuseMapMaterial 提供了 Phong 光照和凹凸效果的默认实现,其中漫反射光成分从纹理贴图中读取,而待渲染网格的法线则从法线贴图中读取。更多内容...

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

Qt3DExtras::QNormalDiffuseMapAlphaMaterial

状态: 已弃用

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

属性

公共函数

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

公共槽位

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

信号

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

详细说明

该类已弃用;请改用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*

存储当前的漫反射贴图。

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

  • 线性缩放和放大滤镜
  • 启用米普映射的线性米普图
  • 重复环绕模式 M
  • 最大各向异性系数为 16.0

访问函数:

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

通知信号:

void diffuseChanged(Qt3DRender::QAbstractTexture *diffuse)

normal : Qt3DRender::QAbstractTexture*

存储当前的法线贴图纹理。

默认情况下,法线贴图具有以下属性:

  • 线性缩放滤波器
  • 循环平铺模式
  • 最大各向异性值为 16.0

访问函数:

Qt3DRender::QAbstractTexture *normal() const
void setNormal(Qt3DRender::QAbstractTexture *normal)

通知信号:

void normalChanged(Qt3DRender::QAbstractTexture *normal)

shininess : float

将当前的光泽度作为浮点数值保存。

访问函数:

float shininess() const
void setShininess(float shininess)

通知器信号:

void shininessChanged(float shininess)

specular : QColor

存储当前的镜面反射颜色。

访问函数:

QColor specular() const
void setSpecular(const QColor &specular)

通知信号:

void specularChanged(const QColor &specular)

textureScale : float

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

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

访问函数:

float textureScale() const
void setTextureScale(float textureScale)

通知器信号:

void textureScaleChanged(float textureScale)

成员函数文档

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

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

[virtual noexcept] QNormalDiffuseMapMaterial::~QNormalDiffuseMapMaterial()

销毁该QNormalDiffuseMapMaterial 实例。

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