17#include "moc_qgs3dwiredmesh_p.cpp"
19#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
20#include <Qt3DRender/QAttribute>
21#include <Qt3DRender/QGeometry>
26#include <Qt3DCore/QAttribute>
27#include <Qt3DCore/QGeometry>
38Qgs3DWiredMesh::Qgs3DWiredMesh( Qt3DCore::QNode *parent )
43 mPositionAttribute->setAttributeType( Qt3DQAttribute::VertexAttribute );
44 mPositionAttribute->setBuffer( mVertexBuffer );
45 mPositionAttribute->setVertexBaseType( Qt3DQAttribute::Float );
46 mPositionAttribute->setVertexSize( 3 );
47 mPositionAttribute->setName( Qt3DQAttribute::defaultPositionAttributeName() );
50 mGeom->addAttribute( mPositionAttribute );
52 setInstanceCount( 1 );
54 setFirstInstance( 0 );
55 setPrimitiveType( Qt3DRender::QGeometryRenderer::Lines );
59Qgs3DWiredMesh::~Qgs3DWiredMesh() =
default;
61void Qgs3DWiredMesh::setVertices(
const QList<QVector3D> &vertices )
63 QByteArray vertexBufferData;
64 vertexBufferData.resize(
static_cast<int>(
static_cast<long>( vertices.size() ) * 3 *
sizeof(
float ) ) );
65 float *rawVertexArray =
reinterpret_cast<float *
>( vertexBufferData.data() );
67 for (
const QVector3D &v : std::as_const( vertices ) )
69 rawVertexArray[idx++] = v.x();
70 rawVertexArray[idx++] = v.y();
71 rawVertexArray[idx++] = v.z();
74 mVertexBuffer->setData( vertexBufferData );
75 setVertexCount( vertices.count() );
78void Qgs3DWiredMesh::setVertices(
const QList<QgsAABB> &bboxes )
80 QList<QVector3D> vertices;
81 for (
const QgsAABB &bbox : bboxes )
82 vertices << bbox.verticesForLines();
84 setVertices( vertices );
Qt3DCore::QAttribute Qt3DQAttribute
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QAttribute Qt3DQAttribute
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QGeometry Qt3DQGeometry