1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICK3DPARTICLESHAPE_H |
5 | #define QQUICK3DPARTICLESHAPE_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 "qquick3dparticleabstractshape_p.h" |
19 | #include <QVector3D> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class QQuick3DParticleSystem; |
24 | class QQuick3DModel; |
25 | |
26 | class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleShape : public QQuick3DParticleAbstractShape |
27 | { |
28 | Q_OBJECT |
29 | Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged) |
30 | Q_PROPERTY(ShapeType type READ type WRITE setType NOTIFY typeChanged) |
31 | Q_PROPERTY(QVector3D extents READ extents WRITE setExtents NOTIFY extentsChanged) |
32 | |
33 | QML_NAMED_ELEMENT(ParticleShape3D) |
34 | QML_ADDED_IN_VERSION(6, 2) |
35 | |
36 | public: |
37 | enum ShapeType |
38 | { |
39 | Cube = 0, |
40 | Sphere, |
41 | Cylinder |
42 | }; |
43 | Q_ENUM(ShapeType) |
44 | |
45 | QQuick3DParticleShape(QObject *parent = nullptr); |
46 | |
47 | bool fill() const; |
48 | ShapeType type() const; |
49 | QVector3D extents() const; |
50 | |
51 | // Returns point inside this shape |
52 | QVector3D getPosition(int particleIndex) override; |
53 | |
54 | public Q_SLOTS: |
55 | void setFill(bool fill); |
56 | void setType(QQuick3DParticleShape::ShapeType type); |
57 | void setExtents(QVector3D extends); |
58 | |
59 | Q_SIGNALS: |
60 | void fillChanged(); |
61 | void typeChanged(); |
62 | void extentsChanged(); |
63 | |
64 | private: |
65 | QVector3D randomPositionCube(int particleIndex) const; |
66 | QVector3D randomPositionSphere(int particleIndex) const; |
67 | QVector3D randomPositionCylinder(int particleIndex) const; |
68 | |
69 | bool m_fill = true; |
70 | ShapeType m_type = ShapeType::Cube; |
71 | QVector3D m_extents = QVector3D(50, 50, 50); |
72 | }; |
73 | |
74 | QT_END_NAMESPACE |
75 | |
76 | #endif // QQUICK3DPARTICLESHAPE_H |
77 | |