summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2017-02-13 15:14:04 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2017-05-09 09:00:18 +0000
commit2daf7fbf486ac3e3265df2d6b6864b4d21826052 (patch)
treeaafe5c8504dd8f9265ec556c6aec224455d8766d
parentcdf18bafbfbfcc2f7cf178ab0fe23ac9f7cf717a (diff)
Add quick3d class for VertexBlendAnimation
Add the missing class for VertexBlendAnimation so that it can be used from qml. Task-number: QTBUG-60618 Change-Id: If47dccf5e44d0158053ca3b9122fcef91d73ea93 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/animation/frontend/qvertexblendanimation.cpp6
-rw-r--r--src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp3
-rw-r--r--src/quick3d/quick3danimation/items/items.pri6
-rw-r--r--src/quick3d/quick3danimation/items/quick3dvertexblendanimation.cpp104
-rw-r--r--src/quick3d/quick3danimation/items/quick3dvertexblendanimation_p.h93
5 files changed, 209 insertions, 3 deletions
diff --git a/src/animation/frontend/qvertexblendanimation.cpp b/src/animation/frontend/qvertexblendanimation.cpp
index efc36e45c..3ddd83bf0 100644
--- a/src/animation/frontend/qvertexblendanimation.cpp
+++ b/src/animation/frontend/qvertexblendanimation.cpp
@@ -125,7 +125,7 @@ namespace Qt3DAnimation {
\readonly
*/
/*!
- \qmlproperty VertexBlendAnimation::target
+ \qmlproperty GeometryRenderer VertexBlendAnimation::target
Holds the target GeometryRenderer the morphing animation is applied to.
*/
/*!
@@ -135,6 +135,10 @@ namespace Qt3DAnimation {
is usually same as the name of the parent entity of the target GeometryRenderer, but
does not have to be.
*/
+/*!
+ \qmlproperty list<MorphTarget> VertexBlendAnimation::morphTargets
+ Holds the list of \l {MorphTarget}{morph targets} added to the animation.
+*/
QVertexBlendAnimationPrivate::QVertexBlendAnimationPrivate()
: QAbstractAnimationPrivate(QAbstractAnimation::VertexBlendAnimation)
diff --git a/src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp b/src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp
index 87c137763..7feeaf84c 100644
--- a/src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp
+++ b/src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp
@@ -55,6 +55,7 @@
#include <Qt3DAnimation/qmorphinganimation.h>
#include <Qt3DAnimation/qanimationgroup.h>
#include <Qt3DAnimation/qmorphtarget.h>
+#include <Qt3DAnimation/qvertexblendanimation.h>
#include <Qt3DQuickAnimation/private/qt3dquickanimation_global_p.h>
#include <Qt3DQuickAnimation/private/quick3dchannelmapper_p.h>
@@ -63,6 +64,7 @@
#include <Qt3DQuickAnimation/private/quick3danimationcontroller_p.h>
#include <Qt3DQuickAnimation/private/quick3dmorphtarget_p.h>
#include <Qt3DQuickAnimation/private/quick3dmorphinganimation_p.h>
+#include <Qt3DQuickAnimation/private/quick3dvertexblendanimation_p.h>
QT_BEGIN_NAMESPACE
@@ -92,6 +94,7 @@ void Qt3DQuick3DAnimationPlugin::registerTypes(const char *uri)
qmlRegisterExtendedType<Qt3DAnimation::QAnimationController, Qt3DAnimation::Quick::QQuick3DAnimationController>(uri, 2, 9, "AnimationController");
qmlRegisterExtendedType<Qt3DAnimation::QMorphingAnimation, Qt3DAnimation::Quick::QQuick3DMorphingAnimation>(uri, 2, 9, "MorphingAnimation");
qmlRegisterExtendedType<Qt3DAnimation::QMorphTarget, Qt3DAnimation::Quick::QQuick3DMorphTarget>(uri, 2, 9, "MorphTarget");
+ qmlRegisterExtendedType<Qt3DAnimation::QVertexBlendAnimation, Qt3DAnimation::Quick::QQuick3DVertexBlendAnimation>(uri, 2, 9, "VertexBlendAnimation");
}
QT_END_NAMESPACE
diff --git a/src/quick3d/quick3danimation/items/items.pri b/src/quick3d/quick3danimation/items/items.pri
index 3f19965b5..27adabbe4 100644
--- a/src/quick3d/quick3danimation/items/items.pri
+++ b/src/quick3d/quick3danimation/items/items.pri
@@ -4,7 +4,8 @@ SOURCES += \
$$PWD/quick3danimationgroup.cpp \
$$PWD/quick3dkeyframeanimation.cpp \
$$PWD/quick3dmorphinganimation.cpp \
- $$PWD/quick3dmorphtarget.cpp
+ $$PWD/quick3dmorphtarget.cpp \
+ $$PWD/quick3dvertexblendanimation.cpp
HEADERS += \
$$PWD/quick3dchannelmapper_p.h \
@@ -12,6 +13,7 @@ HEADERS += \
$$PWD/quick3danimationgroup_p.h \
$$PWD/quick3dkeyframeanimation_p.h \
$$PWD/quick3dmorphinganimation_p.h \
- $$PWD/quick3dmorphtarget_p.h
+ $$PWD/quick3dmorphtarget_p.h \
+ $$PWD/quick3dvertexblendanimation_p.h
INCLUDEPATH += $$PWD
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