我一直在尝试在Qt3D中的网格上进行点和线的拾取。这是三角拾取的工作版本,
auto renderSettings = new Qt3DRender::QRenderSettings(root);
renderSettings->pickingSettings()->setPickMethod(Qt3DRender::QPickingSettings::TrianglePicking);
auto entity = new Qt3DCore::QEntity(root);
auto picker = new Qt3DRender::QObjectPicker;
auto sphere = new Qt3DExtras::QSphereMesh;
entity->addComponent(picker);
entity->addComponent(sphere);
connect(picker, &Qt3DRender::QObjectPicker::clicked, []
(Qt3DRender::QPickEvent* e) {
auto p = dynamic_cast<Qt3DRender::QPickTriangleEvent*>(e);
auto idx = p->triangleIndex();
});
但是,当我切换到点拾取或线拾取时,单击事件永远不会触发。任何想法如何使这项工作?预先感谢。