1 | // Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qanimationcliploader.h" |
5 | #include "qanimationcliploader_p.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | namespace Qt3DAnimation { |
10 | |
11 | QAnimationClipLoaderPrivate::QAnimationClipLoaderPrivate() |
12 | : QAbstractAnimationClipPrivate() |
13 | , m_source() |
14 | , m_status(QAnimationClipLoader::NotReady) |
15 | { |
16 | } |
17 | |
18 | void QAnimationClipLoaderPrivate::setStatus(QAnimationClipLoader::Status status) |
19 | { |
20 | Q_Q(QAnimationClipLoader); |
21 | if (status != m_status) { |
22 | m_status = status; |
23 | const bool blocked = q->blockNotifications(block: true); |
24 | emit q->statusChanged(status: m_status); |
25 | q->blockNotifications(block: blocked); |
26 | } |
27 | } |
28 | |
29 | /*! |
30 | \enum Qt3DAnimation::QAnimationClipLoader::Status |
31 | |
32 | This enum identifies the status of animation clip. |
33 | |
34 | \value NotReady The clip has not been loaded yet |
35 | \value Ready The clip was successfully loaded |
36 | \value Error An error occurred while loading the clip |
37 | */ |
38 | /*! |
39 | \property Qt3DAnimation::QAnimationClipLoader::status |
40 | |
41 | This property contains the status of the animation clip. |
42 | */ |
43 | /*! |
44 | \property Qt3DAnimation::QAnimationClipLoader::source |
45 | |
46 | Holds the source URL from which to load the animation clip. Currently |
47 | glTF2 and the native Qt 3D json animation file formats are supported. |
48 | |
49 | In the case where a file contains multiple animations, it is possible |
50 | to select which animation should be loaded by way of query parameters |
51 | on the source url. The accepted query parameters are animationIndex and |
52 | animationName. If both are specified, animationName is ignored. |
53 | |
54 | If a file contains only a single animation, there is no need to specify |
55 | the animationIndex or animationName. We simply use the one available |
56 | animation. |
57 | */ |
58 | /*! |
59 | \class Qt3DAnimation::QAnimationClipLoader |
60 | \inherits QAbstractAnimationClip |
61 | \inmodule Qt3DAnimation |
62 | \brief Enables loading key frame animation data from a file. |
63 | */ |
64 | |
65 | QAnimationClipLoader::QAnimationClipLoader(Qt3DCore::QNode *parent) |
66 | : QAbstractAnimationClip(*new QAnimationClipLoaderPrivate, parent) |
67 | { |
68 | } |
69 | |
70 | QAnimationClipLoader::QAnimationClipLoader(const QUrl &source, |
71 | Qt3DCore::QNode *parent) |
72 | : QAbstractAnimationClip(*new QAnimationClipLoaderPrivate, parent) |
73 | { |
74 | setSource(source); |
75 | } |
76 | |
77 | QAnimationClipLoader::QAnimationClipLoader(QAnimationClipLoaderPrivate &dd, Qt3DCore::QNode *parent) |
78 | : QAbstractAnimationClip(dd, parent) |
79 | { |
80 | } |
81 | |
82 | QAnimationClipLoader::~QAnimationClipLoader() |
83 | { |
84 | } |
85 | |
86 | QUrl QAnimationClipLoader::source() const |
87 | { |
88 | Q_D(const QAnimationClipLoader); |
89 | return d->m_source; |
90 | } |
91 | |
92 | /*! |
93 | Returns the status of the animation clip. |
94 | */ |
95 | QAnimationClipLoader::Status QAnimationClipLoader::status() const |
96 | { |
97 | Q_D(const QAnimationClipLoader); |
98 | return d->m_status; |
99 | } |
100 | |
101 | void QAnimationClipLoader::setSource(const QUrl &source) |
102 | { |
103 | Q_D(QAnimationClipLoader); |
104 | if (d->m_source == source) |
105 | return; |
106 | |
107 | d->m_source = source; |
108 | emit sourceChanged(source); |
109 | } |
110 | |
111 | } // namespace Qt3DAnimation |
112 | |
113 | QT_END_NAMESPACE |
114 | |
115 | #include "moc_qanimationcliploader.cpp" |
116 | |