diff options
Diffstat (limited to 'src/quick3d/quick3danimation/items')
16 files changed, 1145 insertions, 183 deletions
diff --git a/src/quick3d/quick3danimation/items/items.pri b/src/quick3d/quick3danimation/items/items.pri index 0c3511902..27adabbe4 100644 --- a/src/quick3d/quick3danimation/items/items.pri +++ b/src/quick3d/quick3danimation/items/items.pri @@ -1,9 +1,19 @@ SOURCES += \ $$PWD/quick3dchannelmapper.cpp \ - $$PWD/quick3dabstractclipblendnode.cpp + $$PWD/quick3danimationcontroller.cpp \ + $$PWD/quick3danimationgroup.cpp \ + $$PWD/quick3dkeyframeanimation.cpp \ + $$PWD/quick3dmorphinganimation.cpp \ + $$PWD/quick3dmorphtarget.cpp \ + $$PWD/quick3dvertexblendanimation.cpp HEADERS += \ $$PWD/quick3dchannelmapper_p.h \ - $$PWD/quick3dabstractclipblendnode_p.h + $$PWD/quick3danimationcontroller_p.h \ + $$PWD/quick3danimationgroup_p.h \ + $$PWD/quick3dkeyframeanimation_p.h \ + $$PWD/quick3dmorphinganimation_p.h \ + $$PWD/quick3dmorphtarget_p.h \ + $$PWD/quick3dvertexblendanimation_p.h INCLUDEPATH += $$PWD diff --git a/src/quick3d/quick3danimation/items/quick3dabstractclipblendnode.cpp b/src/quick3d/quick3danimation/items/quick3dabstractclipblendnode.cpp deleted file mode 100644 index 7a709c2d6..000000000 --- a/src/quick3d/quick3danimation/items/quick3dabstractclipblendnode.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "quick3dabstractclipblendnode_p.h" - -QT_BEGIN_NAMESPACE - -namespace Qt3DAnimation { -namespace Animation { -namespace Quick { - -Quick3DAbstractClipBlendNode::Quick3DAbstractClipBlendNode(QObject *parent) - : QObject(parent) -{ -} - -QQmlListProperty<QAnimationClip> Quick3DAbstractClipBlendNode::clipList() -{ - return QQmlListProperty<QAnimationClip>(this, 0, - &Quick3DAbstractClipBlendNode::appendClip, - &Quick3DAbstractClipBlendNode::clipCount, - &Quick3DAbstractClipBlendNode::clipAt, - &Quick3DAbstractClipBlendNode::clearClips); -} - -void Quick3DAbstractClipBlendNode::appendClip(QQmlListProperty<QAnimationClip> *list, QAnimationClip *clip) -{ - Quick3DAbstractClipBlendNode *extension = qobject_cast<Quick3DAbstractClipBlendNode *>(list->object); - extension->parentAbstractClipBlendNode()->addClip(clip); -} - -QAnimationClip *Quick3DAbstractClipBlendNode::clipAt(QQmlListProperty<QAnimationClip> *list, int index) -{ - Quick3DAbstractClipBlendNode *extension = qobject_cast<Quick3DAbstractClipBlendNode *>(list->object); - return extension->parentAbstractClipBlendNode()->clips().at(index); -} - -int Quick3DAbstractClipBlendNode::clipCount(QQmlListProperty<QAnimationClip> *list) -{ - Quick3DAbstractClipBlendNode *extension = qobject_cast<Quick3DAbstractClipBlendNode *>(list->object); - return extension->parentAbstractClipBlendNode()->clips().count(); -} - -void Quick3DAbstractClipBlendNode::clearClips(QQmlListProperty<QAnimationClip> *list) -{ - Quick3DAbstractClipBlendNode *extension = qobject_cast<Quick3DAbstractClipBlendNode *>(list->object); - const QVector<QAnimationClip *> clips = extension->parentAbstractClipBlendNode()->clips(); - for (QAnimationClip *clip : clips) - extension->parentAbstractClipBlendNode()->removeClip(clip); -} - -} // Quick -} // Animation -} // Qt3DAnimation - -QT_END_NAMESPACE diff --git a/src/quick3d/quick3danimation/items/quick3dabstractclipblendnode_p.h b/src/quick3d/quick3danimation/items/quick3dabstractclipblendnode_p.h deleted file mode 100644 index bfb1825a7..000000000 --- a/src/quick3d/quick3danimation/items/quick3dabstractclipblendnode_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DANIMATION_ANIMATION_QUICK3DABSTRACTCLIPBLENDNODE_P_H -#define QT3DANIMATION_ANIMATION_QUICK3DABSTRACTCLIPBLENDNODE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DQuickAnimation/private/qt3dquickanimation_global_p.h> -#include <Qt3DAnimation/qabstractclipblendnode.h> -#include <Qt3DAnimation/qanimationclip.h> -#include <QQmlListProperty> - -QT_BEGIN_NAMESPACE - -namespace Qt3DAnimation { -namespace Animation { -namespace Quick { - -class QT3DQUICKANIMATIONSHARED_PRIVATE_EXPORT Quick3DAbstractClipBlendNode : public QObject -{ - Q_OBJECT - Q_PROPERTY(QQmlListProperty<Qt3DAnimation::QAnimationClip> clips READ clipList CONSTANT) - -public: - explicit Quick3DAbstractClipBlendNode(QObject *parent = nullptr); - - inline QAbstractClipBlendNode *parentAbstractClipBlendNode() const { return qobject_cast<QAbstractClipBlendNode *>(parent()); } - QQmlListProperty<QAnimationClip> clipList(); - -private: - static void appendClip(QQmlListProperty<QAnimationClip> *list, QAnimationClip *clip); - static QAnimationClip *clipAt(QQmlListProperty<QAnimationClip> *list, int index); - static int clipCount(QQmlListProperty<QAnimationClip> *list); - static void clearClips(QQmlListProperty<QAnimationClip> *list); -}; - -} // Quick -} // Animation -} // Qt3DAnimation - -QT_END_NAMESPACE - -#endif // QT3DANIMATION_ANIMATION_QUICK3DABSTRACTCLIPBLENDNODE_P_H diff --git a/src/quick3d/quick3danimation/items/quick3danimationcontroller.cpp b/src/quick3d/quick3danimation/items/quick3danimationcontroller.cpp new file mode 100644 index 000000000..dc6183989 --- /dev/null +++ b/src/quick3d/quick3danimation/items/quick3danimationcontroller.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "quick3danimationcontroller_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Quick { + +QQuick3DAnimationController::QQuick3DAnimationController(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<QAnimationGroup> QQuick3DAnimationController::animationGroups() +{ + return QQmlListProperty<QAnimationGroup>(this, 0, + &QQuick3DAnimationController::appendAnimationGroup, + &QQuick3DAnimationController::animationGroupCount, + &QQuick3DAnimationController::animationGroupAt, + &QQuick3DAnimationController::clearAnimationGroups); +} + + +void QQuick3DAnimationController::appendAnimationGroup(QQmlListProperty<QAnimationGroup> *list, QAnimationGroup *bar) +{ + QQuick3DAnimationController *controller = qobject_cast<QQuick3DAnimationController *>(list->object); + if (controller) + controller->parentAnimationController()->addAnimationGroup(bar); +} + +int QQuick3DAnimationController::animationGroupCount(QQmlListProperty<QAnimationGroup> *list) +{ + QQuick3DAnimationController *controller = qobject_cast<QQuick3DAnimationController *>(list->object); + if (controller) + return controller->parentAnimationController()->animationGroupList().count(); + return 0; +} + +QAnimationGroup *QQuick3DAnimationController::animationGroupAt(QQmlListProperty<QAnimationGroup> *list, int index) +{ + QQuick3DAnimationController *controller = qobject_cast<QQuick3DAnimationController *>(list->object); + if (controller) + return qobject_cast<QAnimationGroup *>(controller->parentAnimationController()->getGroup(index)); + return nullptr; +} + +void QQuick3DAnimationController::clearAnimationGroups(QQmlListProperty<QAnimationGroup> *list) +{ + QQuick3DAnimationController *controller = qobject_cast<QQuick3DAnimationController *>(list->object); + if (controller) { + QVector<QAnimationGroup *> emptyList; + controller->parentAnimationController()->setAnimationGroups(emptyList); + } +} + + +} // namespace Quick +} // namespace Qt3DAnimation + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3danimation/items/quick3danimationcontroller_p.h b/src/quick3d/quick3danimation/items/quick3danimationcontroller_p.h new file mode 100644 index 000000000..a3033e537 --- /dev/null +++ b/src/quick3d/quick3danimation/items/quick3danimationcontroller_p.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DANIMATION_QUICK_QUICK3DANIMATIONCONTROLLER_P_H +#define QT3DANIMATION_QUICK_QUICK3DANIMATIONCONTROLLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qt3dquickanimation_global_p.h> +#include <QtQml/QQmlListProperty> +#include <Qt3DAnimation/QAnimationController> + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Quick { + +class QT3DQUICKANIMATIONSHARED_PRIVATE_EXPORT QQuick3DAnimationController : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DAnimation::QAnimationGroup> animationGroups READ animationGroups) + +public: + + explicit QQuick3DAnimationController(QObject *parent = nullptr); + + inline Qt3DAnimation::QAnimationController *parentAnimationController() const + { + return qobject_cast<Qt3DAnimation::QAnimationController *>(parent()); + } + + QQmlListProperty<Qt3DAnimation::QAnimationGroup> animationGroups(); + +private: + + static void appendAnimationGroup(QQmlListProperty<Qt3DAnimation::QAnimationGroup> *list, Qt3DAnimation::QAnimationGroup *bar); + static QAnimationGroup *animationGroupAt(QQmlListProperty<Qt3DAnimation::QAnimationGroup> *list, int index); + static int animationGroupCount(QQmlListProperty<Qt3DAnimation::QAnimationGroup> *list); + static void clearAnimationGroups(QQmlListProperty<Qt3DAnimation::QAnimationGroup> *list); +}; + +} // namespace Quick +} // namespace Qt3DAnimation + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DEFFECT_P_H diff --git a/src/quick3d/quick3danimation/items/quick3danimationgroup.cpp b/src/quick3d/quick3danimation/items/quick3danimationgroup.cpp new file mode 100644 index 000000000..f10450280 --- /dev/null +++ b/src/quick3d/quick3danimation/items/quick3danimationgroup.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "quick3danimationgroup_p.h" + +#include <Qt3DAnimation/qabstractanimation.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Quick { + +QQuick3DAnimationGroup::QQuick3DAnimationGroup(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<Qt3DAnimation::QAbstractAnimation> QQuick3DAnimationGroup::animations() +{ + return QQmlListProperty<Qt3DAnimation::QAbstractAnimation>(this, 0, + &QQuick3DAnimationGroup::appendAnimation, + &QQuick3DAnimationGroup::animationCount, + &QQuick3DAnimationGroup::animationAt, + &QQuick3DAnimationGroup::clearAnimation); +} + + +void QQuick3DAnimationGroup::appendAnimation(QQmlListProperty<Qt3DAnimation::QAbstractAnimation> *list, + Qt3DAnimation::QAbstractAnimation *animation) +{ + QQuick3DAnimationGroup *animationGroup = qobject_cast<QQuick3DAnimationGroup *>(list->object); + if (animationGroup) + animationGroup->parentAnimationGroup()->addAnimation(animation); +} + +int QQuick3DAnimationGroup::animationCount(QQmlListProperty<Qt3DAnimation::QAbstractAnimation> *list) +{ + QQuick3DAnimationGroup *animationGroup = qobject_cast<QQuick3DAnimationGroup *>(list->object); + if (animationGroup) + return animationGroup->parentAnimationGroup()->animationList().count(); + return 0; +} + +Qt3DAnimation::QAbstractAnimation *QQuick3DAnimationGroup::animationAt(QQmlListProperty<Qt3DAnimation::QAbstractAnimation> *list, int index) +{ + QQuick3DAnimationGroup *animationGroup = qobject_cast<QQuick3DAnimationGroup *>(list->object); + if (animationGroup) { + return qobject_cast<Qt3DAnimation::QAbstractAnimation *>( + animationGroup->parentAnimationGroup()->animationList().at(index)); + } + return nullptr; +} + +void QQuick3DAnimationGroup::clearAnimation(QQmlListProperty<Qt3DAnimation::QAbstractAnimation> *list) +{ + QQuick3DAnimationGroup *animationGroup = qobject_cast<QQuick3DAnimationGroup *>(list->object); + if (animationGroup) { + QVector<Qt3DAnimation::QAbstractAnimation *> emptyList; + animationGroup->parentAnimationGroup()->setAnimations(emptyList); + } +} + +} // namespace Quick +} // namespace Qt3DAnimation + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3danimation/items/quick3danimationgroup_p.h b/src/quick3d/quick3danimation/items/quick3danimationgroup_p.h new file mode 100644 index 000000000..aef202480 --- /dev/null +++ b/src/quick3d/quick3danimation/items/quick3danimationgroup_p.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DANIMATION_QUICK_QUICK3DANIMATIONGROUP_P_H +#define QT3DANIMATION_QUICK_QUICK3DANIMATIONGROUP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqmllist.h> +#include <Qt3DAnimation/qabstractanimation.h> +#include <Qt3DAnimation/qanimationgroup.h> + +#include <private/qt3dquickanimation_global_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Quick { + +class QT3DQUICKANIMATIONSHARED_PRIVATE_EXPORT QQuick3DAnimationGroup : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DAnimation::QAbstractAnimation> animations READ animations) + +public: + + explicit QQuick3DAnimationGroup(QObject *parent = nullptr); + + inline Qt3DAnimation::QAnimationGroup *parentAnimationGroup() const + { + return qobject_cast<Qt3DAnimation::QAnimationGroup *>(parent()); + } + + QQmlListProperty<Qt3DAnimation::QAbstractAnimation> animations(); + +private: + + static void appendAnimation(QQmlListProperty<Qt3DAnimation::QAbstractAnimation> *list, Qt3DAnimation::QAbstractAnimation *animation); + static Qt3DAnimation::QAbstractAnimation *animationAt(QQmlListProperty<Qt3DAnimation::QAbstractAnimation> *list, int index); + static int animationCount(QQmlListProperty<Qt3DAnimation::QAbstractAnimation> *list); + static void clearAnimation(QQmlListProperty<Qt3DAnimation::QAbstractAnimation> *list); +}; + +} // namespace Quick +} // namespace Qt3DAnimation + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_QUICK_QUICK3DEFFECT_P_H diff --git a/src/quick3d/quick3danimation/items/quick3dchannelmapper_p.h b/src/quick3d/quick3danimation/items/quick3dchannelmapper_p.h index fddaae72d..e44efad68 100644 --- a/src/quick3d/quick3danimation/items/quick3dchannelmapper_p.h +++ b/src/quick3d/quick3danimation/items/quick3dchannelmapper_p.h @@ -66,6 +66,8 @@ class QT3DQUICKANIMATIONSHARED_PRIVATE_EXPORT Quick3DChannelMapper : public QOb { Q_OBJECT Q_PROPERTY(QQmlListProperty<Qt3DAnimation::QChannelMapping> mappings READ qmlMappings CONSTANT) + Q_CLASSINFO("DefaultProperty", "mappings") + public: explicit Quick3DChannelMapper(QObject *parent = nullptr); diff --git a/src/quick3d/quick3danimation/items/quick3dkeyframeanimation.cpp b/src/quick3d/quick3danimation/items/quick3dkeyframeanimation.cpp new file mode 100644 index 000000000..f7cf133fe --- /dev/null +++ b/src/quick3d/quick3danimation/items/quick3dkeyframeanimation.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "quick3dkeyframeanimation_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Quick { + +QQuick3DKeyframeAnimation::QQuick3DKeyframeAnimation(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<Qt3DCore::QTransform> QQuick3DKeyframeAnimation::keyframes() +{ + return QQmlListProperty<Qt3DCore::QTransform>(this, 0, + &QQuick3DKeyframeAnimation::appendKeyframe, + &QQuick3DKeyframeAnimation::keyframeCount, + &QQuick3DKeyframeAnimation::keyframeAt, + &QQuick3DKeyframeAnimation::clearKeyframes); +} + +void QQuick3DKeyframeAnimation::appendKeyframe(QQmlListProperty<Qt3DCore::QTransform> *list, + Qt3DCore::QTransform *transform) +{ + QQuick3DKeyframeAnimation *keyframeAnimation + = qobject_cast<QQuick3DKeyframeAnimation *>(list->object); + if (keyframeAnimation) + keyframeAnimation->parentKeyframeAnimation()->addKeyframe(transform); +} + +int QQuick3DKeyframeAnimation::keyframeCount(QQmlListProperty<Qt3DCore::QTransform> *list) +{ + QQuick3DKeyframeAnimation *keyframeAnimation + = qobject_cast<QQuick3DKeyframeAnimation *>(list->object); + if (keyframeAnimation) + return keyframeAnimation->parentKeyframeAnimation()->keyframeList().count(); + return 0; +} + +Qt3DCore::QTransform *QQuick3DKeyframeAnimation::keyframeAt(QQmlListProperty<Qt3DCore::QTransform> *list, + int index) +{ + QQuick3DKeyframeAnimation *keyframeAnimation + = qobject_cast<QQuick3DKeyframeAnimation *>(list->object); + if (keyframeAnimation) { + return qobject_cast<Qt3DCore::QTransform *>( + keyframeAnimation->parentKeyframeAnimation()->keyframeList().at(index)); + } + return nullptr; +} + +void QQuick3DKeyframeAnimation::clearKeyframes(QQmlListProperty<Qt3DCore::QTransform> *list) +{ + QQuick3DKeyframeAnimation *keyframeAnimation + = qobject_cast<QQuick3DKeyframeAnimation *>(list->object); + if (keyframeAnimation) { + QVector<Qt3DCore::QTransform *> emptyList; + keyframeAnimation->parentKeyframeAnimation()->setKeyframes(emptyList); + } +} + +} // namespace Quick +} // namespace Qt3DAnimation + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3danimation/items/quick3dkeyframeanimation_p.h b/src/quick3d/quick3danimation/items/quick3dkeyframeanimation_p.h new file mode 100644 index 000000000..944cdbe67 --- /dev/null +++ b/src/quick3d/quick3danimation/items/quick3dkeyframeanimation_p.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DANIMATION_QUICK_QUICK3DKEYFRAMEANIMATION_P_H +#define QT3DANIMATION_QUICK_QUICK3DKEYFRAMEANIMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqmllist.h> + +#include <Qt3DAnimation/qkeyframeanimation.h> + +#include <private/qt3dquickanimation_global_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Quick { + +class QT3DQUICKANIMATIONSHARED_PRIVATE_EXPORT QQuick3DKeyframeAnimation : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DCore::QTransform> keyframes READ keyframes) + +public: + QQuick3DKeyframeAnimation(QObject *parent = nullptr); + + inline QKeyframeAnimation *parentKeyframeAnimation() const + { + return qobject_cast<QKeyframeAnimation *>(parent()); + } + + QQmlListProperty<Qt3DCore::QTransform> keyframes(); + +private: + + static void appendKeyframe(QQmlListProperty<Qt3DCore::QTransform> *list, + Qt3DCore::QTransform *transform); + static Qt3DCore::QTransform *keyframeAt(QQmlListProperty<Qt3DCore::QTransform> *list, + int index); + static int keyframeCount(QQmlListProperty<Qt3DCore::QTransform> *list); + static void clearKeyframes(QQmlListProperty<Qt3DCore::QTransform> *list); +}; + +} // namespace Quick +} // namespace Qt3DAnimation + +QT_END_NAMESPACE + +#endif // QT3DANIMATION_QUICK_QUICK3DKEYFRAMEANIMATION_P_H diff --git a/src/quick3d/quick3danimation/items/quick3dmorphinganimation.cpp b/src/quick3d/quick3danimation/items/quick3dmorphinganimation.cpp new file mode 100644 index 000000000..997e2e215 --- /dev/null +++ b/src/quick3d/quick3danimation/items/quick3dmorphinganimation.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "quick3dmorphinganimation_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Quick { + +QQuick3DMorphingAnimation::QQuick3DMorphingAnimation(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<Qt3DAnimation::QMorphTarget> QQuick3DMorphingAnimation::morphTargets() +{ + return QQmlListProperty<Qt3DAnimation::QMorphTarget>(this, 0, + &QQuick3DMorphingAnimation::appendMorphTarget, + &QQuick3DMorphingAnimation::morphTargetCount, + &QQuick3DMorphingAnimation::morphTargetAt, + &QQuick3DMorphingAnimation::clearMorphTargets); +} + +void QQuick3DMorphingAnimation::appendMorphTarget(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list, + Qt3DAnimation::QMorphTarget *morphTarget) +{ + QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(list->object); + if (animation) + animation->parentMorphingAnimation()->addMorphTarget(morphTarget); +} + +int QQuick3DMorphingAnimation::morphTargetCount(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list) +{ + QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(list->object); + if (animation) + return animation->parentMorphingAnimation()->morphTargetList().count(); + return 0; +} + +Qt3DAnimation::QMorphTarget *QQuick3DMorphingAnimation::morphTargetAt(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list, + int index) +{ + QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(list->object); + if (animation) { + return qobject_cast<Qt3DAnimation::QMorphTarget *>( + animation->parentMorphingAnimation()->morphTargetList().at(index)); + } + return nullptr; +} + +void QQuick3DMorphingAnimation::clearMorphTargets(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list) +{ + QQuick3DMorphingAnimation *animation = qobject_cast<QQuick3DMorphingAnimation *>(list->object); + if (animation) { + QVector<Qt3DAnimation::QMorphTarget *> emptyList; + animation->parentMorphingAnimation()->setMorphTargets(emptyList); + } +} + +} // namespace Quick +} // namespace Qt3DAnimation + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3danimation/items/quick3dmorphinganimation_p.h b/src/quick3d/quick3danimation/items/quick3dmorphinganimation_p.h new file mode 100644 index 000000000..31d008a89 --- /dev/null +++ b/src/quick3d/quick3danimation/items/quick3dmorphinganimation_p.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DANIMATION_QUICK_QUICK3DMORPHINGANIMATION_P_H +#define QT3DANIMATION_QUICK_QUICK3DMORPHINGANIMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqmllist.h> + +#include <Qt3DAnimation/qmorphinganimation.h> + +#include <private/qt3dquickanimation_global_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Quick { + +class QT3DQUICKANIMATIONSHARED_PRIVATE_EXPORT QQuick3DMorphingAnimation : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DAnimation::QMorphTarget> morphTargets READ morphTargets) + +public: + QQuick3DMorphingAnimation(QObject *parent = nullptr); + + inline QMorphingAnimation *parentMorphingAnimation() const + { + return qobject_cast<QMorphingAnimation *>(parent()); + } + + QQmlListProperty<Qt3DAnimation::QMorphTarget> morphTargets(); + +private: + + static void appendMorphTarget(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list, + Qt3DAnimation::QMorphTarget *morphTarget); + static Qt3DAnimation::QMorphTarget *morphTargetAt(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list, + int index); + static int morphTargetCount(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list); + static void clearMorphTargets(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list); +}; + +} // namespace Quick +} // namespace Qt3DAnimation + +QT_END_NAMESPACE + +#endif // QT3DANIMATION_QUICK_QUICK3DMORPHINGANIMATION_P_H diff --git a/src/quick3d/quick3danimation/items/quick3dmorphtarget.cpp b/src/quick3d/quick3danimation/items/quick3dmorphtarget.cpp new file mode 100644 index 000000000..81144e186 --- /dev/null +++ b/src/quick3d/quick3danimation/items/quick3dmorphtarget.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "quick3dmorphtarget_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Quick { + +QQuick3DMorphTarget::QQuick3DMorphTarget(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<Qt3DRender::QAttribute> QQuick3DMorphTarget::attributes() +{ + return QQmlListProperty<Qt3DRender::QAttribute>(this, 0, + &QQuick3DMorphTarget::appendAttribute, + &QQuick3DMorphTarget::attributeCount, + &QQuick3DMorphTarget::attributeAt, + &QQuick3DMorphTarget::clearAttributes); +} + +void QQuick3DMorphTarget::appendAttribute(QQmlListProperty<Qt3DRender::QAttribute> *list, Qt3DRender::QAttribute *bar) +{ + QQuick3DMorphTarget *target = qobject_cast<QQuick3DMorphTarget *>(list->object); + if (target) + target->parentMorphTarget()->addAttribute(bar); +} + +int QQuick3DMorphTarget::attributeCount(QQmlListProperty<Qt3DRender::QAttribute> *list) +{ + QQuick3DMorphTarget *target = qobject_cast<QQuick3DMorphTarget *>(list->object); + if (target) + return target->parentMorphTarget()->attributeList().count(); + return 0; +} + +Qt3DRender::QAttribute *QQuick3DMorphTarget::attributeAt(QQmlListProperty<Qt3DRender::QAttribute> *list, int index) +{ + QQuick3DMorphTarget *target = qobject_cast<QQuick3DMorphTarget *>(list->object); + if (target) + return qobject_cast<Qt3DRender::QAttribute *>(target->parentMorphTarget()->attributeList().at(index)); + return nullptr; +} + +void QQuick3DMorphTarget::clearAttributes(QQmlListProperty<Qt3DRender::QAttribute> *list) +{ + QQuick3DMorphTarget *target = qobject_cast<QQuick3DMorphTarget *>(list->object); + if (target) { + QVector<Qt3DRender::QAttribute *> emptyList; + target->parentMorphTarget()->setAttributes(emptyList); + } +} + +} // namespace Quick +} // namespace Qt3DAnimation + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3danimation/items/quick3dmorphtarget_p.h b/src/quick3d/quick3danimation/items/quick3dmorphtarget_p.h new file mode 100644 index 000000000..03b52dfeb --- /dev/null +++ b/src/quick3d/quick3danimation/items/quick3dmorphtarget_p.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DANIMATION_QUICK_QUICK3DMORPHTARGET_P_H +#define QT3DANIMATION_QUICK_QUICK3DMORPHTARGET_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <private/qt3dquickanimation_global_p.h> +#include <QQmlListProperty> +#include <Qt3DAnimation/QMorphTarget> + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Quick { + +class QT3DQUICKANIMATIONSHARED_PRIVATE_EXPORT QQuick3DMorphTarget : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DRender::QAttribute> attributes READ attributes) + +public: + QQuick3DMorphTarget(QObject *parent = nullptr); + + inline QMorphTarget *parentMorphTarget() const { return qobject_cast<QMorphTarget *>(parent()); } + + QQmlListProperty<Qt3DRender::QAttribute> attributes(); + +private: + + static void appendAttribute(QQmlListProperty<Qt3DRender::QAttribute> *list, Qt3DRender::QAttribute *bar); + static Qt3DRender::QAttribute *attributeAt(QQmlListProperty<Qt3DRender::QAttribute> *list, int index); + static int attributeCount(QQmlListProperty<Qt3DRender::QAttribute> *list); + static void clearAttributes(QQmlListProperty<Qt3DRender::QAttribute> *list); +}; + +} // namespace Quick +} // namespace Qt3DAnimation + +QT_END_NAMESPACE + +#endif // QT3DANIMATION_QUICK_QUICK3DMORPHTARGET_P_H diff --git a/src/quick3d/quick3danimation/items/quick3dvertexblendanimation.cpp b/src/quick3d/quick3danimation/items/quick3dvertexblendanimation.cpp new file mode 100644 index 000000000..2dffb7858 --- /dev/null +++ b/src/quick3d/quick3danimation/items/quick3dvertexblendanimation.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "quick3dvertexblendanimation_p.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Quick { + +QQuick3DVertexBlendAnimation::QQuick3DVertexBlendAnimation(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<Qt3DAnimation::QMorphTarget> QQuick3DVertexBlendAnimation::morphTargets() +{ + return QQmlListProperty<Qt3DAnimation::QMorphTarget>(this, 0, + &QQuick3DVertexBlendAnimation::appendMorphTarget, + &QQuick3DVertexBlendAnimation::morphTargetCount, + &QQuick3DVertexBlendAnimation::morphTargetAt, + &QQuick3DVertexBlendAnimation::clearMorphTargets); +} + +void QQuick3DVertexBlendAnimation::appendMorphTarget( + QQmlListProperty<Qt3DAnimation::QMorphTarget> *list, + Qt3DAnimation::QMorphTarget *morphTarget) +{ + QQuick3DVertexBlendAnimation *animation + = qobject_cast<QQuick3DVertexBlendAnimation *>(list->object); + if (animation) + animation->parentVertexBlendAnimation()->addMorphTarget(morphTarget); +} + +int QQuick3DVertexBlendAnimation::morphTargetCount( + QQmlListProperty<Qt3DAnimation::QMorphTarget> *list) +{ + QQuick3DVertexBlendAnimation *animation + = qobject_cast<QQuick3DVertexBlendAnimation *>(list->object); + if (animation) + return animation->parentVertexBlendAnimation()->morphTargetList().count(); + return 0; +} + +Qt3DAnimation::QMorphTarget *QQuick3DVertexBlendAnimation::morphTargetAt( + QQmlListProperty<Qt3DAnimation::QMorphTarget> *list, + int index) +{ + QQuick3DVertexBlendAnimation *animation + = qobject_cast<QQuick3DVertexBlendAnimation *>(list->object); + if (animation) { + return qobject_cast<Qt3DAnimation::QMorphTarget *>( + animation->parentVertexBlendAnimation()->morphTargetList().at(index)); + } + return nullptr; +} + +void QQuick3DVertexBlendAnimation::clearMorphTargets(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list) +{ + QQuick3DVertexBlendAnimation *animation + = qobject_cast<QQuick3DVertexBlendAnimation *>(list->object); + if (animation) { + QVector<Qt3DAnimation::QMorphTarget *> emptyList; + animation->parentVertexBlendAnimation()->setMorphTargets(emptyList); + } +} + +} // namespace Quick +} // namespace Qt3DAnimation + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3danimation/items/quick3dvertexblendanimation_p.h b/src/quick3d/quick3danimation/items/quick3dvertexblendanimation_p.h new file mode 100644 index 000000000..6be2d662f --- /dev/null +++ b/src/quick3d/quick3danimation/items/quick3dvertexblendanimation_p.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DANIMATION_QUICK_QUICK3DVERTEXBLENDANIMATION_P_H +#define QT3DANIMATION_QUICK_QUICK3DVERTEXBLENDANIMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtQml/qqmllist.h> + +#include <Qt3DAnimation/qvertexblendanimation.h> + +#include <private/qt3dquickanimation_global_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Quick { + +class QT3DQUICKANIMATIONSHARED_PRIVATE_EXPORT QQuick3DVertexBlendAnimation : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<Qt3DAnimation::QMorphTarget> morphTargets READ morphTargets) + +public: + QQuick3DVertexBlendAnimation(QObject *parent = nullptr); + + inline QVertexBlendAnimation *parentVertexBlendAnimation() const + { + return qobject_cast<QVertexBlendAnimation *>(parent()); + } + + QQmlListProperty<Qt3DAnimation::QMorphTarget> morphTargets(); + +private: + + static void appendMorphTarget(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list, + Qt3DAnimation::QMorphTarget *morphTarget); + static Qt3DAnimation::QMorphTarget *morphTargetAt( + QQmlListProperty<Qt3DAnimation::QMorphTarget> *list, + int index); + static int morphTargetCount(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list); + static void clearMorphTargets(QQmlListProperty<Qt3DAnimation::QMorphTarget> *list); +}; + +} // namespace Quick +} // namespace Qt3DAnimation + +QT_END_NAMESPACE + +#endif // QT3DANIMATION_QUICK_QUICK3DMORPHINGANIMATION_P_H |