1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QQUICK3DPARTICLESPRITESEQUENCE_H
5#define QQUICK3DPARTICLESPRITESEQUENCE_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 <QQmlEngine>
20#include <QtQml/qqmlparserstatus.h>
21#include <QtQuick3DParticles/qtquick3dparticlesglobal.h>
22#include <private/qglobal_p.h>
23
24QT_BEGIN_NAMESPACE
25
26class QQuick3DParticleSpriteParticle;
27
28class Q_QUICK3DPARTICLES_EXPORT QQuick3DParticleSpriteSequence : public QObject, public QQmlParserStatus
29{
30 Q_OBJECT
31 Q_PROPERTY(int frameCount READ frameCount WRITE setFrameCount NOTIFY frameCountChanged)
32 Q_PROPERTY(int frameIndex READ frameIndex WRITE setFrameIndex NOTIFY frameIndexChanged)
33 Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate NOTIFY interpolateChanged)
34 Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
35 Q_PROPERTY(int durationVariation READ durationVariation WRITE setDurationVariation NOTIFY durationVariationChanged)
36 Q_PROPERTY(bool randomStart READ randomStart WRITE setRandomStart NOTIFY randomStartChanged)
37 Q_PROPERTY(AnimationDirection animationDirection READ animationDirection WRITE setAnimationDirection NOTIFY animationDirectionChanged)
38
39 QML_NAMED_ELEMENT(SpriteSequence3D)
40 Q_INTERFACES(QQmlParserStatus)
41 QML_ADDED_IN_VERSION(6, 2)
42
43public:
44 enum AnimationDirection
45 {
46 Normal = 0,
47 Reverse,
48 Alternate,
49 AlternateReverse,
50 SingleFrame
51 };
52 Q_ENUM(AnimationDirection)
53
54 QQuick3DParticleSpriteSequence(QObject *parent = nullptr);
55 ~QQuick3DParticleSpriteSequence() override;
56
57 int frameCount() const;
58 int frameIndex() const;
59 bool interpolate() const;
60 int duration() const;
61 int durationVariation() const;
62 bool randomStart() const;
63 AnimationDirection animationDirection() const;
64
65public Q_SLOTS:
66 void setFrameCount(int frameCount);
67 void setFrameIndex(int frameIndex);
68 void setInterpolate(bool interpolate);
69 void setDuration(int duration);
70 void setDurationVariation(int durationVariation);
71 void setRandomStart(bool randomStart);
72 void setAnimationDirection(QQuick3DParticleSpriteSequence::AnimationDirection animationDirection);
73
74Q_SIGNALS:
75 void frameCountChanged();
76 void frameIndexChanged();
77 void interpolateChanged();
78 void durationChanged();
79 void durationVariationChanged();
80 void randomStartChanged();
81 void animationDirectionChanged();
82
83protected:
84 // From QQmlParserStatus
85 void componentComplete() override;
86 void classBegin() override {}
87
88private:
89 friend class QQuick3DParticleSpriteParticle;
90 friend class QQuick3DParticleSystem;
91
92 void markNodesDirty();
93 float firstFrame(int index, bool singleFrame);
94
95 QQuick3DParticleSpriteParticle *m_parentParticle = nullptr;
96 int m_frameCount = 1;
97 int m_frameIndex = 0;
98 bool m_interpolate = true;
99 int m_duration = -1;
100 int m_durationVariation = 0;
101 bool m_randomStart = false;
102 AnimationDirection m_animationDirection = AnimationDirection::Normal;
103};
104
105QT_END_NAMESPACE
106
107#endif // QQUICK3DPARTICLESPRITESEQUENCE_H
108

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