首页 > 解决方案 > 如何在 Qt3D 中优化点云渲染

问题描述

我正在尝试使用 Qt3D 显示大型点云(~20M pts)。

我首先发现了这个库https://github.com/MASKOR/Qt3DPointcloudRenderer这是一个很好的例子,但是我重写了一个极简的例子来加载一个特定的 LAS 或 PCD 点云并用Qt3DRender::QGeometry.

它有效,点云很好,但滞后很多。我认为没有优化,一直显示所有20M点。

我能做些什么来优化这个?

(相同的点云在同一台笔记本电脑上与 QuickTerrainReader、Pix4D 甚至 VTK 等其他软件一起使用。)

目前,在加载时,点云被序列化为 2 Qt3DRender::QBuffer,我从那里创建了 2 个属性:

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);

标签: c++qtpointqt3d

解决方案


推荐阅读