Qt3DRender::QRayCaster Class

class Qt3DRender::QRayCaster

Qt3DRender::QRayCaster 用于在三维世界坐标下执行光线投射测试。更多

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

属性

公共功能

QVector3D direction() const
float length() const
QVector3D origin() const

公共插槽

void setDirection(const QVector3D &direction)
void setLength(float length)
void setOrigin(const QVector3D &origin)
void trigger()
void trigger(const QVector3D &origin, const QVector3D &direction, float length)

信号

void directionChanged(const QVector3D &direction)
void lengthChanged(float length)
void originChanged(const QVector3D &origin)

详细说明

3d 射线由其原点、方向和长度定义。它将受到应用于其所属实体的变换的影响。

只要组件处于启用状态,每帧都将执行光线投射测试。命中属性将根据交点列表进行更新。

另请参阅 QAbstractRayCaster,QScreenRayCaster, 和QNoPicking

属性文档

direction : QVector3D

保存 3D 射线的方向。这应该是一个单位矢量。

访问功能:

QVector3D direction() const
void setDirection(const QVector3D &direction)

通知信号:

void directionChanged(const QVector3D &direction)

length : float

保存 3D 射线的长度。

访问功能:

float length() const
void setLength(float length)

通知信号:

void lengthChanged(float length)

origin : QVector3D

保存三维射线在本地坐标中的原点。

访问功能:

QVector3D origin() const
void setOrigin(const QVector3D &origin)

Notifier 信号:

void originChanged(const QVector3D &origin)

成员函数 文档

[slot] void QRayCaster::setLength(float length)

将射线的长度设置为length

如果该值小于或等于零,则认为射线是无限长的。

注: length 属性的设置函数。

另请参阅 length().

[slot] void QRayCaster::trigger()

使用当前射线启用组件并触发测试的便捷方法。

[slot] void QRayCaster::trigger(const QVector3D &origin, const QVector3D &direction, float length)

方便的方法,用于设置射线细节origin,direction, 和length, 并使组件能够触发测试。

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