1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICK3DPARTICLEGRAVITY_H |
5 | #define QQUICK3DPARTICLEGRAVITY_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 <QObject> |
19 | #include <QtQuick3DParticles/private/qquick3dparticleaffector_p.h> |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleGravity : public QQuick3DParticleAffector |
24 | { |
25 | Q_OBJECT |
26 | Q_PROPERTY(float magnitude READ magnitude WRITE setMagnitude NOTIFY magnitudeChanged) |
27 | Q_PROPERTY(QVector3D direction READ direction WRITE setDirection NOTIFY directionChanged) |
28 | QML_NAMED_ELEMENT(Gravity3D) |
29 | QML_ADDED_IN_VERSION(6, 2) |
30 | |
31 | public: |
32 | QQuick3DParticleGravity(QQuick3DNode *parent = nullptr); |
33 | |
34 | float magnitude() const; |
35 | const QVector3D &direction() const; |
36 | |
37 | public Q_SLOTS: |
38 | void setDirection(const QVector3D &direction); |
39 | void setMagnitude(float magnitude); |
40 | |
41 | Q_SIGNALS: |
42 | void magnitudeChanged(); |
43 | void directionChanged(); |
44 | |
45 | protected: |
46 | void affectParticle(const QQuick3DParticleData &sd, QQuick3DParticleDataCurrent *d, float time) override; |
47 | |
48 | private: |
49 | float m_magnitude = 100.0f; |
50 | QVector3D m_direction = {0.0f, -1.0f, 0.0f}; |
51 | QVector3D m_directionNormalized = {0.0f, -1.0f, 0.0f}; |
52 | }; |
53 | |
54 | QT_END_NAMESPACE |
55 | |
56 | #endif // QQUICK3DPARTICLEGRAVITY_H |
57 | |