| 1 | // Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include "animationfactory.h" |
| 5 | |
| 6 | using namespace Qt3DAnimation; |
| 7 | |
| 8 | AnimationFactory::AnimationFactory(QObject *parent) |
| 9 | : QObject(parent) |
| 10 | { |
| 11 | updateClipData(); |
| 12 | } |
| 13 | |
| 14 | void AnimationFactory::updateClipData() |
| 15 | { |
| 16 | m_clipData.clearChannels(); |
| 17 | |
| 18 | // Add a channel for a Location animation |
| 19 | QChannel location(QLatin1String("Location")); |
| 20 | |
| 21 | QChannelComponent locationX(QLatin1String("Location X")); |
| 22 | locationX.appendKeyFrame(QKeyFrame({0.0f, 0.0f}, {-1.0f, 0.0f}, {1.0f, 0.0f})); |
| 23 | locationX.appendKeyFrame(QKeyFrame({2.45f, 5.0f}, {1.45f, 5.0f}, {3.45f, 5.0f})); |
| 24 | |
| 25 | QChannelComponent locationY(QLatin1String("Location Y")); |
| 26 | locationY.appendKeyFrame(QKeyFrame({0.0f, 0.0f}, {-1.0f, 0.0f}, {1.0f, 0.0f})); |
| 27 | locationY.appendKeyFrame(QKeyFrame({2.45f, 0.0f}, {1.45f, 0.0f}, {3.45f, 0.0f})); |
| 28 | |
| 29 | QChannelComponent locationZ(QLatin1String("Location Z")); |
| 30 | locationZ.appendKeyFrame(QKeyFrame({0.0f, 0.0f}, {-1.0f, 0.0f}, {1.0f, 0.0f})); |
| 31 | locationZ.appendKeyFrame(QKeyFrame({2.45f, 0.0f}, {1.45f, 0.0f}, {3.45f, 0.0f})); |
| 32 | |
| 33 | location.appendChannelComponent(locationX); |
| 34 | location.appendChannelComponent(locationY); |
| 35 | location.appendChannelComponent(locationZ); |
| 36 | |
| 37 | m_clipData.appendChannel(location); |
| 38 | } |