1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QQUICK3DPARTICLEPOINTROTATOR_H
5#define QQUICK3DPARTICLEPOINTROTATOR_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
21QT_BEGIN_NAMESPACE
22
23class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticlePointRotator : 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 Q_PROPERTY(QVector3D pivotPoint READ pivotPoint WRITE setPivotPoint NOTIFY pivotPointChanged)
29 QML_NAMED_ELEMENT(PointRotator3D)
30 QML_ADDED_IN_VERSION(6, 2)
31
32public:
33 QQuick3DParticlePointRotator(QQuick3DNode *parent = nullptr);
34
35 float magnitude() const;
36 QVector3D direction() const;
37 QVector3D pivotPoint() const;
38
39public Q_SLOTS:
40 void setMagnitude(float magnitude);
41 void setDirection(const QVector3D &direction);
42 void setPivotPoint(const QVector3D &point);
43
44Q_SIGNALS:
45 void magnitudeChanged();
46 void directionChanged();
47 void pivotPointChanged();
48
49protected:
50 void prepareToAffect() override;
51 void affectParticle(const QQuick3DParticleData &sd, QQuick3DParticleDataCurrent *d, float time) override;
52
53private:
54 float m_magnitude = 10.0f;
55 QVector3D m_direction = {0.0f, 1.0f, 0.0f};
56 QVector3D m_directionNormalized = {0.0f, 1.0f, 0.0f};
57 QVector3D m_pivotPoint;
58 QMatrix4x4 m_rotationMatrix;
59};
60
61QT_END_NAMESPACE
62
63#endif // QQUICK3DPARTICLEPOINTROTATOR_H
64

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