1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QQUICK3DPARTICLETARGETDIRECTION_H
5#define QQUICK3DPARTICLETARGETDIRECTION_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 <QVector3D>
19#include <QQmlEngine>
20
21#include <QtQuick3DParticles/private/qquick3dparticledirection_p.h>
22
23QT_BEGIN_NAMESPACE
24
25class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleTargetDirection : public QQuick3DParticleDirection
26{
27 Q_OBJECT
28 Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
29 Q_PROPERTY(QVector3D positionVariation READ positionVariation WRITE setPositionVariation NOTIFY positionVariationChanged)
30 Q_PROPERTY(bool normalized READ normalized WRITE setNormalized NOTIFY normalizedChanged)
31 Q_PROPERTY(float magnitude READ magnitude WRITE setMagnitude NOTIFY magnitudeChanged)
32 Q_PROPERTY(float magnitudeVariation READ magnitudeVariation WRITE setMagnitudeVariation NOTIFY magnitudeChangedVariation)
33 QML_NAMED_ELEMENT(TargetDirection3D)
34 QML_ADDED_IN_VERSION(6, 2)
35
36public:
37 QQuick3DParticleTargetDirection(QObject *parent = nullptr);
38
39 QVector3D position() const;
40 void setPosition(const QVector3D &position);
41 bool normalized() const;
42 float magnitude() const;
43 float magnitudeVariation() const;
44 QVector3D positionVariation() const;
45
46public Q_SLOTS:
47 void setPositionVariation(const QVector3D &positionVariation);
48 void setNormalized(bool normalized);
49 void setMagnitude(float magnitude);
50 void setMagnitudeVariation(float magnitudeVariation);
51
52Q_SIGNALS:
53 void positionChanged();
54 void positionVariationChanged();
55 void normalizedChanged();
56 void magnitudeChanged();
57 void magnitudeChangedVariation();
58
59private:
60 QVector3D sample(const QQuick3DParticleData &d) override;
61 QVector3D m_position;
62 QVector3D m_positionVariation;
63 bool m_normalized = false;
64 float m_magnitude = 1.0f;
65 float m_magnitudeVariation = 0.0f;
66
67};
68
69QT_END_NAMESPACE
70
71#endif // QQUICK3DPARTICLETARGETDIRECTION_H
72

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