1 | // Copyright (C) 2022 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef CAPSULEGEOMETRY_H |
5 | #define CAPSULEGEOMETRY_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QQuick3DGeometry> |
19 | |
20 | QT_BEGIN_NAMESPACE |
21 | |
22 | class CapsuleGeometry : public QQuick3DGeometry |
23 | { |
24 | Q_OBJECT |
25 | QML_NAMED_ELEMENT(CapsuleGeometry) |
26 | Q_PROPERTY(bool enableNormals READ enableNormals WRITE setEnableNormals NOTIFY |
27 | enableNormalsChanged) |
28 | Q_PROPERTY(bool enableUV READ enableUV WRITE setEnableUV NOTIFY enableUVChanged) |
29 | |
30 | Q_PROPERTY(int longitudes READ longitudes WRITE setLongitudes NOTIFY longitudesChanged) |
31 | Q_PROPERTY(int latitudes READ latitudes WRITE setLatitudes NOTIFY latitudesChanged) |
32 | Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) |
33 | Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged) |
34 | Q_PROPERTY(float diameter READ diameter WRITE setDiameter NOTIFY diameterChanged) |
35 | |
36 | public: |
37 | CapsuleGeometry(); |
38 | |
39 | bool enableNormals() const { return m_enableNormals; } |
40 | void setEnableNormals(bool enable); |
41 | |
42 | bool enableUV() const { return m_enableUV; } |
43 | void setEnableUV(bool enable); |
44 | |
45 | int longitudes() const { return m_longitudes; } |
46 | void setLongitudes(int longitudes); |
47 | |
48 | int latitudes() const { return m_latitudes; } |
49 | void setLatitudes(int latitudes); |
50 | |
51 | int rings() const { return m_rings; } |
52 | void setRings(int rings); |
53 | |
54 | float height() const { return m_height; } |
55 | void setHeight(float height); |
56 | |
57 | float diameter() const { return m_diameter; } |
58 | void setDiameter(float diameter); |
59 | |
60 | signals: |
61 | void enableNormalsChanged(); |
62 | void enableUVChanged(); |
63 | void longitudesChanged(); |
64 | void latitudesChanged(); |
65 | void ringsChanged(); |
66 | void heightChanged(); |
67 | void diameterChanged(); |
68 | |
69 | private: |
70 | enum class UvProfile { Fixed, Aspect, Uniform }; |
71 | |
72 | void updateData(); |
73 | |
74 | bool m_enableNormals = true; |
75 | bool m_enableUV = false; |
76 | |
77 | // Number of longitudes, or meridians, distributed by azimuth |
78 | int m_longitudes = 32; |
79 | // Number of latitudes, distributed by inclination. Must be even |
80 | int m_latitudes = 16; |
81 | // Number of sections in cylinder between hemispheres |
82 | int m_rings = 1; |
83 | // Height of the middle cylinder on the y axis, excluding the hemispheres |
84 | float m_height = 100.f; |
85 | // Diameter on the xz plane |
86 | float m_diameter = 100.f; |
87 | UvProfile m_uvProfile = UvProfile::Fixed; |
88 | }; |
89 | |
90 | QT_END_NAMESPACE |
91 | |
92 | #endif |
93 | |