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#include <QVector3D>
20
21QT_BEGIN_NAMESPACE
22
23class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleCustomShape : public QQuick3DParticleAbstractShape
24{
25 Q_OBJECT
26 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
27 Q_PROPERTY(bool randomizeData READ randomizeData WRITE setRandomizeData NOTIFY randomizeDataChanged)
28 QML_NAMED_ELEMENT(ParticleCustomShape3D)
29 QML_ADDED_IN_VERSION(6, 3)
30public:
31 explicit QQuick3DParticleCustomShape(QObject *parent = nullptr);
32
33 QUrl source() const;
34 bool randomizeData() const;
35
36 // Returns point inside this shape
37 QVector3D getPosition(int particleIndex) override;
38 Q_REVISION(6, 10) QVector3D getSurfaceNormal(int particleIndex) override;
39
40public Q_SLOTS:
41 void setSource(const QUrl &source);
42 void setRandomizeData(bool random);
43
44Q_SIGNALS:
45 void sourceChanged();
46 void randomizeDataChanged();
47
48private:
49 void loadFromSource();
50 void doRandomizeData();
51
52 QUrl m_source;
53 bool m_random = false;
54 bool m_randomizeDirty = false;
55 QList<QVector3D> m_positions;
56 QVector3D m_center;
57};
58
59QT_END_NAMESPACE
60
61#endif // QQUICK3DPARTICLECUSTOMSHAPE_H
62

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