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_QSPHEREGEOMETRY_H
5#define QT3DEXTRAS_QSPHEREGEOMETRY_H
6
7#include <Qt3DCore/qgeometry.h>
8#include <Qt3DExtras/qt3dextras_global.h>
9
10QT_BEGIN_NAMESPACE
11
12namespace Qt3DCore {
13
14class QAttribute;
15
16} // Qt3DCore
17
18namespace Qt3DExtras {
19
20class QSphereGeometryPrivate;
21
22class Q_3DEXTRASSHARED_EXPORT QSphereGeometry : public Qt3DCore::QGeometry
23{
24 Q_OBJECT
25 Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged)
26 Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged)
27 Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged)
28 Q_PROPERTY(bool generateTangents READ generateTangents WRITE setGenerateTangents NOTIFY generateTangentsChanged)
29 Q_PROPERTY(Qt3DCore::QAttribute *positionAttribute READ positionAttribute CONSTANT)
30 Q_PROPERTY(Qt3DCore::QAttribute *normalAttribute READ normalAttribute CONSTANT)
31 Q_PROPERTY(Qt3DCore::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT)
32 Q_PROPERTY(Qt3DCore::QAttribute *tangentAttribute READ tangentAttribute CONSTANT)
33 Q_PROPERTY(Qt3DCore::QAttribute *indexAttribute READ indexAttribute CONSTANT)
34
35public:
36 explicit QSphereGeometry(QNode *parent = nullptr);
37 ~QSphereGeometry();
38
39 void updateVertices();
40 void updateIndices();
41
42 bool generateTangents() const;
43 int rings() const;
44 int slices() const;
45 float radius() const;
46
47 Qt3DCore::QAttribute *positionAttribute() const;
48 Qt3DCore::QAttribute *normalAttribute() const;
49 Qt3DCore::QAttribute *texCoordAttribute() const;
50 Qt3DCore::QAttribute *tangentAttribute() const;
51 Qt3DCore::QAttribute *indexAttribute() const;
52
53public Q_SLOTS:
54 void setRings(int rings);
55 void setSlices(int slices);
56 void setRadius(float radius);
57 void setGenerateTangents(bool gen);
58
59Q_SIGNALS:
60 void radiusChanged(float radius);
61 void ringsChanged(int rings);
62 void slicesChanged(int slices);
63 void generateTangentsChanged(bool generateTangents);
64
65protected:
66 QSphereGeometry(QSphereGeometryPrivate &dd, QNode *parent = nullptr);
67
68private:
69 Q_DECLARE_PRIVATE(QSphereGeometry)
70};
71
72} // Qt3DExtras
73
74QT_END_NAMESPACE
75
76#endif // QT3DEXTRAS_QSPHEREGEOMETRY_H
77

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