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