本页内容

Qt3DExtras::QPhongMaterial Class

class Qt3DExtras::QPhongMaterial

QPhongMaterial 类提供了 Phong 光照效果的默认实现。更多内容...

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

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

属性

公共函数

QPhongMaterial(Qt3DCore::QNode *parent = nullptr)
virtual ~QPhongMaterial()
QColor ambient() const
QColor diffuse() const
float shininess() const
QColor specular() const

公共槽位

void setAmbient(const QColor &ambient)
void setDiffuse(const QColor &diffuse)
void setShininess(float shininess)
void setSpecular(const QColor &specular)

信号

void ambientChanged(const QColor &ambient)
void diffuseChanged(const QColor &diffuse)
void shininessChanged(float shininess)
void specularChanged(const QColor &specular)

详细说明

该类已弃用;请改用QDiffuseSpecularMaterial 。

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

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

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

属性文档

ambient : QColor

保存环境颜色。

访问函数:

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

通知信号:

void ambientChanged(const QColor &ambient)

diffuse : QColor

存储漫反射颜色。

访问函数:

QColor diffuse() const
void setDiffuse(const QColor &diffuse)

通知信号:

void diffuseChanged(const QColor &diffuse)

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)

成员函数文档

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

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

[virtual noexcept] QPhongMaterial::~QPhongMaterial()

销毁QPhongMaterial 。

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