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 "qanimationaspect.h"
5#include "qanimationaspect_p.h"
6#include <Qt3DAnimation/qabstractanimationclip.h>
7#include <Qt3DAnimation/qabstractchannelmapping.h>
8#include <Qt3DAnimation/qclock.h>
9#include <Qt3DAnimation/qblendedclipanimator.h>
10#include <Qt3DAnimation/qclipanimator.h>
11#include <Qt3DAnimation/qchannelmapper.h>
12#include <Qt3DAnimation/qlerpclipblend.h>
13#include <Qt3DAnimation/qadditiveclipblend.h>
14#include <Qt3DAnimation/qclipblendvalue.h>
15#include <Qt3DAnimation/private/handler_p.h>
16#include <Qt3DAnimation/private/managers_p.h>
17#include <Qt3DAnimation/private/nodefunctor_p.h>
18#include <Qt3DAnimation/private/lerpclipblend_p.h>
19#include <Qt3DAnimation/private/clipblendvalue_p.h>
20#include <Qt3DAnimation/private/additiveclipblend_p.h>
21#include <Qt3DAnimation/private/skeleton_p.h>
22#include <Qt3DCore/qabstractskeleton.h>
23
24QT_BEGIN_NAMESPACE
25
26using namespace Qt3DCore;
27
28namespace Qt3DAnimation {
29
30QAnimationAspectPrivate::QAnimationAspectPrivate()
31 : QAbstractAspectPrivate()
32 , m_handler(new Animation::Handler)
33{
34}
35
36/*!
37 \class Qt3DAnimation::QAnimationAspect
38 \inherits Qt3DCore::QAbstractAspect
39 \inmodule Qt3DAnimation
40 \brief Provides key-frame animation capabilities to Qt 3D.
41 \since 5.9
42
43 QAnimationAspect provides key-frame animation to Qt 3D.
44*/
45
46/*!
47 * Constructs a new QAnimationAspect with \a parent.
48 */
49QAnimationAspect::QAnimationAspect(QObject *parent)
50 : QAnimationAspect(*new QAnimationAspectPrivate, parent)
51{
52}
53
54/*! \internal */
55QAnimationAspect::QAnimationAspect(QAnimationAspectPrivate &dd, QObject *parent)
56 : QAbstractAspect(dd, parent)
57{
58 setObjectName(QStringLiteral("Animation Aspect"));
59 Q_D(QAnimationAspect);
60 qRegisterMetaType<Qt3DAnimation::QAnimationClipLoader*>();
61 qRegisterMetaType<Qt3DAnimation::QChannelMapper*>();
62 qRegisterMetaType<QList<Qt3DCore::Sqt>>();
63 qRegisterMetaType<Qt3DAnimation::QAbstractAnimationClip*>();
64
65 registerBackendType<QAbstractAnimationClip>(
66 functor: QSharedPointer<Animation::NodeFunctor<Animation::AnimationClip, Animation::AnimationClipLoaderManager>>::create(arguments: d->m_handler.data(),
67 arguments: d->m_handler->animationClipLoaderManager()));
68 registerBackendType<QClock>(
69 functor: QSharedPointer<Animation::NodeFunctor<Animation::Clock, Animation::ClockManager>>::create(arguments: d->m_handler.data(),
70 arguments: d->m_handler->clockManager()));
71 registerBackendType<QClipAnimator>(
72 functor: QSharedPointer<Animation::NodeFunctor<Animation::ClipAnimator, Animation::ClipAnimatorManager>>::create(arguments: d->m_handler.data(),
73 arguments: d->m_handler->clipAnimatorManager()));
74 registerBackendType<QBlendedClipAnimator>(
75 functor: QSharedPointer<Animation::NodeFunctor<Animation::BlendedClipAnimator, Animation::BlendedClipAnimatorManager>>::create(arguments: d->m_handler.data(),
76 arguments: d->m_handler->blendedClipAnimatorManager()));
77 registerBackendType<QAbstractChannelMapping>(
78 functor: QSharedPointer<Animation::NodeFunctor<Animation::ChannelMapping, Animation::ChannelMappingManager>>::create(arguments: d->m_handler.data(),
79 arguments: d->m_handler->channelMappingManager()));
80 registerBackendType<QChannelMapper>(
81 functor: QSharedPointer<Animation::NodeFunctor<Animation::ChannelMapper, Animation::ChannelMapperManager>>::create(arguments: d->m_handler.data(),
82 arguments: d->m_handler->channelMapperManager()));
83 registerBackendType<QLerpClipBlend>(
84 functor: QSharedPointer<Animation::ClipBlendNodeFunctor<Animation::LerpClipBlend, Animation::ClipAnimatorManager>>::create(arguments: d->m_handler.data(),
85 arguments: d->m_handler->clipBlendNodeManager()));
86 registerBackendType<QAdditiveClipBlend>(
87 functor: QSharedPointer<Animation::ClipBlendNodeFunctor<Animation::AdditiveClipBlend, Animation::ClipAnimatorManager>>::create(arguments: d->m_handler.data(),
88 arguments: d->m_handler->clipBlendNodeManager()));
89 registerBackendType<QClipBlendValue>(
90 functor: QSharedPointer<Animation::ClipBlendNodeFunctor<Animation::ClipBlendValue, Animation::ClipAnimatorManager>>::create(arguments: d->m_handler.data(),
91 arguments: d->m_handler->clipBlendNodeManager()));
92 registerBackendType<Qt3DCore::QAbstractSkeleton>(
93 functor: QSharedPointer<Animation::NodeFunctor<Animation::Skeleton, Animation::SkeletonManager>>::create(arguments: d->m_handler.data(),
94 arguments: d->m_handler->skeletonManager()));
95}
96
97/*! \internal */
98QAnimationAspect::~QAnimationAspect()
99{
100}
101
102/*!
103 \internal
104 */
105std::vector<QAspectJobPtr> QAnimationAspect::jobsToExecute(qint64 time)
106{
107 Q_D(QAnimationAspect);
108 Q_ASSERT(d->m_handler);
109 return d->m_handler->jobsToExecute(time);
110}
111
112} // namespace Qt3DAnimation
113
114QT_END_NAMESPACE
115
116QT3D_REGISTER_NAMESPACED_ASPECT("animation", QT_PREPEND_NAMESPACE(Qt3DAnimation), QAnimationAspect)
117
118#include "moc_qanimationaspect.cpp"
119

source code of qt3d/src/animation/frontend/qanimationaspect.cpp