`QMesh` index buffer stride is 0

32 Views Asked by At

I'm trying to load a triangulated .obj file using Qt3D's QMesh loader, like so:

auto *mesh = new Qt3DRender::QMesh();
mesh->setSource(path);

connect(
  mesh,
  &Qt3DRender::QMesh::statusChanged,
  [this, mesh](Qt3DRender::QMesh::Status status) {
    if (status != Qt3DRender::QMesh::Ready) {
      return;
    }

    auto *geometry = mesh->geometry();
    auto *v_attrib = findGeometryAttribute(geometry, Qt3DCore::QAttribute::VertexAttribute);
    auto *i_attrib = findGeometryAttribute(geometry, Qt3DCore::QAttribute::IndexAttribute);

    qDebug() << "vert: count:" << v_attrib->count() << "offset:" << v_attrib->byteOffset() << "stride:" << v_attrib->byteStride();
    qDebug() << "indx: count:" << i_attrib->count() << "offset:" << i_attrib->byteOffset() << "stride:" << i_attrib->byteStride();
});

The results are as follows:

vert: count: 1089 offset: 0 stride: 48
indx: count: 6144 offset: 0 stride: 0

Without knowing the stride, it's very difficult to find the correct data in the buffer, and it might differ depending on the machine. I'm wondering if Qt3D is just not loading the mesh in a triangulated manner (although the blender exported .obj file is triangulated).

Does anyone know if the stride is guaranteed to be a particular number?

0

There are 0 best solutions below