1// Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DEXTRAS_QCUBOIDGEOMETRY_H
5#define QT3DEXTRAS_QCUBOIDGEOMETRY_H
6
7#include <Qt3DExtras/qt3dextras_global.h>
8#include <Qt3DCore/qgeometry.h>
9#include <QtCore/QSize>
10
11QT_BEGIN_NAMESPACE
12
13namespace Qt3DCore {
14
15class QAttribute;
16
17} // Qt3DCore
18
19namespace Qt3DExtras {
20
21class QCuboidGeometryPrivate;
22
23class Q_3DEXTRASSHARED_EXPORT QCuboidGeometry : public Qt3DCore::QGeometry
24{
25 Q_OBJECT
26 Q_PROPERTY(float xExtent READ xExtent WRITE setXExtent NOTIFY xExtentChanged)
27 Q_PROPERTY(float yExtent READ yExtent WRITE setYExtent NOTIFY yExtentChanged)
28 Q_PROPERTY(float zExtent READ zExtent WRITE setZExtent NOTIFY zExtentChanged)
29 Q_PROPERTY(QSize xyMeshResolution READ xyMeshResolution WRITE setXYMeshResolution NOTIFY xyMeshResolutionChanged)
30 Q_PROPERTY(QSize yzMeshResolution READ yzMeshResolution WRITE setYZMeshResolution NOTIFY yzMeshResolutionChanged)
31 Q_PROPERTY(QSize xzMeshResolution READ xzMeshResolution WRITE setXZMeshResolution NOTIFY xzMeshResolutionChanged)
32 Q_PROPERTY(Qt3DCore::QAttribute *positionAttribute READ positionAttribute CONSTANT)
33 Q_PROPERTY(Qt3DCore::QAttribute *normalAttribute READ normalAttribute CONSTANT)
34 Q_PROPERTY(Qt3DCore::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT)
35 Q_PROPERTY(Qt3DCore::QAttribute *tangentAttribute READ tangentAttribute CONSTANT)
36 Q_PROPERTY(Qt3DCore::QAttribute *indexAttribute READ indexAttribute CONSTANT)
37
38public:
39 explicit QCuboidGeometry(QNode *parent = nullptr);
40 ~QCuboidGeometry();
41
42 void updateIndices();
43 void updateVertices();
44
45 float xExtent() const;
46 float yExtent() const;
47 float zExtent() const;
48 QSize yzMeshResolution() const;
49 QSize xyMeshResolution() const;
50 QSize xzMeshResolution() const;
51
52 Qt3DCore::QAttribute *positionAttribute() const;
53 Qt3DCore::QAttribute *normalAttribute() const;
54 Qt3DCore::QAttribute *texCoordAttribute() const;
55 Qt3DCore::QAttribute *tangentAttribute() const;
56 Qt3DCore::QAttribute *indexAttribute() const;
57
58public Q_SLOTS:
59 void setXExtent(float xExtent);
60 void setYExtent(float yExtent);
61 void setZExtent(float zExtent);
62 void setYZMeshResolution(const QSize &resolution);
63 void setXZMeshResolution(const QSize &resolution);
64 void setXYMeshResolution(const QSize &resolution);
65
66Q_SIGNALS:
67 void xExtentChanged(float xExtent);
68 void yExtentChanged(float yExtent);
69 void zExtentChanged(float zExtent);
70
71 void yzMeshResolutionChanged(const QSize &yzMeshResolution);
72 void xzMeshResolutionChanged(const QSize &xzMeshResolution);
73 void xyMeshResolutionChanged(const QSize &xyMeshResolution);
74
75protected:
76 QCuboidGeometry(QCuboidGeometryPrivate &dd, QNode *parent = nullptr);
77
78private:
79 Q_DECLARE_PRIVATE(QCuboidGeometry)
80};
81
82} // Qt3DExtras
83
84QT_END_NAMESPACE
85
86#endif // QT3DEXTRAS_QCUBOIDGEOMETRY_H
87

source code of qt3d/src/extras/geometries/qcuboidgeometry.h