QLevelOfDetail Class
(Qt3DRender::QLevelOfDetail)The QLevelOfDetail class provides a way of controlling the complexity of rendered entities based on their size on the screen. 更多...
头文件: | #include <QLevelOfDetail> |
qmake: | QT += 3drender |
开始支持版本: | Qt 5.9 |
Instantiated By: | LevelOfDetail |
基类: | Qt3DCore::QComponent |
派生类: |
公有类型
enum | ThresholdType { DistanceToCameraThreshold, ProjectedScreenPixelSizeThreshold } |
属性
|
|
- 1 个属性继承自 Qt3DCore::QComponent
- 3 个属性继承自 Qt3DCore::QNode
- 1 个属性继承自 QObject
公有函数
QLevelOfDetail(Qt3DCore::QNode *parent = nullptr) | |
QCamera * | camera() const |
QLevelOfDetailBoundingSphere | createBoundingSphere(const QVector3D ¢er, float radius) |
int | currentIndex() const |
ThresholdType | thresholdType() const |
QVector<qreal> | thresholds() const |
QLevelOfDetailBoundingSphere | volumeOverride() const |
- 2 个公有函数继承自 Qt3DCore::QComponent
- 11 个公有函数继承自 Qt3DCore::QNode
- 32 个公有函数继承自 QObject
公有槽函数
void | setCamera(QCamera *camera) |
void | setCurrentIndex(int currentIndex) |
void | setThresholdType(ThresholdType thresholdType) |
void | setThresholds(const QVector<qreal> &thresholds) |
void | setVolumeOverride(const QLevelOfDetailBoundingSphere &volumeOverride) |
- 1 个公有槽函数继承自 Qt3DCore::QComponent
- 3 个公有槽函数继承自 Qt3DCore::QNode
- 1 个公有槽函数继承自 QObject
信号
void | cameraChanged(QCamera *camera) |
void | currentIndexChanged(int currentIndex) |
void | thresholdTypeChanged(ThresholdType thresholdType) |
void | thresholdsChanged(const QVector<qreal> &thresholds) |
void | volumeOverrideChanged(const QLevelOfDetailBoundingSphere &volumeOverride) |
- 3 个信号继承自 Qt3DCore::QComponent
- 4 个信号继承自 Qt3DCore::QNode
- 2 个信号继承自 QObject
受保护的函数
QLevelOfDetail(QLevelOfDetailPrivate &dd, Qt3DCore::QNode *parent = nullptr) |
- 2 个受保护的函数继承自 Qt3DCore::QNode
- 9 个受保护的函数继承自 QObject
其他继承的成员
详细描述
The QLevelOfDetail class provides a way of controlling the complexity of rendered entities based on their size on the screen.
QLevelOfDetail can be used to control the representation of an entity based on distance from the observer or size on the screen.
In order to improve rendering performance, objects that are very small can be rendered using far fewer details, in geometry or texture.
The component is controlled by specifying thresholds of values which are interpreted as either distances from the camera or screen size.
As the point of view changes, the currentIndex property will change to reflect matching value in the range array.
The currentIndex property can then be used, for example, to enable or disable entities, change material, etc.
The LevelOfDetail component is not shareable between multiple entities.
#include <Qt3DCore/QEntity> #include <Qt3DRender/QGeometryRenderer> #include <Qt3DRender/QLevelOfDetail> // Scene Qt3DCore::QEntity *rootEntity = new Qt3DCore::Qt3DCore::QEntity; Qt3DCore::QEntity *renderableEntity = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QGeometryRenderer *geometryRenderer = new Qt3DCore::QGeometryRenderer(renderableEntity); renderableEntity->addComponent(geometryRenderer); Qt3DRender::QLevelOfDetail* lod = new Qt3Render::QLevelOfDetail(renderableEntity); QVector<qreal> thresholds = {20, 35, 50, 65}; lod->setThresholds(thresholds); lod->setCamera(mainCamera); renderableEntity->addComponent(lod); // connect to QLevelOfDetail::currentIndexChanged to toggle rendering ...
成员类型
enum QLevelOfDetail::ThresholdType
Specifies how the values in the thresholds are interpreted
Constant | Value | Description |
---|---|---|
Qt3DRender::QLevelOfDetail::DistanceToCameraThreshold | 0 | Distance from the entity to the selected camera |
Qt3DRender::QLevelOfDetail::ProjectedScreenPixelSizeThreshold | 1 | Size of the entity when projected on the screen as seen from the selected camera, expressed in number of pixels on the side of the bounding square in screen space. |
属性
camera : Qt3DRender::QCamera *
Holds the id of the camera that is used to compute the actual distance or the screen size.
访问函数:
QCamera * | camera() const |
void | setCamera(QCamera *camera) |
Notifier signal:
void | cameraChanged(QCamera *camera) |
currentIndex : int
The index in the range array which matches the current distance to the camera or screen size.
访问函数:
int | currentIndex() const |
void | setCurrentIndex(int currentIndex) |
Notifier signal:
void | currentIndexChanged(int currentIndex) |
thresholdType : ThresholdType
Specifies how range values are interpreted.
访问函数:
ThresholdType | thresholdType() const |
void | setThresholdType(ThresholdType thresholdType) |
Notifier signal:
void | thresholdTypeChanged(ThresholdType thresholdType) |
参见 Qt3DRender::QLevelOfDetail::ThresholdType.
thresholds : QVector<qreal>
Array of range values as float point numbers. The value for the most detailed representation should be specified first.
If Qt3DRender::QLevelOfDetail::thresholdType is set to Qt3DRender::QLevelOfDetail::DistanceToCameraThreshold, values should be specified in ascending order, in camera space coordinates
If Qt3DRender::QLevelOfDetail::thresholdType is set to Qt3DRender::QLevelOfDetail::ProjectedScreenPixelSizeThreshold, values should be specified in descending order, in screen space pixels.
访问函数:
QVector<qreal> | thresholds() const |
void | setThresholds(const QVector<qreal> &thresholds) |
Notifier signal:
void | thresholdsChanged(const QVector<qreal> &thresholds) |
参见 Qt3DRender::QLevelOfDetail::ThresholdType.
volumeOverride : Qt3DRender::QLevelOfDetailBoundingSphere
The default is a sphere of radius 1 and centered at the local origin of the entity. This proxy volume is used to compute the distance to the camera or the size of the screen projection.
If this value to nullptr, the bounding volume of the entity is used. Care must be taken that this bounding volume never becomes invalid.
访问函数:
QLevelOfDetailBoundingSphere | volumeOverride() const |
void | setVolumeOverride(const QLevelOfDetailBoundingSphere &volumeOverride) |
Notifier signal:
void | volumeOverrideChanged(const QLevelOfDetailBoundingSphere &volumeOverride) |
参见 Qt3dRender::QLevelOfDetailBoundingSphere.
成员函数
QLevelOfDetail::QLevelOfDetail(Qt3DCore::QNode *parent = nullptr)
Constructs a new QLevelOfDetail with the specified parent.
[protected]
QLevelOfDetail::QLevelOfDetail(QLevelOfDetailPrivate &dd, Qt3DCore::QNode *parent = nullptr)
Copy constructor.
QLevelOfDetailBoundingSphere QLevelOfDetail::createBoundingSphere(const QVector3D ¢er, float radius)
[slot]
void QLevelOfDetail::setCamera(QCamera *camera)
Sets the camera relative to which distance and size are computed.
Note: Setter function for property camera.
参见 camera().
[slot]
void QLevelOfDetail::setCurrentIndex(int currentIndex)
Sets the currentIndex.
Note: This should not normally be set by the user.
However, if the component is disabled, then changing the current index is a simple way of switching between multiple representations.
Note: Setter function for property currentIndex.
参见 currentIndex().
[slot]
void QLevelOfDetail::setThresholdType(ThresholdType thresholdType)
Sets the way thresholds values are interpreted with parameter thresholdType
Note: Setter function for property thresholdType.
参见 thresholdType() and Qt3DRender::QLevelOfDetail::ThresholdType.
[slot]
void QLevelOfDetail::setThresholds(const QVector<qreal> &thresholds)
Sets the range values in thresholds.
Note: Setter function for property thresholds.
参见 thresholds() and Qt3DRender::QLevelOfDetail::thresholdType.