How to extract triangles out of mesh geometry
-
I'm creating meshes with
Qt3D. I check if the mesh is actually built with triangles:qDebug() << "mesh primitive type: " << mesh->primitiveType();which returns:
Qt3DRender::QGeometryRenderer::PrimitiveType(Triangles)Therefore, my mesh primitive type is definitely
triangle.
Now I'm trying to access to triangles of the mesh, but I don't know how. There is the following API to get the
dataand itstypewhich can be eitherVertexBufferorIndexBuffer:mesh->geometry()->attributes().at(i)->buffer()->data(); mesh->geometry()->attributes().at(i)->buffer()->type();But I don't know how to extract triangles one-by-one using the above APIs. Can anybody help me.
Eventually, I'm going to export the triangles as STL file with such a format. Is there any API to export mesh as STL? I'm using Qt 5.9.4