QObjectPicker - QPickingSettings::TrianglePicking doesn't work with custom mesh



  • Hi,

    I have a custom mesh witch is implemented trough QGeometry -> QGeometryRenderer. In general is a plane from triangles that could be edited.
    My problem is that QObjectPicker doesn't catch the clicking/selections on this plane. Event are not triggered at all.
    I configured QRenderSettings to Qt3DRender::QPickingSettings::TrianglePicking.
    Even when I put AllPicks and FrontAndBackFace still nothing.

    I little mo info for may custom mesh. Here how I configured the Attributes

    _VertexDataBuffer = new Qt3DRender::QBuffer(Qt3DRender::QBuffer::VertexBuffer, this);
    _IndexDataBuffer = new Qt3DRender::QBuffer(Qt3DRender::QBuffer::IndexBuffer, this);
    
    
    // Attributes
    _PositionAttribute = new Qt3DRender::QAttribute();
    _PositionAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
    _PositionAttribute->setBuffer(_VertexDataBuffer);
    _PositionAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float);
    _PositionAttribute->setVertexSize(3);
    _PositionAttribute->setByteOffset(0);
    _PositionAttribute->setByteStride(9 * sizeof(float));
    _PositionAttribute->setCount(_Grid_W * 2);
    _PositionAttribute->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
    
    _NormalAttribute = new Qt3DRender::QAttribute();
    _NormalAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
    _NormalAttribute->setBuffer(_VertexDataBuffer);
    _NormalAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float);
    _NormalAttribute->setVertexSize(3);
    _NormalAttribute->setByteOffset(3 * sizeof(float));
    _NormalAttribute->setByteStride(9 * sizeof(float));
    _NormalAttribute->setCount(_Grid_W * 2);
    _NormalAttribute->setName(Qt3DRender::QAttribute::defaultNormalAttributeName());
    
    _ColorAttribute = new Qt3DRender::QAttribute();
    _ColorAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
    _ColorAttribute->setBuffer(_VertexDataBuffer);
    _ColorAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float);
    _ColorAttribute->setVertexSize(3);
    _ColorAttribute->setByteOffset(6 * sizeof(float));
    _ColorAttribute->setByteStride(9 * sizeof(float));
    _ColorAttribute->setCount(_Grid_W * 2);
    _ColorAttribute->setName(Qt3DRender::QAttribute::defaultColorAttributeName());
    
    _IndexAttribute = new Qt3DRender::QAttribute();
    _IndexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute);
    _IndexAttribute->setBuffer(_IndexDataBuffer);
    _IndexAttribute->setVertexBaseType(Qt3DRender::QAttribute::UnsignedShort);
    _IndexAttribute->setVertexSize(1);
    _IndexAttribute->setByteOffset(0);
    _IndexAttribute->setByteStride(0);
    _IndexAttribute->setCount(_Grid_W * 2 * 3);
    

    Can you help me and tell me what I have to do in order to make this mesh to work normally with QObjectPicker ?
    Thanks.

    P.S. As you can see I am using c++ not QML



  • Never mind the problem was in my code - /I was not counting correctly the vertices :-)/ Everything works as expected .