I try to get the position attribute of a mesh using the following code
....code...
Qt3DRender::QMesh *mesh = new Qt3DRender::QMesh();
mesh->setMeshName("mesh");
// Import mesh data from a ply file (monster.ply located at same level of the executable)
mesh
->setSource
(QUrl::fromLocalFile("monster.ply"));
// The call to mesh->geometry() crashes my app
if (mesh->primitiveType() == Qt3DRender::QGeometryRenderer::Triangles)
{
for(int i = 0; i < mesh->geometry()->attributes().size(); ++i)
{
// To have access to data
mesh->geometry()->attributes().at(i)->buffer()->setSyncData(true);
}
// Now I need to get the position of the vertices of the triangles
Qt3DRender::QAttribute *positionAttribute = mesh->geometry()->attributes().at(0);
...more code...
}
....code...
Qt3DRender::QMesh *mesh = new Qt3DRender::QMesh();
mesh->setMeshName("mesh");
// Import mesh data from a ply file (monster.ply located at same level of the executable)
mesh->setSource(QUrl::fromLocalFile("monster.ply"));
// The call to mesh->geometry() crashes my app
if (mesh->primitiveType() == Qt3DRender::QGeometryRenderer::Triangles)
{
for(int i = 0; i < mesh->geometry()->attributes().size(); ++i)
{
// To have access to data
mesh->geometry()->attributes().at(i)->buffer()->setSyncData(true);
}
// Now I need to get the position of the vertices of the triangles
Qt3DRender::QAttribute *positionAttribute = mesh->geometry()->attributes().at(0);
...more code...
}
To copy to clipboard, switch view to plain text mode
This is the content of the qmake script
QT += 3dcore 3drender 3dinput 3dextras
QT += widgets
SOURCES += main.cpp
QT += 3dcore 3drender 3dinput 3dextras
QT += widgets
SOURCES += main.cpp
To copy to clipboard, switch view to plain text mode
I am using Qt5 LTS version.
Am I forgetting some plugins or am I doing something wrong?
I don't understand why I am getting such runtime error.
Franco
Bookmarks