I'm trying to display large point clouds (~20M pts) with Qt3D.
I first found this library https://github.com/MASKOR/Qt3DPointcloudRenderer which is a good example, but I rewrote a minimalist example to load a specific LAS or PCD point cloud and display it with a subclass of Qt3DRender::QGeometry
.
It works and the point cloud is nice, but it lags a lot. I think there is no optimization and all 20M points are displayed all the time.
What can I do to optimize this?
(The same point clouds is fluid on the same laptop with other softwares such as QuickTerrainReader, Pix4D or even VTK.)
Currently, at loading, the point cloud is serialized into 2 Qt3DRender::QBuffer
, and I create 2 attributes from there:
Qt3DRender::QAttribute* vertexAttrib = new Qt3DRender::QAttribute(nullptr);
vertexAttrib->setName(Qt3DRender::QAttribute::defaultPositionAttributeName());
vertexAttrib->setVertexBaseType(Qt3DRender::QAttribute::Float);
vertexAttrib->setVertexSize(3);
vertexAttrib->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
vertexAttrib->setBuffer(m_vertexBuffer);
vertexAttrib->setByteStride(12);
vertexAttrib->setByteOffset(0);
vertexAttrib->setCount(m_pointcloud->size());
addAttribute(vertexAttrib);
setBoundingVolumePositionAttribute(vertexAttrib);
t3DRender::QAttribute* colorAttrib = new Qt3DRender::QAttribute(nullptr);
colorAttrib->setName(Qt3DRender::QAttribute::defaultColorAttributeName());
colorAttrib->setVertexBaseType(Qt3DRender::QAttribute::UnsignedByte);
colorAttrib->setVertexSize(3);
colorAttrib->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
colorAttrib->setBuffer(m_colorBuffer);
colorAttrib->setByteStride(3);
colorAttrib->setByteOffset(0);
colorAttrib->setCount(m_pointcloud->size());
addAttribute(colorAttrib);