1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QQUICK3DPARTICLECUSTOMSHAPE_H
5#define QQUICK3DPARTICLECUSTOMSHAPE_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
20QT_BEGIN_NAMESPACE
21
22class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleCustomShape : public QQuick3DParticleAbstractShape
23{
24 Q_OBJECT
25 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
26 Q_PROPERTY(bool randomizeData READ randomizeData WRITE setRandomizeData NOTIFY randomizeDataChanged)
27 QML_NAMED_ELEMENT(ParticleCustomShape3D)
28 QML_ADDED_IN_VERSION(6, 3)
29public:
30 explicit QQuick3DParticleCustomShape(QObject *parent = nullptr);
31
32 QUrl source() const;
33 bool randomizeData() const;
34
35 // Returns point inside this shape
36 QVector3D getPosition(int particleIndex) override;
37
38public Q_SLOTS:
39 void setSource(const QUrl &source);
40 void setRandomizeData(bool random);
41
42Q_SIGNALS:
43 void sourceChanged();
44 void randomizeDataChanged();
45
46private:
47 void loadFromSource();
48 void doRandomizeData();
49
50 QUrl m_source;
51 bool m_random = false;
52 bool m_randomizeDirty = false;
53 QList<QVector3D> m_positions;
54};
55
56QT_END_NAMESPACE
57
58#endif // QQUICK3DPARTICLECUSTOMSHAPE_H
59

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