1/****************************************************************************
2**
3** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qanimationaspect.h"
41#include "qanimationaspect_p.h"
42#include <Qt3DAnimation/qabstractanimationclip.h>
43#include <Qt3DAnimation/qabstractchannelmapping.h>
44#include <Qt3DAnimation/qclock.h>
45#include <Qt3DAnimation/qblendedclipanimator.h>
46#include <Qt3DAnimation/qclipanimator.h>
47#include <Qt3DAnimation/qchannelmapper.h>
48#include <Qt3DAnimation/qlerpclipblend.h>
49#include <Qt3DAnimation/qadditiveclipblend.h>
50#include <Qt3DAnimation/qclipblendvalue.h>
51#include <Qt3DAnimation/private/handler_p.h>
52#include <Qt3DAnimation/private/managers_p.h>
53#include <Qt3DAnimation/private/nodefunctor_p.h>
54#include <Qt3DAnimation/private/lerpclipblend_p.h>
55#include <Qt3DAnimation/private/clipblendvalue_p.h>
56#include <Qt3DAnimation/private/additiveclipblend_p.h>
57#include <Qt3DAnimation/private/skeleton_p.h>
58#include <Qt3DCore/qabstractskeleton.h>
59
60QT_BEGIN_NAMESPACE
61
62using namespace Qt3DCore;
63
64namespace Qt3DAnimation {
65
66QAnimationAspectPrivate::QAnimationAspectPrivate()
67 : QAbstractAspectPrivate()
68 , m_handler(new Animation::Handler)
69{
70}
71
72/*!
73 \class Qt3DAnimation::QAnimationAspect
74 \inherits Qt3DCore::QAbstractAspect
75 \inmodule Qt3DAnimation
76 \brief Provides key-frame animation capabilities to Qt 3D.
77 \since 5.9
78
79 QAnimationAspect provides key-frame animation to Qt 3D.
80*/
81
82/*!
83 * Constructs a new QAnimationAspect with \a parent.
84 */
85QAnimationAspect::QAnimationAspect(QObject *parent)
86 : QAnimationAspect(*new QAnimationAspectPrivate, parent)
87{
88}
89
90/*! \internal */
91QAnimationAspect::QAnimationAspect(QAnimationAspectPrivate &dd, QObject *parent)
92 : QAbstractAspect(dd, parent)
93{
94 setObjectName(QStringLiteral("Animation Aspect"));
95 Q_D(QAnimationAspect);
96 qRegisterMetaType<Qt3DAnimation::QAnimationClipLoader*>();
97 qRegisterMetaType<Qt3DAnimation::QChannelMapper*>();
98 qRegisterMetaType<QVector<Qt3DCore::Sqt>>();
99 qRegisterMetaType<Qt3DAnimation::QAbstractAnimationClip*>();
100
101 registerBackendType<QAbstractAnimationClip>(
102 QSharedPointer<Animation::NodeFunctor<Animation::AnimationClip, Animation::AnimationClipLoaderManager>>::create(d->m_handler.data(),
103 d->m_handler->animationClipLoaderManager()));
104 registerBackendType<QClock>(
105 QSharedPointer<Animation::NodeFunctor<Animation::Clock, Animation::ClockManager>>::create(d->m_handler.data(),
106 d->m_handler->clockManager()));
107 registerBackendType<QClipAnimator>(
108 QSharedPointer<Animation::NodeFunctor<Animation::ClipAnimator, Animation::ClipAnimatorManager>>::create(d->m_handler.data(),
109 d->m_handler->clipAnimatorManager()));
110 registerBackendType<QBlendedClipAnimator>(
111 QSharedPointer<Animation::NodeFunctor<Animation::BlendedClipAnimator, Animation::BlendedClipAnimatorManager>>::create(d->m_handler.data(),
112 d->m_handler->blendedClipAnimatorManager()));
113 registerBackendType<QAbstractChannelMapping>(
114 QSharedPointer<Animation::NodeFunctor<Animation::ChannelMapping, Animation::ChannelMappingManager>>::create(d->m_handler.data(),
115 d->m_handler->channelMappingManager()));
116 registerBackendType<QChannelMapper>(
117 QSharedPointer<Animation::NodeFunctor<Animation::ChannelMapper, Animation::ChannelMapperManager>>::create(d->m_handler.data(),
118 d->m_handler->channelMapperManager()));
119 registerBackendType<QLerpClipBlend>(
120 QSharedPointer<Animation::ClipBlendNodeFunctor<Animation::LerpClipBlend, Animation::ClipAnimatorManager>>::create(d->m_handler.data(),
121 d->m_handler->clipBlendNodeManager()));
122 registerBackendType<QAdditiveClipBlend>(
123 QSharedPointer<Animation::ClipBlendNodeFunctor<Animation::AdditiveClipBlend, Animation::ClipAnimatorManager>>::create(d->m_handler.data(),
124 d->m_handler->clipBlendNodeManager()));
125 registerBackendType<QClipBlendValue>(
126 QSharedPointer<Animation::ClipBlendNodeFunctor<Animation::ClipBlendValue, Animation::ClipAnimatorManager>>::create(d->m_handler.data(),
127 d->m_handler->clipBlendNodeManager()));
128 registerBackendType<Qt3DCore::QAbstractSkeleton>(
129 QSharedPointer<Animation::NodeFunctor<Animation::Skeleton, Animation::SkeletonManager>>::create(d->m_handler.data(),
130 d->m_handler->skeletonManager()));
131}
132
133/*! \internal */
134QAnimationAspect::~QAnimationAspect()
135{
136}
137
138/*!
139 \internal
140 */
141QVector<QAspectJobPtr> QAnimationAspect::jobsToExecute(qint64 time)
142{
143 Q_D(QAnimationAspect);
144 Q_ASSERT(d->m_handler);
145 return d->m_handler->jobsToExecute(time);
146}
147
148} // namespace Qt3DAnimation
149
150QT_END_NAMESPACE
151
152QT3D_REGISTER_NAMESPACED_ASPECT("animation", QT_PREPEND_NAMESPACE(Qt3DAnimation), QAnimationAspect)
153