1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DANIMATION_QMORPHINGANIMATION_H
5#define QT3DANIMATION_QMORPHINGANIMATION_H
6
7#include <Qt3DRender/qgeometryrenderer.h>
8
9#include <Qt3DAnimation/qabstractanimation.h>
10#include <Qt3DAnimation/qmorphtarget.h>
11#include <Qt3DAnimation/qt3danimation_global.h>
12
13#include <QtCore/qeasingcurve.h>
14
15QT_BEGIN_NAMESPACE
16
17namespace Qt3DAnimation {
18
19class QMorphingAnimationPrivate;
20
21class Q_3DANIMATIONSHARED_EXPORT QMorphingAnimation : public QAbstractAnimation
22{
23 Q_OBJECT
24 Q_PROPERTY(QVector<float> targetPositions READ targetPositions WRITE setTargetPositions NOTIFY targetPositionsChanged)
25 Q_PROPERTY(float interpolator READ interpolator NOTIFY interpolatorChanged)
26 Q_PROPERTY(Qt3DRender::QGeometryRenderer *target READ target WRITE setTarget NOTIFY targetChanged)
27 Q_PROPERTY(QString targetName READ targetName WRITE setTargetName NOTIFY targetNameChanged)
28 Q_PROPERTY(Method method READ method WRITE setMethod NOTIFY methodChanged)
29 Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
30
31public:
32 enum Method
33 {
34 Normalized,
35 Relative
36 };
37 Q_ENUM(Method)
38
39 explicit QMorphingAnimation(QObject *parent = nullptr);
40
41 QVector<float> targetPositions() const;
42 float interpolator() const;
43 Qt3DRender::QGeometryRenderer *target() const;
44 QString targetName() const;
45 QMorphingAnimation::Method method() const;
46 QEasingCurve easing() const;
47
48 void setMorphTargets(const QVector<Qt3DAnimation::QMorphTarget *> &targets);
49 void addMorphTarget(Qt3DAnimation::QMorphTarget *target);
50 void removeMorphTarget(Qt3DAnimation::QMorphTarget *target);
51
52 void setWeights(int positionIndex, const QVector<float> &weights);
53 QVector<float> getWeights(int positionIndex);
54
55 QVector<Qt3DAnimation::QMorphTarget *> morphTargetList();
56
57public Q_SLOTS:
58 void setTargetPositions(const QVector<float> &targetPositions);
59 void setTarget(Qt3DRender::QGeometryRenderer *target);
60 void setTargetName(const QString name);
61 void setMethod(QMorphingAnimation::Method method);
62 void setEasing(const QEasingCurve &easing);
63
64Q_SIGNALS:
65 void targetPositionsChanged(const QVector<float> &targetPositions);
66 void interpolatorChanged(float interpolator);
67 void targetChanged(Qt3DRender::QGeometryRenderer *target);
68 void targetNameChanged(const QString &name);
69 void methodChanged(QMorphingAnimation::Method method);
70 void easingChanged(const QEasingCurve &easing);
71
72private:
73
74 void updateAnimation(float position);
75
76 Q_DECLARE_PRIVATE(QMorphingAnimation)
77};
78
79} // Qt3DAnimation
80
81QT_END_NAMESPACE
82
83#endif // QT3DANIMATION_QMORPHINGANIMATION_H
84

source code of qt3d/src/animation/frontend/qmorphinganimation.h