| 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 | |
| 60 | QT_BEGIN_NAMESPACE |
| 61 | |
| 62 | using namespace Qt3DCore; |
| 63 | |
| 64 | namespace Qt3DAnimation { |
| 65 | |
| 66 | QAnimationAspectPrivate::QAnimationAspectPrivate() |
| 67 | : QAbstractAspectPrivate() |
| 68 | , m_handler(new Animation::Handler) |
| 69 | { |
| 70 | } |
| 71 | |
| 72 | void QAnimationAspectPrivate::syncDirtyFrontEndNode(QNode *node, QBackendNode *backend, bool firstTime) const |
| 73 | { |
| 74 | Animation::BackendNode *renderBackend = static_cast<Animation::BackendNode *>(backend); |
| 75 | renderBackend->syncFromFrontEnd(frontEnd: node, firstTime); |
| 76 | } |
| 77 | |
| 78 | /*! |
| 79 | \class Qt3DAnimation::QAnimationAspect |
| 80 | \inherits Qt3DCore::QAbstractAspect |
| 81 | \inmodule Qt3DAnimation |
| 82 | \brief Provides key-frame animation capabilities to Qt 3D. |
| 83 | \since 5.9 |
| 84 | |
| 85 | QAnimationAspect provides key-frame animation to Qt 3D. |
| 86 | */ |
| 87 | |
| 88 | /*! |
| 89 | * Constructs a new QAnimationAspect with \a parent. |
| 90 | */ |
| 91 | QAnimationAspect::QAnimationAspect(QObject *parent) |
| 92 | : QAnimationAspect(*new QAnimationAspectPrivate, parent) |
| 93 | { |
| 94 | } |
| 95 | |
| 96 | /*! \internal */ |
| 97 | QAnimationAspect::QAnimationAspect(QAnimationAspectPrivate &dd, QObject *parent) |
| 98 | : QAbstractAspect(dd, parent) |
| 99 | { |
| 100 | setObjectName(QStringLiteral("Animation Aspect" )); |
| 101 | Q_D(QAnimationAspect); |
| 102 | qRegisterMetaType<Qt3DAnimation::QAnimationClipLoader*>(); |
| 103 | qRegisterMetaType<Qt3DAnimation::QChannelMapper*>(); |
| 104 | qRegisterMetaType<QVector<Qt3DCore::Sqt>>(); |
| 105 | qRegisterMetaType<Qt3DAnimation::QAbstractAnimationClip*>(); |
| 106 | |
| 107 | registerBackendType<QAbstractAnimationClip, true>( |
| 108 | functor: QSharedPointer<Animation::NodeFunctor<Animation::AnimationClip, Animation::AnimationClipLoaderManager>>::create(arguments: d->m_handler.data(), |
| 109 | arguments: d->m_handler->animationClipLoaderManager())); |
| 110 | registerBackendType<QClock, true>( |
| 111 | functor: QSharedPointer<Animation::NodeFunctor<Animation::Clock, Animation::ClockManager>>::create(arguments: d->m_handler.data(), |
| 112 | arguments: d->m_handler->clockManager())); |
| 113 | registerBackendType<QClipAnimator, true>( |
| 114 | functor: QSharedPointer<Animation::NodeFunctor<Animation::ClipAnimator, Animation::ClipAnimatorManager>>::create(arguments: d->m_handler.data(), |
| 115 | arguments: d->m_handler->clipAnimatorManager())); |
| 116 | registerBackendType<QBlendedClipAnimator, true>( |
| 117 | functor: QSharedPointer<Animation::NodeFunctor<Animation::BlendedClipAnimator, Animation::BlendedClipAnimatorManager>>::create(arguments: d->m_handler.data(), |
| 118 | arguments: d->m_handler->blendedClipAnimatorManager())); |
| 119 | registerBackendType<QAbstractChannelMapping, true>( |
| 120 | functor: QSharedPointer<Animation::NodeFunctor<Animation::ChannelMapping, Animation::ChannelMappingManager>>::create(arguments: d->m_handler.data(), |
| 121 | arguments: d->m_handler->channelMappingManager())); |
| 122 | registerBackendType<QChannelMapper, true>( |
| 123 | functor: QSharedPointer<Animation::NodeFunctor<Animation::ChannelMapper, Animation::ChannelMapperManager>>::create(arguments: d->m_handler.data(), |
| 124 | arguments: d->m_handler->channelMapperManager())); |
| 125 | registerBackendType<QLerpClipBlend, true>( |
| 126 | functor: QSharedPointer<Animation::ClipBlendNodeFunctor<Animation::LerpClipBlend, Animation::ClipAnimatorManager>>::create(arguments: d->m_handler.data(), |
| 127 | arguments: d->m_handler->clipBlendNodeManager())); |
| 128 | registerBackendType<QAdditiveClipBlend, true>( |
| 129 | functor: QSharedPointer<Animation::ClipBlendNodeFunctor<Animation::AdditiveClipBlend, Animation::ClipAnimatorManager>>::create(arguments: d->m_handler.data(), |
| 130 | arguments: d->m_handler->clipBlendNodeManager())); |
| 131 | registerBackendType<QClipBlendValue, true>( |
| 132 | functor: QSharedPointer<Animation::ClipBlendNodeFunctor<Animation::ClipBlendValue, Animation::ClipAnimatorManager>>::create(arguments: d->m_handler.data(), |
| 133 | arguments: d->m_handler->clipBlendNodeManager())); |
| 134 | registerBackendType<Qt3DCore::QAbstractSkeleton, true>( |
| 135 | functor: QSharedPointer<Animation::NodeFunctor<Animation::Skeleton, Animation::SkeletonManager>>::create(arguments: d->m_handler.data(), |
| 136 | arguments: d->m_handler->skeletonManager())); |
| 137 | } |
| 138 | |
| 139 | /*! \internal */ |
| 140 | QAnimationAspect::~QAnimationAspect() |
| 141 | { |
| 142 | } |
| 143 | |
| 144 | /*! |
| 145 | \internal |
| 146 | */ |
| 147 | QVector<QAspectJobPtr> QAnimationAspect::jobsToExecute(qint64 time) |
| 148 | { |
| 149 | Q_D(QAnimationAspect); |
| 150 | Q_ASSERT(d->m_handler); |
| 151 | return d->m_handler->jobsToExecute(time); |
| 152 | } |
| 153 | |
| 154 | } // namespace Qt3DAnimation |
| 155 | |
| 156 | QT_END_NAMESPACE |
| 157 | |
| 158 | QT3D_REGISTER_NAMESPACED_ASPECT("animation" , QT_PREPEND_NAMESPACE(Qt3DAnimation), QAnimationAspect) |
| 159 | |