'Retrieving the amount of vertices/edges/faces in a QMesh (QT6)

This topic is a copy of the topic I made on the QT Forum (which seems to be less active).


I'm having trouble to count the cells (vertices/edges/faces) of a QMesh, using Qt3DRender in QT6.

Goal : given a Qt3DRender::QMesh, retrieve its amount of vertices, edges and faces.

Example : For a simple cube, I'd like to retrieve 8/12/6

It seems that the vertexCount method of the Qt3DRender::QGeometryRenderer class function is designed for this.

A Qt3DRender::QMesh is a Qt3DRender::QGeometryRenderer so I decided to use vertexCount. Here comes the problem => it always returns 0.

Context when calling vertexCount :

  • The loading state of the QMesh on which I'm calling vertexCount is Qt3DRender::QMesh::Ready
  • I tried to parse the vertices positions of the Qt3DCore::QGeometry associated to the QMesh to count its vertices => it works (that is, the geometry is loaded too)

Questions :

  • What is a "primitive" in the Qt3DRender::QGeometryRenderer terminology? The function vertexCount definition is "holds the primitive count". I assumed that a "primitive" is either a vertex, an edge or a face (since this is what the Qt3DRender::QGeometryRenderer::PrimitiveType enumeration is).

  • Is there any example using this function? I found nothing on the Internet nor in the Qt examples bank.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source