18#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
19#include <Qt3DRender/QAttribute>
20#include <Qt3DRender/QGeometry>
25#include <Qt3DCore/QAttribute>
26#include <Qt3DCore/QGeometry>
37Qgs3DWiredMesh::Qgs3DWiredMesh( Qt3DCore::QNode *parent )
42 mPositionAttribute->setAttributeType( Qt3DQAttribute::VertexAttribute );
43 mPositionAttribute->setBuffer( mVertexBuffer );
44 mPositionAttribute->setVertexBaseType( Qt3DQAttribute::Float );
45 mPositionAttribute->setVertexSize( 3 );
46 mPositionAttribute->setName( Qt3DQAttribute::defaultPositionAttributeName() );
49 mGeom->addAttribute( mPositionAttribute );
51 setInstanceCount( 1 );
53 setFirstInstance( 0 );
54 setPrimitiveType( Qt3DRender::QGeometryRenderer::Lines );
58Qgs3DWiredMesh::~Qgs3DWiredMesh() =
default;
60void Qgs3DWiredMesh::setVertices(
const QList<QVector3D> &vertices )
62 QByteArray vertexBufferData;
63 vertexBufferData.resize(
static_cast<int>(
static_cast<long>( vertices.size() ) * 3 *
sizeof(
float ) ) );
64 float *rawVertexArray =
reinterpret_cast<float *
>( vertexBufferData.data() );
66 for (
const QVector3D &v : std::as_const( vertices ) )
68 rawVertexArray[idx++] = v.x();
69 rawVertexArray[idx++] = v.y();
70 rawVertexArray[idx++] = v.z();
73 mVertexBuffer->setData( vertexBufferData );
74 setVertexCount( vertices.count() );
77void Qgs3DWiredMesh::setVertices(
const QList<QgsAABB> &bboxes )
79 QList<QVector3D> vertices;
80 for (
const QgsAABB &bbox : bboxes )
81 vertices << bbox.verticesForLines();
83 setVertices( vertices );
Qt3DCore::QAttribute Qt3DQAttribute
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QAttribute Qt3DQAttribute
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QGeometry Qt3DQGeometry