QGIS API Documentation 4.1.0-Master (9af12b5a203)
Loading...
Searching...
No Matches
qgschunkboundsentity_p.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgschunkboundsentity_p.cpp
3 --------------------------------------
4 Date : July 2017
5 Copyright : (C) 2017 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include "qgs3dwiredmesh_p.h"
19#include "qgsaabb.h"
20#include "qgsbox3d.h"
21#include "qgsgeotransform.h"
22#include "qgsphongmaterial.h"
23
24#include <Qt3DExtras/QPhongMaterial>
25
26#include "moc_qgschunkboundsentity_p.cpp"
27
29
30QgsChunkBoundsEntity::QgsChunkBoundsEntity( const QgsVector3D &vertexDataOrigin, Qt3DCore::QNode *parent )
31 : Qt3DCore::QEntity( parent )
32 , mVertexDataOrigin( vertexDataOrigin )
33{
34 mAabbMesh = new Qgs3DWiredMesh;
35 addComponent( mAabbMesh );
36
37 auto *bboxesMaterial = new QgsPhongMaterial();
38 bboxesMaterial->setAmbient( Qt::red );
39 bboxesMaterial->setCastsShadows( false );
40 addComponent( bboxesMaterial );
41
42 QgsGeoTransform *transform = new QgsGeoTransform;
43 transform->setGeoTranslation( mVertexDataOrigin );
44 addComponent( transform );
45}
46
47void QgsChunkBoundsEntity::setBoxes( const QList<QgsBox3D> &bboxes )
48{
49 QList<QgsAABB> aabbBoxes;
50 for ( const QgsBox3D &box : bboxes )
51 {
52 aabbBoxes << QgsAABB::fromBox3D( box, mVertexDataOrigin );
53 }
54 mAabbMesh->setVertices( aabbBoxes );
55}
56
static QgsAABB fromBox3D(const QgsBox3D &box3D, const QgsVector3D &origin)
Constructs bounding box from QgsBox3D by subtracting origin 3D vector.
Definition qgsaabb.h:46
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:45
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:33