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
21QT_BEGIN_NAMESPACE
22
23class QQuick3DParticleSystem;
24class QQuick3DModel;
25
26class 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
36public:
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
54public Q_SLOTS:
55 void setFill(bool fill);
56 void setType(QQuick3DParticleShape::ShapeType type);
57 void setExtents(QVector3D extends);
58
59Q_SIGNALS:
60 void fillChanged();
61 void typeChanged();
62 void extentsChanged();
63
64private:
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
74QT_END_NAMESPACE
75
76#endif // QQUICK3DPARTICLESHAPE_H
77

source code of qtquick3d/src/quick3dparticles/qquick3dparticleshape_p.h