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 |
| Since: | Qt 5.9 |
| 實例化: | LevelOfDetail |
| 繼承: | Qt3DCore::QComponent |
| 繼承者: | Qt3DRender::QLevelOfDetailSwitch |
| enum | ThresholdType { DistanceToCameraThreshold, ProjectedScreenPixelSizeThreshold } |
|
|
| QLevelOfDetail (Qt3DCore::QNode * parent = nullptr) | |
| Qt3DRender::QCamera * | camera () const |
| Qt3DRender::QLevelOfDetailBoundingSphere | createBoundingSphere (const QVector3D & center , float radius ) |
| int | currentIndex () const |
| Qt3DRender::QLevelOfDetail::ThresholdType | thresholdType () const |
| QVector<qreal> | thresholds () const |
| Qt3DRender::QLevelOfDetailBoundingSphere | volumeOverride () const |
| void | setCamera (Qt3DRender::QCamera * camera ) |
| void | setCurrentIndex (int currentIndex ) |
| void | setThresholdType (Qt3DRender::QLevelOfDetail::ThresholdType thresholdType ) |
| void | setThresholds (const QVector<qreal> & thresholds ) |
| void | setVolumeOverride (const Qt3DRender::QLevelOfDetailBoundingSphere & volumeOverride ) |
| void | cameraChanged (Qt3DRender::QCamera * camera ) |
| void | currentIndexChanged (int currentIndex ) |
| void | thresholdTypeChanged (Qt3DRender::QLevelOfDetail::ThresholdType thresholdType ) |
| void | thresholdsChanged (const QVector<qreal> & thresholds ) |
| void | volumeOverrideChanged (const Qt3DRender::QLevelOfDetailBoundingSphere & volumeOverride ) |
| const QMetaObject | staticMetaObject |
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 ...
Specifies how the values in the thresholds are interpreted
| 常量 | 值 | 描述 |
|---|---|---|
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. |
Holds the id of the camera that is used to compute the actual distance or the screen size.
訪問函數:
| Qt3DRender::QCamera * | camera () const |
| void | setCamera (Qt3DRender::QCamera * camera ) |
通知程序信號:
| void | cameraChanged (Qt3DRender::QCamera * camera ) |
The index in the range array which matches the current distance to the camera or screen size.
訪問函數:
| int | currentIndex () const |
| void | setCurrentIndex (int currentIndex ) |
通知程序信號:
| void | currentIndexChanged (int currentIndex ) |
Specifies how range values are interpreted.
訪問函數:
| Qt3DRender::QLevelOfDetail::ThresholdType | thresholdType () const |
| void | setThresholdType (Qt3DRender::QLevelOfDetail::ThresholdType thresholdType ) |
通知程序信號:
| void | thresholdTypeChanged (Qt3DRender::QLevelOfDetail::ThresholdType thresholdType ) |
另請參閱 Qt3DRender::QLevelOfDetail::ThresholdType .
Array of range values as float point numbers. The value for the most detailed representation should be specified first.
若 Qt3DRender::QLevelOfDetail::thresholdType 被設為 Qt3DRender::QLevelOfDetail::DistanceToCameraThreshold , values should be specified in ascending order, in camera space coordinates
若 Qt3DRender::QLevelOfDetail::thresholdType 被設為 Qt3DRender::QLevelOfDetail::ProjectedScreenPixelSizeThreshold , values should be specified in descending order, in screen space pixels.
訪問函數:
| QVector<qreal> | thresholds () const |
| void | setThresholds (const QVector<qreal> & thresholds ) |
通知程序信號:
| void | thresholdsChanged (const QVector<qreal> & thresholds ) |
另請參閱 Qt3DRender::QLevelOfDetail::ThresholdType .
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.
訪問函數:
| Qt3DRender::QLevelOfDetailBoundingSphere | volumeOverride () const |
| void | setVolumeOverride (const Qt3DRender::QLevelOfDetailBoundingSphere & volumeOverride ) |
通知程序信號:
| void | volumeOverrideChanged (const Qt3DRender::QLevelOfDetailBoundingSphere & volumeOverride ) |
另請參閱 Qt3DRender::QLevelOfDetailBoundingSphere .
構造新的 QLevelOfDetail 采用指定 parent .
注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .
[slot]
void
QLevelOfDetail::
setCamera
(
Qt3DRender::QCamera
*
camera
)
設置 camera relative to which distance and size are computed.
注意: setter 函數對於特性 camera .
另請參閱 camera ().
[slot]
void
QLevelOfDetail::
setCurrentIndex
(
int
currentIndex
)
設置 currentIndex .
注意: 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.
注意: setter 函數對於特性 currentIndex .
另請參閱 currentIndex ().
[slot]
void
QLevelOfDetail::
setThresholdType
(
Qt3DRender::QLevelOfDetail::ThresholdType
thresholdType
)
Sets the way thresholds values are interpreted with parameter thresholdType
注意: setter 函數對於特性 thresholdType .
另請參閱 thresholdType () 和 Qt3DRender::QLevelOfDetail::ThresholdType .
[slot]
void
QLevelOfDetail::
setThresholds
(const
QVector
<
qreal
> &
thresholds
)
Sets the range values in thresholds .
注意: setter 函數對於特性 thresholds .
另請參閱 thresholds () 和 Qt3DRender::QLevelOfDetail::thresholdType .