2

I've been trying to do point and line picking on a mesh in Qt3D. Here's a working version of triangle picking,

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();
});

However, when I switched to point picking or line picking, the clicked event is never triggered. Any idea how to make this work? Thanks in advance.

unclejimbo
  • 91
  • 7
  • Are you clicking on points and lines when setting a different pick method? I'm assuming that the picker doesn't trigger when you click inside of a triangle. Also, when altering the pick method you should adjust your lambda, as it casts the pick event to `QPickTriangleEvent`. – Florian Blume Oct 24 '18 at 07:21
  • @FlorianBlume Yes, I'm picking on the points and lines. And yes, I've correctly cast the event type. – unclejimbo Oct 24 '18 at 08:14
  • I tried an example myself and can't get it to work either. The test in the [test repository](https://github.com/qt/qt3d/tree/5.11/tests/manual) doesn't cover this type of picking, so maybe it's a bug. I'd suggest you file a bug report and see what response you get. – Florian Blume Oct 25 '18 at 14:20
  • @FlorianBlume Thank you. I've also tried to pick triangles for a custom mesh which doesn't work either. No idea how to configure this based on the documentation Qt provides. – unclejimbo Oct 25 '18 at 14:58
  • That's weird because that definitely worked for me in a project. I'll have a look at my setup. – Florian Blume Oct 29 '18 at 11:41

0 Answers0