summaryrefslogtreecommitdiffstats
path: root/src/animation/frontend
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-08-24 11:30:09 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-09-02 18:10:23 +0000
commitc8f28a88e73ff5e9f612cd55eec40196bd68d8cd (patch)
treed220fd5406fe54659a2f78d976573d3b813574e9 /src/animation/frontend
parent2574584da4c6ad2ce96103e39bce2dbd84f5a8df (diff)
Add QSkeletonMapping to Qt3DAnimation
Allows to easily map animation channels onto a target QAbstractSkeleton. Change-Id: I53c348fe19e00f7b57653f5525b67920319f83d6 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/animation/frontend')
-rw-r--r--src/animation/frontend/frontend.pri5
-rw-r--r--src/animation/frontend/qskeletonmapping.cpp108
-rw-r--r--src/animation/frontend/qskeletonmapping.h85
-rw-r--r--src/animation/frontend/qskeletonmapping_p.h84
4 files changed, 281 insertions, 1 deletions
diff --git a/src/animation/frontend/frontend.pri b/src/animation/frontend/frontend.pri
index 6735b75c3..48b1cb6b1 100644
--- a/src/animation/frontend/frontend.pri
+++ b/src/animation/frontend/frontend.pri
@@ -52,7 +52,9 @@ HEADERS += \
$$PWD/qabstractchannelmapping.h \
$$PWD/qabstractchannelmapping_p.h \
$$PWD/qchannelmappingcreatedchange_p.h \
- $$PWD/qchannelmappingcreatedchange_p_p.h
+ $$PWD/qchannelmappingcreatedchange_p_p.h \
+ $$PWD/qskeletonmapping.h \
+ $$PWD/qskeletonmapping_p.h
SOURCES += \
$$PWD/qanimationaspect.cpp \
@@ -84,5 +86,6 @@ SOURCES += \
$$PWD/qclock.cpp \
$$PWD/qabstractchannelmapping.cpp \
$$PWD/qchannelmappingcreatedchange.cpp \
+ $$PWD/qskeletonmapping.cpp
INCLUDEPATH += $$PWD
diff --git a/src/animation/frontend/qskeletonmapping.cpp b/src/animation/frontend/qskeletonmapping.cpp
new file mode 100644
index 000000000..7569a5bab
--- /dev/null
+++ b/src/animation/frontend/qskeletonmapping.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** 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 "qskeletonmapping.h"
+#include "qskeletonmapping_p.h"
+#include <Qt3DCore/qabstractskeleton.h>
+
+#include <Qt3DAnimation/private/qchannelmappingcreatedchange_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DAnimation {
+
+QSkeletonMappingPrivate::QSkeletonMappingPrivate()
+ : QAbstractChannelMappingPrivate()
+ , m_skeleton(nullptr)
+{
+ m_mappingType = QChannelMappingCreatedChangeBase::SkeletonMapping;
+}
+
+QSkeletonMapping::QSkeletonMapping(Qt3DCore::QNode *parent)
+ : QAbstractChannelMapping(*new QSkeletonMappingPrivate, parent)
+{
+}
+
+QSkeletonMapping::QSkeletonMapping(QSkeletonMappingPrivate &dd, Qt3DCore::QNode *parent)
+ : QAbstractChannelMapping(dd, parent)
+{
+}
+
+QSkeletonMapping::~QSkeletonMapping()
+{
+}
+
+Qt3DCore::QAbstractSkeleton *QSkeletonMapping::skeleton() const
+{
+ Q_D(const QSkeletonMapping);
+ return d->m_skeleton;
+}
+
+void QSkeletonMapping::setSkeleton(Qt3DCore::QAbstractSkeleton *skeleton)
+{
+ Q_D(QSkeletonMapping);
+ if (d->m_skeleton == skeleton)
+ return;
+
+ if (d->m_skeleton)
+ d->unregisterDestructionHelper(d->m_skeleton);
+
+ if (skeleton && !skeleton->parent())
+ skeleton->setParent(this);
+ d->m_skeleton = skeleton;
+
+ // Ensures proper bookkeeping
+ if (d->m_skeleton)
+ d->registerDestructionHelper(d->m_skeleton, &QSkeletonMapping::setSkeleton, d->m_skeleton);
+
+ emit skeletonChanged(skeleton);
+}
+
+Qt3DCore::QNodeCreatedChangeBasePtr QSkeletonMapping::createNodeCreationChange() const
+{
+ auto creationChange = QChannelMappingCreatedChangePtr<QSkeletonMappingData>::create(this);
+ auto &data = creationChange->data;
+ Q_D(const QSkeletonMapping);
+ data.skeletonId = Qt3DCore::qIdForNode(d->m_skeleton);
+ return creationChange;
+}
+
+} // namespace Qt3DAnimation
+
+QT_END_NAMESPACE
diff --git a/src/animation/frontend/qskeletonmapping.h b/src/animation/frontend/qskeletonmapping.h
new file mode 100644
index 000000000..2c698da8e
--- /dev/null
+++ b/src/animation/frontend/qskeletonmapping.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** 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_QSKELETONMAPPING_H
+#define QT3DANIMATION_QSKELETONMAPPING_H
+
+#include <Qt3DAnimation/qabstractchannelmapping.h>
+#include <Qt3DAnimation/qt3danimation_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+class QAbstractSkeleton;
+}
+
+namespace Qt3DAnimation {
+
+class QSkeletonMappingPrivate;
+
+class QT3DANIMATIONSHARED_EXPORT QSkeletonMapping : public QAbstractChannelMapping
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DCore::QAbstractSkeleton* skeleton READ skeleton WRITE setSkeleton NOTIFY skeletonChanged)
+
+public:
+ explicit QSkeletonMapping(Qt3DCore::QNode *parent = nullptr);
+ ~QSkeletonMapping();
+
+ Qt3DCore::QAbstractSkeleton *skeleton() const;
+
+public Q_SLOTS:
+ void setSkeleton(Qt3DCore::QAbstractSkeleton *skeleton);
+
+Q_SIGNALS:
+ void skeletonChanged(Qt3DCore::QAbstractSkeleton *skeleton);
+
+protected:
+ QSkeletonMapping(QSkeletonMappingPrivate &dd, Qt3DCore::QNode *parent = nullptr);
+
+private:
+ Q_DECLARE_PRIVATE(QSkeletonMapping)
+ Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const Q_DECL_OVERRIDE;
+};
+
+} // namespace Qt3DAnimation
+
+QT_END_NAMESPACE
+
+#endif // QT3DANIMATION_QSKELETONMAPPING_H
diff --git a/src/animation/frontend/qskeletonmapping_p.h b/src/animation/frontend/qskeletonmapping_p.h
new file mode 100644
index 000000000..19f9c70ae
--- /dev/null
+++ b/src/animation/frontend/qskeletonmapping_p.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** 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_QSKELETONMAPPING_P_H
+#define QT3DANIMATION_QSKELETONMAPPING_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 <Qt3DAnimation//private/qabstractchannelmapping_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+class QAbstractSkeleton;
+}
+
+namespace Qt3DAnimation {
+
+class QSkeletonMappingPrivate : public QAbstractChannelMappingPrivate
+{
+public:
+ QSkeletonMappingPrivate();
+
+ Q_DECLARE_PUBLIC(QSkeletonMapping)
+
+ Qt3DCore::QAbstractSkeleton *m_skeleton;
+};
+
+struct QSkeletonMappingData
+{
+ Qt3DCore::QNodeId skeletonId;
+};
+
+} // namespace Qt3DAnimation
+
+
+QT_END_NAMESPACE
+
+#endif // QT3DANIMATION_QSKELETONMAPPING_P_H