QAbstractRayCaster Class

class Qt3DRender::QAbstractRayCaster

An abstract base class for ray casting in 3d scenes. More...

Header: #include <QAbstractRayCaster>
qmake: QT += 3drender
Since: Qt 5.11
Instantiated By: AbstractRayCaster
Inherits: Qt3DCore::QComponent
Inherited By:

Qt3DRender::QRayCaster and Qt3DRender::QScreenRayCaster

This class was introduced in Qt 5.11.

Public Types

enum RunMode { Continuous, SingleShot }

Detailed Description

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.

Note: Components derived from QAbstractRayCaster should not be shared amount multiple entities.

See also Qt3DRender::QRayCaster, Qt3DRender::QScreenRayCaster, Qt3DRender::QObjectPicker, Qt3DRender::QPickingSettings, and Qt3DRender::QNoPicking.

Member Type Documentation

enum QAbstractRayCaster::RunMode

This enumeration specifies how often ray casting is performed

ConstantValueDescription
Qt3DRender::QAbstractRayCaster::Continuous0Ray casting is performed at every frame as long as the component is enabled.
Qt3DRender::QAbstractRayCaster::SingleShot1Ray casting is done once then the component disables itself. This is the default