Qt3DRender::QPointLight Class

class Qt3DRender::QPointLight

Qt 3D 场景中封装点光源对象。更多

头文件: #include <QPointLight>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
在 QML 中: PointLight
继承: Qt3DRender::QAbstractLight
状态:已废弃

属性

公共功能

QPointLight(Qt3DCore::QNode *parent = nullptr)
float constantAttenuation() const
float linearAttenuation() const
float quadraticAttenuation() const

公共插槽

void setConstantAttenuation(float value)
void setLinearAttenuation(float value)
void setQuadraticAttenuation(float value)

信号

void constantAttenuationChanged(float constantAttenuation)
void linearAttenuationChanged(float linearAttenuation)
void quadraticAttenuationChanged(float quadraticAttenuation)

详细说明

点光源是从一个点向所有方向发光的光源。从概念上讲,这类似于标准灯泡发出的光。

点光源使用三个衰减系数来描述光的强度随距离衰减的情况。这些因子可在计算总衰减时一起使用。对于 Qt3D Extras 中的材质,使用了以下公式,其中距离是指光线到被渲染表面的距离:

totalAttenuation = 1.0 / (constantAttenuation + (linearAttenuation * distance) + (quadraticAttenuation * distance * distance));

自定义材质可以选择以不同方式解释这些因素。

属性文档

constantAttenuation : float

指定点光源的恒定衰减。

注: 该属性的确切含义和使用取决于材质的实现。

访问功能:

float constantAttenuation() const
void setConstantAttenuation(float value)

通知信号:

void constantAttenuationChanged(float constantAttenuation)

linearAttenuation : float

指定点光源的线性衰减。

注: 此属性的确切含义和使用取决于材质的实现。

访问功能:

float linearAttenuation() const
void setLinearAttenuation(float value)

通知信号:

void linearAttenuationChanged(float linearAttenuation)

quadraticAttenuation : float

指定点光源的二次衰减。

注: 此属性的确切含义和使用取决于材质的实现。

访问功能:

float quadraticAttenuation() const
void setQuadraticAttenuation(float value)

Notifier 信号:

void quadraticAttenuationChanged(float quadraticAttenuation)

成员函数 文档

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

使用指定的parent 构建一个新的 QPointLight。

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