用于在 3D 场景中,投射光线的抽象基类。 更多...
头: | #include <QAbstractRayCaster> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender) |
qmake: | QT += 3drender |
实例化: | AbstractRayCaster |
继承: | Qt3DCore::QComponent |
继承者: |
enum | FilterMode { AcceptAnyMatchingLayers, AcceptAllMatchingLayers, DiscardAnyMatchingLayers, DiscardAllMatchingLayers } |
enum | RunMode { Continuous, SingleShot } |
void | addLayer (Qt3DRender::QLayer * layer ) |
Qt3DRender::QAbstractRayCaster::FilterMode | filterMode () const |
Qt3DRender::QAbstractRayCaster::Hits | hits () const |
QList<Qt3DRender::QLayer *> | layers () const |
void | removeLayer (Qt3DRender::QLayer * layer ) |
Qt3DRender::QAbstractRayCaster::RunMode | runMode () const |
void | setFilterMode (Qt3DRender::QAbstractRayCaster::FilterMode filterMode ) |
void | setRunMode (Qt3DRender::QAbstractRayCaster::RunMode runMode ) |
void | filterModeChanged (Qt3DRender::QAbstractRayCaster::FilterMode filterMode ) |
void | hitsChanged (const Qt3DRender::QAbstractRayCaster::Hits & hits ) |
void | runModeChanged (Qt3DRender::QAbstractRayCaster::RunMode runMode ) |
Qt3DRender::QAbstractRayCaster is an abstract base class for casting rays into a 3d scene. Qt3DRender::QAbstractRayCaster can not be directly instantiated, but rather through its subclasses. QAbstractRayCaster specifies common properties for all ray casters, such as run mode and layer handling, while leaving the actual ray casting details to the subclasses.
Ray castings differs from picking (using Qt3DRender::QObjectPicker ) in that it does not require mouse events to trigger.
By default, the instances of Qt3DRender::QAbstractRayCaster are disabled. When enabled, the specified ray will be tested for intersecting objects at every frame. The QAbstractRayCaster::hits property will be updated with the results of the ray casting, even if no objects are found.
The Qt3DRender::QPickingSettings can be used to control the ray casting, such as which primitives are tested and how the results are returned.
Furthermore, Qt3DRender::QLayer components can be used to control how entities, or entity sub-graphs, react to ray casting.
注意: Components derived from QAbstractRayCaster should not be shared amount multiple entities.
另请参阅 Qt3DRender::QRayCaster , Qt3DRender::QScreenRayCaster , Qt3DRender::QObjectPicker , Qt3DRender::QPickingSettings ,和 Qt3DRender::QNoPicking .
Specifies the rules for selecting entities to test for raycasting.
常量 | 值 | 描述 |
---|---|---|
Qt3DRender::QAbstractRayCaster::AcceptAnyMatchingLayers
|
0
|
Accept entities that reference one or more QLayer objects added to this QAbstractRayCaster . This is the default |
Qt3DRender::QAbstractRayCaster::AcceptAllMatchingLayers
|
1
|
Accept entities that reference all the QLayer objects added to this QAbstractRayCaster |
Qt3DRender::QAbstractRayCaster::DiscardAnyMatchingLayers
|
2
|
Discard entities that reference one or more QLayer objects added to this QAbstractRayCaster |
Qt3DRender::QAbstractRayCaster::DiscardAllMatchingLayers
|
3
|
Discard entities that reference all QLayer objects added to this QAbstractRayCaster |
This enumeration specifies how often ray casting is performed
常量 | 值 | 描述 |
---|---|---|
Qt3DRender::QAbstractRayCaster::Continuous
|
0
|
Ray casting is performed at every frame as long as the component is enabled. |
Qt3DRender::QAbstractRayCaster::SingleShot
|
1
|
Ray casting is done once then the component disables itself. This is the default |
Holds the filter mode specifying the entities to select for ray casting tests.
The default value is AcceptMatchingLayers.
访问函数:
Qt3DRender::QAbstractRayCaster::FilterMode | filterMode () const |
void | setFilterMode (Qt3DRender::QAbstractRayCaster::FilterMode filterMode ) |
通知程序信号:
void | filterModeChanged (Qt3DRender::QAbstractRayCaster::FilterMode filterMode ) |
[read-only]
hits
: const
Hits
Holds the results of last ray casting test as a vector of Qt3DRender::QRayCasterHit 实例。
Note that even if successive tests return the exact same results (or empty results), a change notification will be emitted at every test.
访问函数:
Qt3DRender::QAbstractRayCaster::Hits | hits () const |
通知程序信号:
void | hitsChanged (const Qt3DRender::QAbstractRayCaster::Hits & hits ) |
Holds the run mode controlling how often ray casting tests are performed.
若设为 SingleShot (the default), when the component is enabled, a single ray casting test will be performed and the component will automatically disable itself.
If set to Continuous, ray casting tests will be performed at every frame as long as the component is enabled.
访问函数:
Qt3DRender::QAbstractRayCaster::RunMode | runMode () const |
void | setRunMode (Qt3DRender::QAbstractRayCaster::RunMode runMode ) |
通知程序信号:
void | runModeChanged (Qt3DRender::QAbstractRayCaster::RunMode runMode ) |
添加 layer to the current list of layers
Returns the current list of layers
移除 layer from the current list of layers