diff options
Diffstat (limited to 'src/extras/animations')
22 files changed, 0 insertions, 2685 deletions
diff --git a/src/extras/animations/animations.pri b/src/extras/animations/animations.pri deleted file mode 100644 index 71d6099fc..000000000 --- a/src/extras/animations/animations.pri +++ /dev/null @@ -1,26 +0,0 @@ -HEADERS += \ - $$PWD/qanimationcontroller.h \ - $$PWD/qanimationcontroller_p.h \ - $$PWD/qanimationgroup.h \ - $$PWD/qanimationgroup_p.h \ - $$PWD/qkeyframeanimation.h \ - $$PWD/qkeyframeanimation_p.h \ - $$PWD/qmorphinganimation.h \ - $$PWD/qmorphinganimation_p.h \ - $$PWD/qabstractanimation.h \ - $$PWD/qabstractanimation_p.h \ - $$PWD/qmorphtarget.h \ - $$PWD/qmorphtarget_p.h \ - $$PWD/qvertexblendanimation.h \ - $$PWD/qvertexblendanimation_p.h - -SOURCES += \ - $$PWD/qanimationcontroller.cpp \ - $$PWD/qanimationgroup.cpp \ - $$PWD/qkeyframeanimation.cpp \ - $$PWD/qmorphinganimation.cpp \ - $$PWD/qabstractanimation.cpp \ - $$PWD/qmorphtarget.cpp \ - $$PWD/qvertexblendanimation.cpp - -INCLUDEPATH += $$PWD diff --git a/src/extras/animations/qabstractanimation.cpp b/src/extras/animations/qabstractanimation.cpp deleted file mode 100644 index f87455c18..000000000 --- a/src/extras/animations/qabstractanimation.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** 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 "qabstractanimation.h" -#include "Qt3DExtras/private/qabstractanimation_p.h" - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -QAbstractAnimationPrivate::QAbstractAnimationPrivate(QAbstractAnimation::AnimationType type) - : QObjectPrivate() - , m_animationType(type) - , m_position(0.0f) - , m_duration(0.0f) -{ - -} - -QAbstractAnimation::QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent) - : QObject(dd, parent) -{ - -} - -QString QAbstractAnimation::animationName() const -{ - Q_D(const QAbstractAnimation); - return d->m_animationName; -} - -QAbstractAnimation::AnimationType QAbstractAnimation::animationType() const -{ - Q_D(const QAbstractAnimation); - return d->m_animationType; -} - -float QAbstractAnimation::position() const -{ - Q_D(const QAbstractAnimation); - return d->m_position; -} - -float QAbstractAnimation::duration() const -{ - Q_D(const QAbstractAnimation); - return d->m_duration; -} - -void QAbstractAnimation::setAnimationName(const QString &name) -{ - Q_D(QAbstractAnimation); - if (name != d->m_animationName) { - d->m_animationName = name; - emit animationNameChanged(name); - } -} - -void QAbstractAnimation::setPosition(float position) -{ - Q_D(QAbstractAnimation); - if (!qFuzzyCompare(position, d->m_position)) { - d->m_position = position; - emit positionChanged(position); - } -} - -void QAbstractAnimation::setDuration(float duration) -{ - Q_D(QAbstractAnimation); - if (!qFuzzyCompare(duration, d->m_duration)) { - d->m_duration = duration; - emit durationChanged(duration); - } -} - -} // Qt3DExtras - -QT_END_NAMESPACE diff --git a/src/extras/animations/qabstractanimation.h b/src/extras/animations/qabstractanimation.h deleted file mode 100644 index 242fe293a..000000000 --- a/src/extras/animations/qabstractanimation.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QABSTRACTANIMATION_H -#define QT3DEXTRAS_QABSTRACTANIMATION_H - -#include <QtCore/qobject.h> -#include <QtCore/qvector.h> - -#include <Qt3DExtras/qt3dextras_global.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QAbstractAnimationPrivate; - -class QT3DEXTRASSHARED_EXPORT QAbstractAnimation : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString animationName READ animationName WRITE setAnimationName NOTIFY animationNameChanged) - Q_PROPERTY(QAbstractAnimation::AnimationType animationType READ animationType CONSTANT) - Q_PROPERTY(float position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(float duration READ duration NOTIFY durationChanged) - -public: - enum AnimationType { - KeyframeAnimation = 1, - MorphingAnimation = 2, - VertexBlendAnimation = 3, - }; - - QString animationName() const; - QAbstractAnimation::AnimationType animationType() const; - float position() const; - float duration() const; - -public Q_SLOTS: - void setAnimationName(const QString &name); - void setPosition(float position); - -protected: - explicit QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent = nullptr); - - void setDuration(float duration); - -Q_SIGNALS: - void animationNameChanged(const QString &name); - void positionChanged(float position); - void durationChanged(float duration); - -private: - Q_DECLARE_PRIVATE(QAbstractAnimation) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QABSTRACTANIMATION_H diff --git a/src/extras/animations/qabstractanimation_p.h b/src/extras/animations/qabstractanimation_p.h deleted file mode 100644 index 1370ef2c7..000000000 --- a/src/extras/animations/qabstractanimation_p.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QABSTRACTANIMATION_P_H -#define QT3DEXTRAS_QABSTRACTANIMATION_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/qobject_p.h> -#include <Qt3DExtras/QAbstractAnimation> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QAbstractAnimationPrivate : public QObjectPrivate -{ -public: - QAbstractAnimationPrivate(QAbstractAnimation::AnimationType type); - - QString m_animationName; - QAbstractAnimation::AnimationType m_animationType; - float m_position; - float m_duration; - - Q_DECLARE_PUBLIC(QAbstractAnimation) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QANIMATIONCONTROLLER_P_H diff --git a/src/extras/animations/qanimationcontroller.cpp b/src/extras/animations/qanimationcontroller.cpp deleted file mode 100644 index adef3d45c..000000000 --- a/src/extras/animations/qanimationcontroller.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** 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 "qanimationcontroller.h" -#include "qanimationgroup.h" - -#include <private/qanimationcontroller_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -QAnimationControllerPrivate::QAnimationControllerPrivate() - : QObjectPrivate() - , m_activeAnimationGroup(0) - , m_position(0.0f) - , m_positionScale(1.0f) - , m_positionOffset(0.0f) - , m_entity(nullptr) - , m_recursive(true) -{ - -} - -void QAnimationControllerPrivate::updatePosition(float position) -{ - m_position = position; - if (m_activeAnimationGroup >= 0 && m_activeAnimationGroup < m_animationGroups.size()) { - const float pos = m_positionScale * position + m_positionOffset; - m_animationGroups[m_activeAnimationGroup]->setPosition(pos); - } -} - -QAnimationGroup *QAnimationControllerPrivate::findGroup(const QString &name) -{ - for (QAnimationGroup *g : m_animationGroups) { - if (g->name() == name) - return g; - } - return nullptr; -} - -void QAnimationControllerPrivate::extractAnimations() -{ - Q_Q(QAnimationController); - if (!m_entity) - return; - QList<Qt3DExtras::QAbstractAnimation *> animations - = m_entity->findChildren<Qt3DExtras::QAbstractAnimation *>(QString(), - m_recursive ? Qt::FindChildrenRecursively : Qt::FindDirectChildrenOnly); - if (animations.size() > 0) { - for (Qt3DExtras::QAbstractAnimation *a : animations) { - QAnimationGroup *group = findGroup(a->animationName()); - if (!group) { - group = new QAnimationGroup(q); - group->setName(a->animationName()); - m_animationGroups.push_back(group); - } - group->addAnimation(a); - } - } -} -void QAnimationControllerPrivate::clearAnimations() -{ - for (Qt3DExtras::QAnimationGroup *a : m_animationGroups) - a->deleteLater(); - m_animationGroups.clear(); - m_activeAnimationGroup = 0; -} - -QAnimationController::QAnimationController(QObject *parent) - : QObject(*new QAnimationControllerPrivate, parent) -{ - -} - -QVector<QAnimationGroup *> QAnimationController::animationGroupList() -{ - Q_D(QAnimationController); - return d->m_animationGroups; -} - -int QAnimationController::activeAnimationGroup() const -{ - Q_D(const QAnimationController); - return d->m_activeAnimationGroup; -} - -float QAnimationController::position() const -{ - Q_D(const QAnimationController); - return d->m_position; -} - -float QAnimationController::positionScale() const -{ - Q_D(const QAnimationController); - return d->m_positionScale; -} - -float QAnimationController::positionOffset() const -{ - Q_D(const QAnimationController); - return d->m_positionOffset; -} - -Qt3DCore::QEntity *QAnimationController::entity() const -{ - Q_D(const QAnimationController); - return d->m_entity; -} - -bool QAnimationController::recursive() const -{ - Q_D(const QAnimationController); - return d->m_recursive; -} - -void QAnimationController::setAnimationGroups(const QVector<QAnimationGroup *> &animationGroups) -{ - Q_D(QAnimationController); - d->m_animationGroups = animationGroups; - if (d->m_activeAnimationGroup >= d->m_animationGroups.size()) - d->m_activeAnimationGroup = 0; - d->updatePosition(d->m_position); -} - -void QAnimationController::addAnimationGroup(Qt3DExtras::QAnimationGroup *animationGroup) -{ - Q_D(QAnimationController); - if (!d->m_animationGroups.contains(animationGroup)) - d->m_animationGroups.push_back(animationGroup); -} - -void QAnimationController::removeAnimationGroup(Qt3DExtras::QAnimationGroup *animationGroup) -{ - Q_D(QAnimationController); - if (d->m_animationGroups.contains(animationGroup)) - d->m_animationGroups.removeAll(animationGroup); - if (d->m_activeAnimationGroup >= d->m_animationGroups.size()) - d->m_activeAnimationGroup = 0; -} - -void QAnimationController::setActiveAnimationGroup(int index) -{ - Q_D(QAnimationController); - if (d->m_activeAnimationGroup != index) { - d->m_activeAnimationGroup = index; - d->updatePosition(d->m_position); - emit activeAnimationGroupChanged(index); - } -} -void QAnimationController::setPosition(float position) -{ - Q_D(QAnimationController); - if (!qFuzzyCompare(d->m_position, position)) { - d->updatePosition(position); - emit positionChanged(position); - } -} - -void QAnimationController::setPositionScale(float scale) -{ - Q_D(QAnimationController); - if (!qFuzzyCompare(d->m_positionScale, scale)) { - d->m_positionScale = scale; - emit positionScaleChanged(scale); - } -} - -void QAnimationController::setPositionOffset(float offset) -{ - Q_D(QAnimationController); - if (!qFuzzyCompare(d->m_positionOffset, offset)) { - d->m_positionOffset = offset; - emit positionOffsetChanged(offset); - } -} - -void QAnimationController::setEntity(Qt3DCore::QEntity *entity) -{ - Q_D(QAnimationController); - if (d->m_entity != entity) { - d->clearAnimations(); - d->m_entity = entity; - d->extractAnimations(); - d->updatePosition(d->m_position); - emit entityChanged(entity); - } -} - -void QAnimationController::setRecursive(bool recursive) -{ - Q_D(QAnimationController); - if (d->m_recursive != recursive) { - d->m_recursive = recursive; - emit recursiveChanged(recursive); - } -} - -int QAnimationController::getAnimationIndex(const QString &name) const -{ - Q_D(const QAnimationController); - for (int i = 0; i < d->m_animationGroups.size(); ++i) { - if (d->m_animationGroups[i]->name() == name) - return i; - } - return -1; -} - -QAnimationGroup *QAnimationController::getGroup(int index) const -{ - Q_D(const QAnimationController); - return d->m_animationGroups.at(index); -} - -} // Qt3DExtras - -QT_END_NAMESPACE diff --git a/src/extras/animations/qanimationcontroller.h b/src/extras/animations/qanimationcontroller.h deleted file mode 100644 index 4ee32dd8b..000000000 --- a/src/extras/animations/qanimationcontroller.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QANIMATIONCONTROLLER_H -#define QT3DEXTRAS_QANIMATIONCONTROLLER_H - -#include <Qt3DExtras/qkeyframeanimation.h> -#include <Qt3DExtras/qanimationgroup.h> -#include <Qt3DCore/qentity.h> - -#include <Qt3DExtras/qt3dextras_global.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QAnimationControllerPrivate; - -class QT3DEXTRASSHARED_EXPORT QAnimationController : public QObject -{ - Q_OBJECT - Q_PROPERTY(int activeAnimationGroup READ activeAnimationGroup WRITE setActiveAnimationGroup NOTIFY activeAnimationGroupChanged) - Q_PROPERTY(float position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(float positionScale READ positionScale WRITE setPositionScale NOTIFY positionScaleChanged) - Q_PROPERTY(float positionOffset READ positionOffset WRITE setPositionOffset NOTIFY positionOffsetChanged) - Q_PROPERTY(Qt3DCore::QEntity *entity READ entity WRITE setEntity NOTIFY entityChanged) - Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged) - -public: - QAnimationController(QObject *parent = nullptr); - - QVector<Qt3DExtras::QAnimationGroup *> animationGroupList(); - - int activeAnimationGroup() const; - float position() const; - float positionScale() const; - float positionOffset() const; - Qt3DCore::QEntity *entity() const; - bool recursive() const; - - void setAnimationGroups(const QVector<Qt3DExtras::QAnimationGroup *> &animationGroups); - void addAnimationGroup(Qt3DExtras::QAnimationGroup *animationGroups); - void removeAnimationGroup(Qt3DExtras::QAnimationGroup *animationGroups); - - Q_INVOKABLE int getAnimationIndex(const QString &name) const; - Q_INVOKABLE Qt3DExtras::QAnimationGroup *getGroup(int index) const; - -public Q_SLOTS: - void setActiveAnimationGroup(int index); - void setPosition(float position); - void setPositionScale(float scale); - void setPositionOffset(float offset); - void setEntity(Qt3DCore::QEntity *entity); - void setRecursive(bool recursive); - -Q_SIGNALS: - void activeAnimationGroupChanged(int index); - void positionChanged(float position); - void positionScaleChanged(float scale); - void positionOffsetChanged(float offset); - void entityChanged(Qt3DCore::QEntity *entity); - void recursiveChanged(bool recursive); - -private: - Q_DECLARE_PRIVATE(QAnimationController) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QANIMATIONCONTROLLER_H diff --git a/src/extras/animations/qanimationcontroller_p.h b/src/extras/animations/qanimationcontroller_p.h deleted file mode 100644 index dd5079ef5..000000000 --- a/src/extras/animations/qanimationcontroller_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QANIMATIONCONTROLLER_P_H -#define QT3DEXTRAS_QANIMATIONCONTROLLER_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/qobject_p.h> -#include <Qt3DExtras/QAnimationGroup> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QAnimationControllerPrivate : public QObjectPrivate -{ -public: - QAnimationControllerPrivate(); - - QString m_name; - int m_activeAnimationGroup; - QVector<QAnimationGroup *> m_animationGroups; - float m_position; - float m_positionScale; - float m_positionOffset; - Qt3DCore::QEntity *m_entity; - bool m_recursive; - - void updatePosition(float position); - void extractAnimations(); - void clearAnimations(); - QAnimationGroup *findGroup(const QString &name); - - Q_DECLARE_PUBLIC(QAnimationController) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QANIMATIONCONTROLLER_P_H diff --git a/src/extras/animations/qanimationgroup.cpp b/src/extras/animations/qanimationgroup.cpp deleted file mode 100644 index e9febe811..000000000 --- a/src/extras/animations/qanimationgroup.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** 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 "qanimationgroup.h" -#include "Qt3DExtras/private/qanimationgroup_p.h" - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -QAnimationGroupPrivate::QAnimationGroupPrivate() - : QObjectPrivate() - , m_position(0.0f) - , m_duration(0.0f) -{ - -} - -void QAnimationGroupPrivate::updatePosition(float position) -{ - m_position = position; - for (QAbstractAnimation *aa : m_animations) - aa->setPosition(position); -} - -QAnimationGroup::QAnimationGroup(QObject *parent) - : QObject(*new QAnimationGroupPrivate, parent) -{ - -} - -QString QAnimationGroup::name() const -{ - Q_D(const QAnimationGroup); - return d->m_name; -} - -QVector<Qt3DExtras::QAbstractAnimation *> QAnimationGroup::animationList() -{ - Q_D(QAnimationGroup); - return d->m_animations; -} - -float QAnimationGroup::position() const -{ - Q_D(const QAnimationGroup); - return d->m_position; -} - -float QAnimationGroup::duration() const -{ - Q_D(const QAnimationGroup); - return d->m_duration; -} - -void QAnimationGroup::setName(const QString &name) -{ - Q_D(QAnimationGroup); - if (d->m_name != name) { - d->m_name = name; - emit nameChanged(name); - } -} - -void QAnimationGroup::setAnimations(const QVector<Qt3DExtras::QAbstractAnimation *> &animations) -{ - Q_D(QAnimationGroup); - d->m_animations = animations; - d->m_duration = 0.0f; - for (const Qt3DExtras::QAbstractAnimation *a : animations) - d->m_duration = qMax(d->m_duration, a->duration()); -} - -void QAnimationGroup::addAnimation(QAbstractAnimation *animation) -{ - Q_D(QAnimationGroup); - d->m_animations.push_back(animation); - d->m_duration = qMax(d->m_duration, animation->duration()); -} - -void QAnimationGroup::setPosition(float position) -{ - Q_D(QAnimationGroup); - if (!qFuzzyCompare(d->m_position, position)) { - d->updatePosition(position); - emit positionChanged(position); - } -} - -} // Qt3DExtras - -QT_END_NAMESPACE diff --git a/src/extras/animations/qanimationgroup.h b/src/extras/animations/qanimationgroup.h deleted file mode 100644 index 4595a2082..000000000 --- a/src/extras/animations/qanimationgroup.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QANIMATIONGROUP_H -#define QT3DEXTRAS_QANIMATIONGROUP_H - -#include <qobject.h> - -#include <Qt3DExtras/qabstractanimation.h> - -#include <Qt3DExtras/qt3dextras_global.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QAnimationGroupPrivate; - -class QT3DEXTRASSHARED_EXPORT QAnimationGroup : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(float position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(float duration READ duration NOTIFY durationChanged) - -public: - explicit QAnimationGroup(QObject *parent = nullptr); - - QString name() const; - QVector<Qt3DExtras::QAbstractAnimation *> animationList(); - float position() const; - float duration() const; - - void setAnimations(const QVector<Qt3DExtras::QAbstractAnimation *> &animations); - void addAnimation(Qt3DExtras::QAbstractAnimation *animation); - void removeAnimation(Qt3DExtras::QAbstractAnimation *animation); - -public Q_SLOTS: - void setName(const QString &name); - void setPosition(float position); - -Q_SIGNALS: - void nameChanged(const QString &name); - void positionChanged(float position); - void durationChanged(float duration); - -private: - - Q_DECLARE_PRIVATE(QAnimationGroup) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QANIMATIONGROUP_H diff --git a/src/extras/animations/qanimationgroup_p.h b/src/extras/animations/qanimationgroup_p.h deleted file mode 100644 index cffe44636..000000000 --- a/src/extras/animations/qanimationgroup_p.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QANIMATIONGROUP_P_H -#define QT3DEXTRAS_QANIMATIONGROUP_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/qobject_p.h> -#include <Qt3DExtras/QAnimationGroup> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QAnimationGroupPrivate : public QObjectPrivate -{ -public: - QAnimationGroupPrivate(); - - QString m_name; - QVector<Qt3DExtras::QAbstractAnimation *> m_animations; - float m_position; - float m_duration; - - void updatePosition(float position); - - Q_DECLARE_PUBLIC(QAnimationGroup) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QANIMATIONGROUP_P_H diff --git a/src/extras/animations/qkeyframeanimation.cpp b/src/extras/animations/qkeyframeanimation.cpp deleted file mode 100644 index 425cbe0df..000000000 --- a/src/extras/animations/qkeyframeanimation.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/**************************************************************************** -** -** 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 "qkeyframeanimation.h" -#include "Qt3DExtras/private/qkeyframeanimation_p.h" - -#include <cmath> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -QKeyframeAnimationPrivate::QKeyframeAnimationPrivate() - : QAbstractAnimationPrivate(QAbstractAnimation::KeyframeAnimation) - , m_minposition(0.0f) - , m_maxposition(0.0f) - , m_prevPosition(-1.0f) - , m_target(nullptr) - , m_startMode(QKeyframeAnimation::Constant) - , m_endMode(QKeyframeAnimation::Constant) -{ - -} - -QKeyframeAnimation::QKeyframeAnimation(QObject *parent) - : QAbstractAnimation(*new QKeyframeAnimationPrivate(), parent) -{ - Q_D(QKeyframeAnimation); - d->m_positionConnection = QObject::connect(this, &QAbstractAnimation::positionChanged, - this, &QKeyframeAnimation::updateAnimation); -} - - -void QKeyframeAnimation::setFramePositions(const QVector<float> &positions) -{ - Q_D(QKeyframeAnimation); - d->m_framePositions = positions; - d->m_prevPosition = -1.0f; - if (d->m_framePositions.size() == 0) { - d->m_minposition = d->m_maxposition = 0.0f; - return; - } - d->m_minposition = d->m_framePositions.first(); - d->m_maxposition = d->m_framePositions.last(); - float lastPos = d->m_minposition; - for (float p : d->m_framePositions) { - if (p < lastPos || p > d->m_maxposition) - qWarning() << "positions not ordered correctly"; - lastPos = p; - } - setDuration(d->m_maxposition); -} - -void QKeyframeAnimation::setKeyframes(const QVector<Qt3DCore::QTransform *> &keyframes) -{ - Q_D(QKeyframeAnimation); - d->m_keyframes = keyframes; -} - -// slerp which allows long path -QQuaternion lslerp(QQuaternion q1, QQuaternion q2, float t) -{ - QQuaternion ret; - // Handle the easy cases first. - if (t <= 0.0f) - return q1; - else if (t >= 1.0f) - return q2; - - float cos = qBound(-1.0f, QQuaternion::dotProduct(q1, q2), 1.0f); - float angle = std::acos(cos); - float sin = std::sin(angle); - if (!qFuzzyIsNull(sin)) { - float a = std::sin((1.0 - t) * angle) / sin; - float b = std::sin(t * angle) / sin; - ret = (q1 * a + q2 * b).normalized(); - } else { - ret = q1 * (1.0f-t) + q2 * t; - } - return ret; -} - -void QKeyframeAnimationPrivate::calculateFrame(float position) -{ - if (m_target && m_framePositions.size() > 0 - && m_keyframes.size() == m_framePositions.size() - && m_prevPosition != m_position) { - if (m_position >= m_minposition && m_position < m_maxposition) { - for (int i = 0; i < m_framePositions.size() - 1; i++) { - if (position >= m_framePositions.at(i) - && position < m_framePositions.at(i+1)) { - float ip = (position - m_framePositions.at(i)) - / (m_framePositions.at(i+1) - m_framePositions.at(i)); - float eIp = m_easing.valueForProgress(ip); - float eIip = 1.0f - eIp; - - Qt3DCore::QTransform *a = m_keyframes.at(i); - Qt3DCore::QTransform *b = m_keyframes.at(i+1); - - QVector3D s = a->scale3D() * eIip + b->scale3D() * eIp; - QVector3D t = a->translation() * eIip + b->translation() * eIp; - QQuaternion r = QQuaternion::slerp(a->rotation(), b->rotation(), eIp); - - m_target->setRotation(r); - m_target->setScale3D(s); - m_target->setTranslation(t); - return; - } - } - } else if (position < m_minposition) { - m_target->setRotation(m_keyframes.first()->rotation()); - m_target->setScale3D(m_keyframes.first()->scale3D()); - m_target->setTranslation(m_keyframes.first()->translation()); - } else { - m_target->setRotation(m_keyframes.last()->rotation()); - m_target->setScale3D(m_keyframes.last()->scale3D()); - m_target->setTranslation(m_keyframes.last()->translation()); - } - m_prevPosition = m_position; - } -} - -void QKeyframeAnimation::updateAnimation(float position) -{ - Q_D(QKeyframeAnimation); - d->calculateFrame(position); -} - -QVector<float> QKeyframeAnimation::framePositions() const -{ - Q_D(const QKeyframeAnimation); - return d->m_framePositions; -} - -QVector<Qt3DCore::QTransform *> QKeyframeAnimation::keyframeList() const -{ - Q_D(const QKeyframeAnimation); - return d->m_keyframes; -} - -void QKeyframeAnimation::setTarget(Qt3DCore::QTransform *target) -{ - Q_D(QKeyframeAnimation); - if (d->m_target != target) { - d->m_target = target; - emit targetChanged(d->m_target); - d->m_prevPosition = -1.0f; - - if (target) { - d->m_baseScale = target->scale3D(); - d->m_baseTranslation = target->translation(); - d->m_baseRotation = target->rotation(); - } - } -} - -QKeyframeAnimation::RepeatMode QKeyframeAnimation::startMode() const -{ - Q_D(const QKeyframeAnimation); - return d->m_startMode; -} - -QKeyframeAnimation::RepeatMode QKeyframeAnimation::endMode() const -{ - Q_D(const QKeyframeAnimation); - return d->m_endMode; -} - -void QKeyframeAnimation::setEasing(QEasingCurve::Type easing) -{ - Q_D(QKeyframeAnimation); - if (d->m_easing.type() != easing) { - d->m_easing.setType(easing); - emit easingChanged(easing); - } -} - -void QKeyframeAnimation::setTargetName(const QString &name) -{ - Q_D(QKeyframeAnimation); - d->m_targetName = name; - emit targetNameChanged(name); -} - -void QKeyframeAnimation::setStartMode(QKeyframeAnimation::RepeatMode mode) -{ - Q_D(QKeyframeAnimation); - if (d->m_startMode != mode) { - d->m_startMode = mode; - emit startModeChanged(mode); - } -} - -void QKeyframeAnimation::setEndMode(QKeyframeAnimation::RepeatMode mode) -{ - Q_D(QKeyframeAnimation); - if (mode != d->m_endMode) { - d->m_endMode = mode; - emit endModeChanged(mode); - } -} - -void QKeyframeAnimation::addKeyframe(Qt3DCore::QTransform *keyframe) -{ - Q_D(QKeyframeAnimation); - d->m_keyframes.push_back(keyframe); -} - -QString QKeyframeAnimation::targetName() const -{ - Q_D(const QKeyframeAnimation); - return d->m_targetName; -} - -QEasingCurve::Type QKeyframeAnimation::easing() const -{ - Q_D(const QKeyframeAnimation); - return d->m_easing.type(); -} - -Qt3DCore::QTransform *QKeyframeAnimation::target() const -{ - Q_D(const QKeyframeAnimation); - return d->m_target; -} - -} // Qt3DExtras - -QT_END_NAMESPACE diff --git a/src/extras/animations/qkeyframeanimation.h b/src/extras/animations/qkeyframeanimation.h deleted file mode 100644 index 178c9dbf1..000000000 --- a/src/extras/animations/qkeyframeanimation.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QKEYFRAMEANIMATION_H -#define QT3DEXTRAS_QKEYFRAMEANIMATION_H - -#include <Qt3DCore/qtransform.h> - -#include <Qt3DExtras/qabstractanimation.h> -#include <Qt3DExtras/qt3dextras_global.h> - -#include <QtCore/qeasingcurve.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QKeyframeAnimationPrivate; - -class QT3DEXTRASSHARED_EXPORT QKeyframeAnimation : public QAbstractAnimation -{ - Q_OBJECT - Q_PROPERTY(QVector<float> framePositions READ framePositions WRITE setFramePositions NOTIFY framePositionsChanged) - Q_PROPERTY(Qt3DCore::QTransform *target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(QEasingCurve::Type easing READ easing WRITE setEasing NOTIFY easingChanged) - Q_PROPERTY(QString targetName READ targetName WRITE setTargetName NOTIFY targetNameChanged) - Q_PROPERTY(QKeyframeAnimation::RepeatMode startMode READ startMode WRITE setStartMode NOTIFY startModeChanged) - Q_PROPERTY(QKeyframeAnimation::RepeatMode endMode READ endMode WRITE setEndMode NOTIFY endModeChanged) - -public: - explicit QKeyframeAnimation(QObject *parent = nullptr); - - enum RepeatMode - { - None, - Constant, - Repeat, - }; - Q_ENUM(RepeatMode) - - QVector<float> framePositions() const; - QVector<Qt3DCore::QTransform *> keyframeList() const; - Qt3DCore::QTransform *target() const; - QEasingCurve::Type easing() const; - QString targetName() const; - RepeatMode startMode() const; - RepeatMode endMode() const; - - void setKeyframes(const QVector<Qt3DCore::QTransform *> &keyframes); - void addKeyframe(Qt3DCore::QTransform *keyframe); - void removeKeyframe(Qt3DCore::QTransform *keyframe); - -public Q_SLOTS: - void setFramePositions(const QVector<float> &positions); - void setTarget(Qt3DCore::QTransform *target); - void setEasing(QEasingCurve::Type easing); - void setTargetName(const QString &name); - void setStartMode(RepeatMode mode); - void setEndMode(RepeatMode mode); - -Q_SIGNALS: - void framePositionsChanged(const QVector<float> &positions); - void targetChanged(Qt3DCore::QTransform *target); - void easingChanged(QEasingCurve::Type easing); - void targetNameChanged(const QString &name); - void startModeChanged(RepeatMode startMode); - void endModeChanged(RepeatMode endMode); - -private: - void updateAnimation(float position); - - Q_DECLARE_PRIVATE(QKeyframeAnimation) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QKEYFRAMEANIMATION_H diff --git a/src/extras/animations/qkeyframeanimation_p.h b/src/extras/animations/qkeyframeanimation_p.h deleted file mode 100644 index 0095b9432..000000000 --- a/src/extras/animations/qkeyframeanimation_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QKEYFRAMEANIMATION_P_H -#define QT3DEXTRAS_QKEYFRAMEANIMATION_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/qobject_p.h> -#include <Qt3DExtras/qkeyframeanimation.h> -#include <private/qabstractanimation_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QKeyframeAnimationPrivate : public QAbstractAnimationPrivate -{ -public: - QKeyframeAnimationPrivate(); - - void calculateFrame(float position); - - float m_prevPosition; - QVector<float> m_framePositions; - QVector<Qt3DCore::QTransform *> m_keyframes; - Qt3DCore::QTransform *m_target; - QEasingCurve m_easing; - QString m_animationName; - QString m_targetName; - float m_minposition; - float m_maxposition; - QKeyframeAnimation::RepeatMode m_startMode; - QKeyframeAnimation::RepeatMode m_endMode; - QVector3D m_baseScale; - QVector3D m_baseTranslation; - QQuaternion m_baseRotation; - QMetaObject::Connection m_positionConnection; - - Q_DECLARE_PUBLIC(QKeyframeAnimation) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QKEYFRAMEANIMATION_P_H diff --git a/src/extras/animations/qmorphinganimation.cpp b/src/extras/animations/qmorphinganimation.cpp deleted file mode 100644 index e7fe05147..000000000 --- a/src/extras/animations/qmorphinganimation.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/**************************************************************************** -** -** 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 "qmorphinganimation.h" -#include <private/qmorphinganimation_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -QMorphingAnimationPrivate::QMorphingAnimationPrivate() - : QAbstractAnimationPrivate(QAbstractAnimation::MorphingAnimation) - , m_flattened(nullptr) - , m_method(QMorphingAnimation::Relative) - , m_interpolator(0.0f) - , m_target(nullptr) - , m_currentTarget(nullptr) -{ - m_easing.setType(QEasingCurve::InOutCubic); -} - -QMorphingAnimationPrivate::~QMorphingAnimationPrivate() -{ - for (QVector<float> *weights : m_weights) - delete weights; -} - -void QMorphingAnimationPrivate::updateAnimation(float position) -{ - Q_Q(QMorphingAnimation); - if (!m_target || !m_target->geometry()) - return; - - m_morphKey.resize(m_morphTargets.size()); - - for (int i = 0; i < m_targetPositions.size() - 1; ++i) { - if (position > m_targetPositions.at(i) && position <= m_targetPositions.at(i + 1)) { - float interpolator = (position - m_targetPositions.at(i)) - / (m_targetPositions.at(i + 1) - m_targetPositions.at(i)); - interpolator = m_easing.valueForProgress(interpolator); - float iip = 1.0f - interpolator; - float sum = 0.0f; - QVector<int> relevantValues; - for (int j = 0; j < m_morphTargets.size(); ++j) { - m_morphKey[j] = interpolator * m_weights.at(i + 1)->at(j) - + iip * m_weights.at(i)->at(j); - sum += m_morphKey[j]; - if (!qFuzzyIsNull(m_morphKey[j])) - relevantValues.push_back(j); - } - - if (relevantValues.size() == 0 || qFuzzyIsNull(sum)) { - // only base is used - interpolator = 0.0f; - } else if (relevantValues.size() == 1) { - // one morph target has non-zero weight - setTargetInterpolated(relevantValues[0]); - interpolator = sum; - } else { - // more than one morph target has non-zero weight - // flatten morph targets to one - qWarning() << Q_FUNC_INFO << "Flattening required"; - } - if (!qFuzzyCompare(interpolator, m_interpolator)) { - if (m_method == QMorphingAnimation::Normalized) - m_interpolator = interpolator; - else - m_interpolator = -interpolator; - emit q->interpolatorChanged(m_interpolator); - } - return; - } - } -} - -void QMorphingAnimationPrivate::setTargetInterpolated(int morphTarget) -{ - QMorphTarget *target = m_morphTargets[morphTarget]; - Qt3DRender::QGeometry *geometry = m_target->geometry(); - - // remove attributes from previous frame - if (m_currentTarget && (target != m_currentTarget)) { - const QVector<Qt3DRender::QAttribute *> targetAttributes = m_currentTarget->attributeList(); - for (int i = 0; i < targetAttributes.size(); ++i) - geometry->removeAttribute(targetAttributes.at(i)); - } - - const QVector<Qt3DRender::QAttribute *> targetAttributes = target->attributeList(); - - // add attributes from current frame to the geometry - if (target != m_currentTarget) { - for (int i = 0; i < m_attributeNames.size(); ++i) { - QString targetName = m_attributeNames.at(i); - targetName.append("Target"); - targetAttributes[i]->setName(targetName); - geometry->addAttribute(targetAttributes.at(i)); - } - } - m_currentTarget = target; -} - -QMorphingAnimation::QMorphingAnimation(QObject *parent) - : QAbstractAnimation(*new QMorphingAnimationPrivate, parent) -{ - Q_D(QMorphingAnimation); - d->m_positionConnection = QObject::connect(this, &QAbstractAnimation::positionChanged, - this, &QMorphingAnimation::updateAnimation); -} - -QVector<float> QMorphingAnimation::targetPositions() const -{ - Q_D(const QMorphingAnimation); - return d->m_targetPositions; -} - -float QMorphingAnimation::interpolator() const -{ - Q_D(const QMorphingAnimation); - return d->m_interpolator; -} - -Qt3DRender::QGeometryRenderer *QMorphingAnimation::target() const -{ - Q_D(const QMorphingAnimation); - return d->m_target; -} - -QString QMorphingAnimation::targetName() const -{ - Q_D(const QMorphingAnimation); - return d->m_targetName; -} - -QMorphingAnimation::Method QMorphingAnimation::method() const -{ - Q_D(const QMorphingAnimation); - return d->m_method; -} - -QEasingCurve::Type QMorphingAnimation::easing() const -{ - Q_D(const QMorphingAnimation); - return d->m_easing.type(); -} - -void QMorphingAnimation::setMorphTargets(const QVector<Qt3DExtras::QMorphTarget *> &targets) -{ - Q_D(QMorphingAnimation); - d->m_morphTargets = targets; - d->m_attributeNames = targets[0]->attributeNames(); -} - -void QMorphingAnimation::addMorphTarget(Qt3DExtras::QMorphTarget *target) -{ - Q_D(QMorphingAnimation); - if (!d->m_morphTargets.contains(target)) - d->m_morphTargets.push_back(target); -} - -void QMorphingAnimation::removeMorphTarget(Qt3DExtras::QMorphTarget *target) -{ - Q_D(QMorphingAnimation); - d->m_morphTargets.removeAll(target); -} - -void QMorphingAnimation::setTargetPositions(const QVector<float> &targetPositions) -{ - Q_D(QMorphingAnimation); - d->m_targetPositions = targetPositions; - emit targetPositionsChanged(targetPositions); - setDuration(d->m_targetPositions.last()); - if (d->m_weights.size() < targetPositions.size()) { - d->m_weights.resize(targetPositions.size()); - for (int i = 0; i < d->m_weights.size(); ++i) { - if (d->m_weights[i] == nullptr) - d->m_weights[i] = new QVector<float>(); - } - } -} - -void QMorphingAnimation::setTarget(Qt3DRender::QGeometryRenderer *target) -{ - Q_D(QMorphingAnimation); - if (d->m_target != target) { - d->m_target = target; - emit targetChanged(target); - } -} - -void QMorphingAnimation::setWeights(int positionIndex, const QVector<float> &weights) -{ - Q_D(QMorphingAnimation); - if (d->m_weights.size() < positionIndex) - d->m_weights.resize(positionIndex + 1); - if (d->m_weights[positionIndex] == nullptr) - d->m_weights[positionIndex] = new QVector<float>(); - *d->m_weights[positionIndex] = weights; -} - -QVector<float> QMorphingAnimation::getWeights(int positionIndex) -{ - Q_D(QMorphingAnimation); - return *d->m_weights[positionIndex]; -} - -QVector<Qt3DExtras::QMorphTarget *> QMorphingAnimation::morphTargetList() -{ - Q_D(QMorphingAnimation); - return d->m_morphTargets; -} - -void QMorphingAnimation::setTargetName(const QString name) -{ - Q_D(QMorphingAnimation); - if (d->m_targetName != name) { - d->m_targetName = name; - emit targetNameChanged(name); - } -} - -void QMorphingAnimation::setMethod(QMorphingAnimation::Method method) -{ - Q_D(QMorphingAnimation); - if (d->m_method != method) { - d->m_method = method; - emit methodChanged(method); - } -} - -void QMorphingAnimation::setEasing(QEasingCurve::Type easing) -{ - Q_D(QMorphingAnimation); - if (d->m_easing.type() != easing) { - d->m_easing.setType(easing); - emit easingChanged(easing); - } -} - -void QMorphingAnimation::updateAnimation(float position) -{ - Q_D(QMorphingAnimation); - d->updateAnimation(position); -} - -} // Qt3DExtras - -QT_END_NAMESPACE diff --git a/src/extras/animations/qmorphinganimation.h b/src/extras/animations/qmorphinganimation.h deleted file mode 100644 index f8ca71ec9..000000000 --- a/src/extras/animations/qmorphinganimation.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QMORPHINGANIMATION_H -#define QT3DEXTRAS_QMORPHINGANIMATION_H - -#include <Qt3DRender/qgeometryrenderer.h> - -#include <Qt3DExtras/qabstractanimation.h> -#include <Qt3DExtras/qmorphtarget.h> -#include <Qt3DExtras/qt3dextras_global.h> - -#include <QtCore/qeasingcurve.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QMorphingAnimationPrivate; - -class QT3DEXTRASSHARED_EXPORT QMorphingAnimation : public QAbstractAnimation -{ - Q_OBJECT - Q_PROPERTY(QVector<float> targetPositions READ targetPositions WRITE setTargetPositions NOTIFY targetPositionsChanged) - Q_PROPERTY(float interpolator READ interpolator NOTIFY interpolatorChanged) - Q_PROPERTY(Qt3DRender::QGeometryRenderer *target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(QString targetName READ targetName WRITE setTargetName NOTIFY targetNameChanged) - Q_PROPERTY(QMorphingAnimation::Method method READ method WRITE setMethod NOTIFY methodChanged) - Q_PROPERTY(QEasingCurve::Type easing READ easing WRITE setEasing NOTIFY easingChanged) - -public: - enum Method - { - Normalized, - Relative - }; - Q_ENUM(Method) - - explicit QMorphingAnimation(QObject *parent = nullptr); - - QVector<float> targetPositions() const; - float interpolator() const; - Qt3DRender::QGeometryRenderer *target() const; - QString targetName() const; - QMorphingAnimation::Method method() const; - QEasingCurve::Type easing() const; - - void setMorphTargets(const QVector<Qt3DExtras::QMorphTarget *> &targets); - void addMorphTarget(Qt3DExtras::QMorphTarget *target); - void removeMorphTarget(Qt3DExtras::QMorphTarget *target); - - void setWeights(int positionIndex, const QVector<float> &weights); - QVector<float> getWeights(int positionIndex); - - QVector<Qt3DExtras::QMorphTarget *> morphTargetList(); - -public Q_SLOTS: - void setTargetPositions(const QVector<float> &targetPositions); - void setTarget(Qt3DRender::QGeometryRenderer *target); - void setTargetName(const QString name); - void setMethod(QMorphingAnimation::Method method); - void setEasing(QEasingCurve::Type easing); - -Q_SIGNALS: - void targetPositionsChanged(const QVector<float> &targetPositions); - void interpolatorChanged(float interpolator); - void targetChanged(Qt3DRender::QGeometryRenderer *target); - void targetNameChanged(const QString &name); - void methodChanged(QMorphingAnimation::Method method); - void easingChanged(QEasingCurve::Type easing); - -private: - - void updateAnimation(float position); - - Q_DECLARE_PRIVATE(QMorphingAnimation) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QMORPHINGANIMATION_H diff --git a/src/extras/animations/qmorphinganimation_p.h b/src/extras/animations/qmorphinganimation_p.h deleted file mode 100644 index e4a18f199..000000000 --- a/src/extras/animations/qmorphinganimation_p.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QMORPHINGANIMATION_P_H -#define QT3DEXTRAS_QMORPHINGANIMATION_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 <QtCore/qeasingcurve.h> -#include <Qt3DExtras/qmorphinganimation.h> - -#include <private/qobject_p.h> -#include <private/qabstractanimation_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QMorphingAnimationPrivate : public QAbstractAnimationPrivate -{ -public: - QMorphingAnimationPrivate(); - ~QMorphingAnimationPrivate(); - - void updateAnimation(float position); - void setTargetInterpolated(int morphTarget); - - QVector<float> m_targetPositions; - QVector<QVector<float>*> m_weights; - QVector<float> m_morphKey; - QStringList m_attributeNames; - QVector<Qt3DExtras::QMorphTarget *> m_morphTargets; - QMorphTarget *m_flattened; - QMorphingAnimation::Method m_method; - QEasingCurve m_easing; - float m_interpolator; - Qt3DRender::QGeometryRenderer *m_target; - QString m_targetName; - - QMorphTarget *m_currentTarget; - - QMetaObject::Connection m_positionConnection; - - Q_DECLARE_PUBLIC(QMorphingAnimation) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QMORPHINGANIMATION_P_H diff --git a/src/extras/animations/qmorphtarget.cpp b/src/extras/animations/qmorphtarget.cpp deleted file mode 100644 index 0c327a490..000000000 --- a/src/extras/animations/qmorphtarget.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** 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 "qmorphtarget.h" -#include "Qt3DExtras/private/qmorphtarget_p.h" - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -QMorphTargetPrivate::QMorphTargetPrivate() - : QObjectPrivate() -{ - -} - -void QMorphTargetPrivate::updateAttributeNames() -{ - m_attributeNames.clear(); - for (const Qt3DRender::QAttribute *attr : m_targetAttributes) - m_attributeNames.push_back(attr->name()); -} - -QMorphTarget::QMorphTarget(QObject *parent) - : QObject(*new QMorphTargetPrivate, parent) -{ - -} - -QVector<Qt3DRender::QAttribute *> QMorphTarget::attributeList() const -{ - Q_D(const QMorphTarget); - return d->m_targetAttributes; -} - -QStringList QMorphTarget::attributeNames() const -{ - Q_D(const QMorphTarget); - return d->m_attributeNames; -} - -void QMorphTarget::setAttributes(const QVector<Qt3DRender::QAttribute *> &attributes) -{ - Q_D(QMorphTarget); - d->m_targetAttributes = attributes; - d->m_attributeNames.clear(); - for (const Qt3DRender::QAttribute *attr : attributes) - d->m_attributeNames.push_back(attr->name()); - - emit attributeNamesChanged(d->m_attributeNames); -} - -void QMorphTarget::addAttribute(Qt3DRender::QAttribute *attribute) -{ - Q_D(QMorphTarget); - for (const Qt3DRender::QAttribute *attr : d->m_targetAttributes) { - if (attr->name() == attribute->name()) - return; - } - d->m_targetAttributes.push_back(attribute); - d->m_attributeNames.push_back(attribute->name()); - emit attributeNamesChanged(d->m_attributeNames); -} - -void QMorphTarget::removeAttribute(Qt3DRender::QAttribute *attribute) -{ - Q_D(QMorphTarget); - if (d->m_targetAttributes.contains(attribute)) { - d->m_targetAttributes.removeAll(attribute); - d->updateAttributeNames(); - emit attributeNamesChanged(d->m_attributeNames); - } -} - -QMorphTarget *QMorphTarget::fromGeometry(Qt3DRender::QGeometry *geometry, const QStringList &attributes) -{ - QMorphTarget *target = new QMorphTarget(); - for (Qt3DRender::QAttribute *attr : geometry->attributes()) { - if (attributes.contains(attr->name())) - target->addAttribute(attr); - } - return target; -} - -} // Qt3DExtras - -QT_END_NAMESPACE diff --git a/src/extras/animations/qmorphtarget.h b/src/extras/animations/qmorphtarget.h deleted file mode 100644 index 64c3037cb..000000000 --- a/src/extras/animations/qmorphtarget.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QMORPHTARGET_H -#define QT3DEXTRAS_QMORPHTARGET_H - -#include <Qt3DRender/qattribute.h> -#include <Qt3DRender/qgeometry.h> - -#include <QtCore/qstringlist.h> - -#include <Qt3DExtras/qt3dextras_global.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QMorphTargetPrivate; - -class QT3DEXTRASSHARED_EXPORT QMorphTarget : public QObject -{ - Q_OBJECT - Q_PROPERTY(QStringList attributeNames READ attributeNames NOTIFY attributeNamesChanged) - -public: - explicit QMorphTarget(QObject *parent = nullptr); - - QVector<Qt3DRender::QAttribute *> attributeList() const; - QStringList attributeNames() const; - - void setAttributes(const QVector<Qt3DRender::QAttribute *> &attributes); - void addAttribute(Qt3DRender::QAttribute *attribute); - void removeAttribute(Qt3DRender::QAttribute *attribute); - - Q_INVOKABLE static QMorphTarget *fromGeometry(Qt3DRender::QGeometry *geometry, - const QStringList &attributes); - -Q_SIGNALS: - void attributeNamesChanged(const QStringList &attributeNames); - -private: - - Q_DECLARE_PRIVATE(QMorphTarget) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QMORPHTARGET_H diff --git a/src/extras/animations/qmorphtarget_p.h b/src/extras/animations/qmorphtarget_p.h deleted file mode 100644 index 7d42f8eb4..000000000 --- a/src/extras/animations/qmorphtarget_p.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QMORPHTARGET_P_H -#define QT3DEXTRAS_QMORPHTARGET_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 <Qt3DExtras/qmorphtarget.h> - -#include <private/qobject_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QMorphTargetPrivate : public QObjectPrivate -{ -public: - QMorphTargetPrivate(); - - void updateAttributeNames(); - - QStringList m_attributeNames; - QVector<Qt3DRender::QAttribute *> m_targetAttributes; - - Q_DECLARE_PUBLIC(QMorphTarget) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QMORPHTARGET_P_H diff --git a/src/extras/animations/qvertexblendanimation.cpp b/src/extras/animations/qvertexblendanimation.cpp deleted file mode 100644 index 1b45992fe..000000000 --- a/src/extras/animations/qvertexblendanimation.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/**************************************************************************** -** -** 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 "qvertexblendanimation.h" - -#include <private/qvertexblendanimation_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -QVertexBlendAnimationPrivate::QVertexBlendAnimationPrivate() - : QAbstractAnimationPrivate(QAbstractAnimation::VertexBlendAnimation) - , m_currentBase(nullptr) - , m_currentTarget(nullptr) -{ - -} - -void QVertexBlendAnimationPrivate::getAttributesInPosition(float position, int *target0, - int *target1, float *interpolator) -{ - if (position < m_targetPositions.first()) { - *target0 = 0; - *target1 = qMin(1, m_targetPositions.size()); - *interpolator = 0.0f; - } else if (position > m_targetPositions.last()) { - *target0 = qMax(m_targetPositions.size() - 2, 0); - *target1 = qMax(m_targetPositions.size() - 1, 0); - *interpolator = 1.0f; - } else { - for (int i = 0; i < m_targetPositions.size() - 1; i++) { - if (position >= m_targetPositions[i] && position < m_targetPositions[i + 1]) { - *target0 = i; - *target1 = i + 1; - float a = (position - m_targetPositions[i]) - / (m_targetPositions[i + 1] - m_targetPositions[i]); - *interpolator = a; - } - } - } -} - -static Qt3DRender::QAttribute *findAttribute(QVector<Qt3DRender::QAttribute *> &attributes, - QString name) -{ - for (Qt3DRender::QAttribute *gattr : attributes) { - if (gattr->name() == name) - return gattr; - } - return nullptr; -} - -void QVertexBlendAnimationPrivate::updateAnimation(float position) -{ - Q_Q(QVertexBlendAnimation); - if (!m_target || !m_target->geometry()) - return; - - Qt3DExtras::QMorphTarget *base; - Qt3DExtras::QMorphTarget *target; - int target0, target1; - float interpolator; - getAttributesInPosition(position, &target0, &target1, &interpolator); - - base = m_morphTargets.at(target0); - target = m_morphTargets.at(target1); - - Qt3DRender::QGeometry *geometry = m_target->geometry(); - - // remove attributes from previous frame - if ((m_currentBase && (base != m_currentBase)) - || (m_currentTarget && (target != m_currentTarget))) { - const QVector<Qt3DRender::QAttribute *> baseAttributes = m_currentBase->attributeList(); - const QVector<Qt3DRender::QAttribute *> targetAttributes = m_currentTarget->attributeList(); - for (int i = 0; i < baseAttributes.size(); ++i) { - geometry->removeAttribute(baseAttributes.at(i)); - geometry->removeAttribute(targetAttributes.at(i)); - } - } - - const QVector<Qt3DRender::QAttribute *> baseAttributes = base->attributeList(); - const QVector<Qt3DRender::QAttribute *> targetAttributes = target->attributeList(); - const QStringList attributeNames = base->attributeNames(); - - // add attributes from current frame to the geometry - if (base != m_currentBase || target != m_currentTarget) { - for (int i = 0; i < baseAttributes.size(); ++i) { - const QString baseName = attributeNames.at(i); - QString targetName = baseName; - targetName.append("Target"); - - baseAttributes[i]->setName(baseName); - geometry->addAttribute(baseAttributes.at(i)); - targetAttributes[i]->setName(targetName); - geometry->addAttribute(targetAttributes.at(i)); - } - } - m_currentBase = base; - m_currentTarget = target; - - if (!qFuzzyCompare(interpolator, m_interpolator)) { - m_interpolator = interpolator; - emit q->interpolatorChanged(interpolator); - } -} - -QVertexBlendAnimation::QVertexBlendAnimation(QObject *parent) - : QAbstractAnimation(*new QVertexBlendAnimationPrivate, parent) -{ - Q_D(QVertexBlendAnimation); - d->m_positionConnection = QObject::connect(this, &QAbstractAnimation::positionChanged, - this, &QVertexBlendAnimation::updateAnimation); -} - -QVector<float> QVertexBlendAnimation::targetPositions() const -{ - Q_D(const QVertexBlendAnimation); - return d->m_targetPositions; -} - -float QVertexBlendAnimation::interpolator() const -{ - Q_D(const QVertexBlendAnimation); - return d->m_interpolator; -} - -Qt3DRender::QGeometryRenderer *QVertexBlendAnimation::target() const -{ - Q_D(const QVertexBlendAnimation); - return d->m_target; -} - -QString QVertexBlendAnimation::targetName() const -{ - Q_D(const QVertexBlendAnimation); - return d->m_targetName; -} - -void QVertexBlendAnimation::setMorphTargets(const QVector<Qt3DExtras::QMorphTarget *> &targets) -{ - Q_D(QVertexBlendAnimation); - d->m_morphTargets = targets; -} - -void QVertexBlendAnimation::addMorphTarget(Qt3DExtras::QMorphTarget *target) -{ - Q_D(QVertexBlendAnimation); - if (!d->m_morphTargets.contains(target)) - d->m_morphTargets.push_back(target); -} - -void QVertexBlendAnimation::removeMorphTarget(Qt3DExtras::QMorphTarget *target) -{ - Q_D(QVertexBlendAnimation); - d->m_morphTargets.removeAll(target); -} - -void QVertexBlendAnimation::setTargetPositions(const QVector<float> &targetPositions) -{ - Q_D(QVertexBlendAnimation); - if (d->m_targetPositions == targetPositions) - return; - d->m_targetPositions = targetPositions; - emit targetPositionsChanged(targetPositions); - setDuration(d->m_targetPositions.last()); -} - -void QVertexBlendAnimation::setTarget(Qt3DRender::QGeometryRenderer *target) -{ - Q_D(QVertexBlendAnimation); - if (d->m_target != target) { - d->m_target = target; - emit targetChanged(target); - } -} - -QVector<Qt3DExtras::QMorphTarget *> QVertexBlendAnimation::morphTargetList() -{ - Q_D(QVertexBlendAnimation); - return d->m_morphTargets; -} - -void QVertexBlendAnimation::setTargetName(const QString name) -{ - Q_D(QVertexBlendAnimation); - if (d->m_targetName != name) { - d->m_targetName = name; - emit targetNameChanged(name); - } -} - -void QVertexBlendAnimation::updateAnimation(float position) -{ - Q_D(QVertexBlendAnimation); - d->updateAnimation(position); -} - -} // Qt3DExtras - -QT_END_NAMESPACE diff --git a/src/extras/animations/qvertexblendanimation.h b/src/extras/animations/qvertexblendanimation.h deleted file mode 100644 index ebd313e83..000000000 --- a/src/extras/animations/qvertexblendanimation.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QVERTEXBLENDANIMATION_H -#define QT3DEXTRAS_QVERTEXBLENDANIMATION_H - -#include <Qt3DRender/qgeometryrenderer.h> -#include <Qt3DExtras/qabstractanimation.h> -#include <Qt3DExtras/qmorphtarget.h> - -#include <Qt3DExtras/qt3dextras_global.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QVertexBlendAnimationPrivate; - -class QT3DEXTRASSHARED_EXPORT QVertexBlendAnimation : public QAbstractAnimation -{ - Q_OBJECT - Q_PROPERTY(QVector<float> targetPositions READ targetPositions WRITE setTargetPositions NOTIFY targetPositionsChanged) - Q_PROPERTY(float interpolator READ interpolator NOTIFY interpolatorChanged) - Q_PROPERTY(Qt3DRender::QGeometryRenderer *target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(QString targetName READ targetName WRITE setTargetName NOTIFY targetNameChanged) - -public: - explicit QVertexBlendAnimation(QObject *parent = nullptr); - - QVector<float> targetPositions() const; - float interpolator() const; - Qt3DRender::QGeometryRenderer *target() const; - QString targetName() const; - - void setMorphTargets(const QVector<Qt3DExtras::QMorphTarget *> &targets); - void addMorphTarget(Qt3DExtras::QMorphTarget *target); - void removeMorphTarget(Qt3DExtras::QMorphTarget *target); - - QVector<Qt3DExtras::QMorphTarget *> morphTargetList(); - -public Q_SLOTS: - void setTargetPositions(const QVector<float> &targetPositions); - void setTarget(Qt3DRender::QGeometryRenderer *target); - void setTargetName(const QString name); - -Q_SIGNALS: - void targetPositionsChanged(const QVector<float> &targetPositions); - void interpolatorChanged(float interpolator); - void targetChanged(Qt3DRender::QGeometryRenderer *target); - void targetNameChanged(const QString &name); - -private: - - void updateAnimation(float position); - - Q_DECLARE_PRIVATE(QVertexBlendAnimation) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QVERTEXBLENDANIMATION_H diff --git a/src/extras/animations/qvertexblendanimation_p.h b/src/extras/animations/qvertexblendanimation_p.h deleted file mode 100644 index 812953e04..000000000 --- a/src/extras/animations/qvertexblendanimation_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** 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 QT3DEXTRAS_QVERTEXBLENDANIMATION_P_H -#define QT3DEXTRAS_QVERTEXBLENDANIMATION_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 <Qt3DExtras/qvertexblendanimation.h> - -#include <private/qobject_p.h> -#include <private/qabstractanimation_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DExtras { - -class QVertexBlendAnimationPrivate : public QAbstractAnimationPrivate -{ -public: - QVertexBlendAnimationPrivate(); - - void getAttributesInPosition(float position, int *target0, int *target1, float *interpolator); - void updateAnimation(float position); - - QVector<float> m_targetPositions; - QVector<Qt3DExtras::QMorphTarget *> m_morphTargets; - float m_interpolator; - Qt3DRender::QGeometryRenderer *m_target; - QString m_targetName; - QMorphTarget *m_currentBase; - QMorphTarget *m_currentTarget; - - QMetaObject::Connection m_positionConnection; - - Q_DECLARE_PUBLIC(QVertexBlendAnimation) -}; - -} // Qt3DExtras - -QT_END_NAMESPACE - -#endif // QT3DEXTRAS_QVertexBlendANIMATION_P_H |