18#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
19#include <Qt3DRender/QBuffer>
22#include <Qt3DCore/QBuffer>
25#include <Qt3DExtras/QPhongMaterial>
32LineMeshGeometry::LineMeshGeometry( Qt3DCore::QNode *parent )
37 mPositionAttribute->setAttributeType( Qt3DQAttribute::VertexAttribute );
38 mPositionAttribute->setBuffer( mVertexBuffer );
39 mPositionAttribute->setVertexBaseType( Qt3DQAttribute::Float );
40 mPositionAttribute->setVertexSize( 3 );
41 mPositionAttribute->setName( Qt3DQAttribute::defaultPositionAttributeName() );
43 addAttribute( mPositionAttribute );
46void LineMeshGeometry::setVertices(
const QList<QVector3D> &vertices )
48 QByteArray vertexBufferData;
49 vertexBufferData.resize( vertices.size() * 3 *
sizeof(
float ) );
50 float *rawVertexArray =
reinterpret_cast<float *
>( vertexBufferData.data() );
52 for (
const auto &v : vertices )
54 rawVertexArray[idx++] = v.x();
55 rawVertexArray[idx++] = v.y();
56 rawVertexArray[idx++] = v.z();
59 mVertexCount = vertices.count();
60 mVertexBuffer->setData( vertexBufferData );
67AABBMesh::AABBMesh( Qt3DCore::QNode *parent )
70 setInstanceCount( 1 );
72 setFirstInstance( 0 );
73 setPrimitiveType( Qt3DRender::QGeometryRenderer::Lines );
75 mLineMeshGeo =
new LineMeshGeometry(
this );
76 setGeometry( mLineMeshGeo );
79void AABBMesh::setBoxes(
const QList<QgsAABB> &bboxes )
81 QList<QVector3D> vertices;
82 for (
const QgsAABB &bbox : bboxes )
83 vertices << bbox.verticesForLines();
84 mLineMeshGeo->setVertices( vertices );
85 setVertexCount( mLineMeshGeo->vertexCount() );
92QgsChunkBoundsEntity::QgsChunkBoundsEntity( Qt3DCore::QNode *parent )
95 mAabbMesh =
new AABBMesh;
96 addComponent( mAabbMesh );
98 Qt3DExtras::QPhongMaterial *bboxesMaterial =
new Qt3DExtras::QPhongMaterial;
99 bboxesMaterial->setAmbient( Qt::red );
100 addComponent( bboxesMaterial );
103void QgsChunkBoundsEntity::setBoxes(
const QList<QgsAABB> &bboxes )
105 mAabbMesh->setBoxes( bboxes );
Qt3DCore::QAttribute Qt3DQAttribute
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QBuffer Qt3DQBuffer