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

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

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