在本页

Qt3DRender::QRayCasterHit Class

class Qt3DRender::QRayCasterHit

投射射线穿过模型时命中的详细信息。更多

头文件: #include <QRayCasterHit>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
状态:已废弃

公共类型

enum HitType { TriangleHit, LineHit, PointHit, EntityHit }

属性

公共功能

float distance() const
Qt3DCore::QEntity *entity() const
Qt3DCore::QNodeId entityId() const
QVector3D localIntersection() const
uint primitiveIndex() const
Qt3DRender::QRayCasterHit::HitType type() const
uint vertex1Index() const
uint vertex2Index() const
uint vertex3Index() const
QVector3D worldIntersection() const

详细描述

Qt3DRender::QRayCasterHit 包含使用Qt3DRender::QRayCasterQt3DRender::QScreenRayCaster 组件通过模型投射射线时成功命中的详细信息。

另请参阅 Qt3DRender::QRayCaster,Qt3DRender::QScreenRayCaster, 和Qt3DRender::QPickingSettings

成员类型文档

enum QRayCasterHit::HitType

指定返回的命中类型。可通过QPickingSettings 控制。

常量说明
Qt3DRender::QRayCasterHit::TriangleHit0选中的基元是一个三角形,顶点索引指的是构成三角形的三个点
Qt3DRender::QRayCasterHit::LineHit1选中的基元是一条线段,前两个顶点指的是组成该线段的两个点
Qt3DRender::QRayCasterHit::PointHit2选取的基元是一个点;所有 3 个顶点索引都未定义
Qt3DRender::QRayCasterHit::EntityHit3只考虑了边界体积;基元和顶点索引将未定义

属性文档

[read-only] distance : const float

该属性用于保存射线原点与交点之间的距离。

保存从射线原点到射线与实体相交点之间的距离。

访问函数:

float distance() const

[read-only] entity : Qt3DCore::QEntity* const

该属性持有指向被击中实体的指针。

指向被射线击中的 QEntity 的指针。

访问函数:

Qt3DCore::QEntity *entity() const

[read-only] entityId : const Qt3DCore::QNodeId

此属性保存被击中实体的 ID。

保存被射线击中的实体的节点 ID。

访问函数:

Qt3DCore::QNodeId entityId() const

[read-only] localIntersection : const QVector3D

该属性保存交叉点在实体坐标系中的坐标。

在实体的本地坐标系中保存交叉点的坐标。

访问函数:

QVector3D localIntersection() const

[read-only] primitiveIndex : const uint

该属性用于保存选取基元的索引。

保存被选中的基元(三角形、直线或点)的索引。

访问函数:

uint primitiveIndex() const

[read-only] type : const QRayCasterHit::HitType

该属性用于保存命中类型。

保存命中的类型,可以是TriangleHit,LineHit,PointHit, 或EntityHit

访问功能:

Qt3DRender::QRayCasterHit::HitType type() const

[read-only] vertex1Index : const uint

该属性保存选取基元的第一个顶点的索引。

保存选取基元的第一个顶点的索引。对于三角形,这是三个顶点中的一个。如果是直线,则是两个顶点中的一个。

访问函数:

uint vertex1Index() const

[read-only] vertex2Index : const uint

该属性保存选取基元的第二个顶点的索引。

保存选取基元的第二个顶点的索引。对于三角形,这是三个顶点之一。如果是直线,则是两个顶点中的一个。

访问函数:

uint vertex2Index() const

[read-only] vertex3Index : const uint

该属性保存选取基元的第三个顶点的索引。

保存拾取基元的第三个顶点的索引。该属性仅对三角形命中有效。

访问函数:

uint vertex3Index() const

[read-only] worldIntersection : const QVector3D

此属性保存交点在模型坐标系中的坐标。

该属性保存交点在世界坐标系中的坐标。

访问函数:

QVector3D worldIntersection() const

成员函数文档

float QRayCasterHit::distance() const

返回射线原点与交点之间的距离

注: 属性距离的获取函数。

Qt3DCore::QEntity *QRayCasterHit::entity() const

返回指向被击中实体的指针

注: 属性实体的获取函数。

Qt3DCore::QNodeId QRayCasterHit::entityId() const

返回被击中实体的 ID

注: 属性 entityId 的获取函数。

QVector3D QRayCasterHit::localIntersection() const

返回交叉点在实体坐标系中的坐标

注: 属性 localIntersection 的获取函数。

uint QRayCasterHit::primitiveIndex() const

返回选中基元的索引

注: 属性 primitiveIndex 的获取函数。

Qt3DRender::QRayCasterHit::HitType QRayCasterHit::type() const

返回命中的类型

注: 属性类型的获取函数。

uint QRayCasterHit::vertex1Index() const

返回选取基元的第一个顶点的索引

注: 属性 vertex1Index 的获取函数。

uint QRayCasterHit::vertex2Index() const

返回选取基元的第二个顶点的索引

注: 属性 vertex2Index 的获取函数。

uint QRayCasterHit::vertex3Index() const

返回选取基元的第三个顶点的索引

注: 属性 vertex3Index 的获取函数。

QVector3D QRayCasterHit::worldIntersection() const

返回模型坐标系中交点的坐标

注: 属性 worldIntersection 的获取函数。

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