Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 5.15.2 Q3D Object picking does not work on custom geomentry
Forum Updated to NodeBB v4.3 + New Features

Qt 5.15.2 Q3D Object picking does not work on custom geomentry

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 1 Posters 360 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VictorT
    wrote on last edited by
    #1

    Hello everyone
    Yet again I was trying to do something custom in Q3D and faced the following problem.
    I've made a custom geometry following instructions in examples and (actually) modifing the QTorusMesh class from the source.

    Somehow I've managed to draw what I wanted but the object picking functionnality refuses to work properly on my mesh.
    I noticed that if I make geometry to be drawn in reverse order (the slices of my srface would go in oposite direction giving the inverse figure in the end), the picking starts working but not on the whole surface but somewhere in the central area.
    I tryied:

    • changing places of vertex indicies (switching on/off the visibility of the face and doesn't afect picking)
    • changing normal directions (seens to be irrelevant at all)
    • changing tangents (same result)
    • crying and laughing (same result)

    I've read this topic
    https://forum.qt.io/topic/96709/qobjectpicker-qpickingsettings-trianglepicking-doesn-t-work-with-custom-mesh/3
    but it does not seem to be the case.

    I would very like to know how te intersection mechanism works. The code is gigantic amd my best gues is render-backend to look through.

    Thanks for any ideas!

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VictorT
      wrote on last edited by VictorT
      #2

      Ok... now my logic is over....
      I've switched off pickingin all the objects but one and ...

      This way picking works

              Qt3DCore::QTransform *transform = new Qt3DCore::QTransform();
              transform->setScale(4.0f);// this line
              transform->setTranslation(QVector3D(15.0f, -10.0f, 0.0f));
      
              Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial();
              material->setDiffuse(QColor(QRgb(0x665423)));
      
              m_twoCylinderFilletEntity = new Qt3DCore::QEntity(m_rootEntity);
              m_twoCylinderFilletEntity->setObjectName("m_twoCylinderFilletEntity");
              {
                  m_objectPicker = new Qt3DRender::QObjectPicker(m_twoCylinderFilletEntity);
                  m_objectPickers.push_back(m_objectPicker);
                  connect(m_objectPicker,&Qt3DRender::QObjectPicker::clicked,
                          this,&SceneModifier::clickedHandler);
              }
              m_twoCylinderFilletEntity->addComponent(m_twoCylinderFilletMesh);
              m_twoCylinderFilletEntity->addComponent(material);
              m_twoCylinderFilletEntity->addComponent(transform);
              m_twoCylinderFilletEntity->addComponent(m_objectPicker);
      

      This way it DOES NOT

      Qt3DCore::QTransform *transform = new Qt3DCore::QTransform();
              transform->setScale(1.0f);// this line
              transform->setTranslation(QVector3D(15.0f, -10.0f, 0.0f));
      
              Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial();
              material->setDiffuse(QColor(QRgb(0x665423)));
      
              m_twoCylinderFilletEntity = new Qt3DCore::QEntity(m_rootEntity);
              m_twoCylinderFilletEntity->setObjectName("m_twoCylinderFilletEntity");
              {
                  m_objectPicker = new Qt3DRender::QObjectPicker(m_twoCylinderFilletEntity);
                  m_objectPickers.push_back(m_objectPicker);
                  connect(m_objectPicker,&Qt3DRender::QObjectPicker::clicked,
                          this,&SceneModifier::clickedHandler);
              }
              m_twoCylinderFilletEntity->addComponent(m_twoCylinderFilletMesh);
              m_twoCylinderFilletEntity->addComponent(material);
              m_twoCylinderFilletEntity->addComponent(transform);
              m_twoCylinderFilletEntity->addComponent(m_objectPicker);
      

      I specifically duplicated the whole code to show that nothing else but the scale in QTransformation has changed. I just can't get it how scaling can possibly affect intersection calculation....
      Please some one explain me this because I really have no idea what the developers tried to acheive.

      I'm also seriously considering gving out Qt Q3D as my project choice becasuse such unexpected behaviour is very difficult to debug and maintain. The Q3D seems VERY IMMATURE, bug prone and constantly changing from version to version.
      The fron-end/back-end architecture does not give any particular advandages in such situation but obfuscates the source and pulls down the debug process into trial-and-error.

      Probably for some simple projects without some advance (but actually NOT that advanced) geometric processing Q3D is ok. If so I'd like to see complite documentation (and not just for QML which will never be the one and only mean for interface development, Python or Lua in this sence would be better choice as a scripting and configuration mechanism).

      1 Reply Last reply
      0
      • V Offline
        V Offline
        VictorT
        wrote on last edited by
        #3

        I wonder if there is a minimum size for object picking?

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VictorT
          wrote on last edited by
          #4

          I'm back once again. Don't beleave it myself though.
          After a little bit more experimentaion the following knowledge is obtained:

          • this bug is NOT only with custom mesh but with any mesh (even from Qt3DExtras)
          • it seems to have something with bounding volume:
            in the function bool HierarchicalEntityPicker::collectHits(NodeManagers *manager, Entity *root) (pickboundingvolumeutils.cpp)
            line 786 :queryResult = rayCasting.query(m_ray, current.entity->worldBoundingVolume());
            line 787: if (accepted && queryResult.m_distance >= 0.f && (current.hasObjectPicker || !m_objectPickersRequired))
            the if statement is not fullfilled for small volumes. The worldBoundingVolume() returns structure with m_raidious == -1 (but the object being clicked is perfectly fine)

          Maybe developers could spend some time and debug it as they understand what's going on much better than I do.
          Also some workaround for the current Qt 5.15.2 version is appreciated!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved