| 1 | // Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QT3DANIMATION_ANIMATION_SKELETON_H |
| 5 | #define QT3DANIMATION_ANIMATION_SKELETON_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists for the convenience |
| 12 | // of other Qt classes. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <Qt3DAnimation/private/backendnode_p.h> |
| 19 | #include <Qt3DCore/private/sqt_p.h> |
| 20 | |
| 21 | QT_BEGIN_NAMESPACE |
| 22 | |
| 23 | namespace Qt3DAnimation { |
| 24 | namespace Animation { |
| 25 | |
| 26 | class Q_AUTOTEST_EXPORT Skeleton : public BackendNode |
| 27 | { |
| 28 | public: |
| 29 | Skeleton(); |
| 30 | |
| 31 | void cleanup(); |
| 32 | void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override; |
| 33 | |
| 34 | QVector<Qt3DCore::Sqt> joints() const { return m_jointLocalPoses; } |
| 35 | int jointCount() const { return m_jointLocalPoses.size(); } |
| 36 | QString jointName(int jointIndex) const { return m_jointNames.at(i: jointIndex); } |
| 37 | |
| 38 | void setJointScale(int jointIndex, const QVector3D &scale) |
| 39 | { |
| 40 | m_jointLocalPoses[jointIndex].scale = scale; |
| 41 | } |
| 42 | |
| 43 | QVector3D jointScale(int jointIndex) const |
| 44 | { |
| 45 | return m_jointLocalPoses[jointIndex].scale; |
| 46 | } |
| 47 | |
| 48 | void setJointRotation(int jointIndex, const QQuaternion &rotation) |
| 49 | { |
| 50 | m_jointLocalPoses[jointIndex].rotation = rotation; |
| 51 | } |
| 52 | |
| 53 | QQuaternion jointRotation(int jointIndex) const |
| 54 | { |
| 55 | return m_jointLocalPoses[jointIndex].rotation; |
| 56 | } |
| 57 | |
| 58 | void setJointTranslation(int jointIndex, const QVector3D &translation) |
| 59 | { |
| 60 | m_jointLocalPoses[jointIndex].translation = translation; |
| 61 | } |
| 62 | |
| 63 | QVector3D jointTranslation(int jointIndex) const |
| 64 | { |
| 65 | return m_jointLocalPoses[jointIndex].translation; |
| 66 | } |
| 67 | |
| 68 | #if defined(QT_BUILD_INTERNAL) |
| 69 | void setJointCount(int jointCount) |
| 70 | { |
| 71 | m_jointNames.resize(size: jointCount); |
| 72 | m_jointLocalPoses.resize(size: jointCount); |
| 73 | } |
| 74 | void setJointNames(const QVector<QString> &names) { m_jointNames = names; } |
| 75 | QVector<QString> jointNames() const { return m_jointNames; } |
| 76 | void setJointLocalPoses(const QVector<Qt3DCore::Sqt> &localPoses) { m_jointLocalPoses = localPoses; } |
| 77 | QVector<Qt3DCore::Sqt> jointLocalPoses() const { return m_jointLocalPoses; } |
| 78 | #endif |
| 79 | |
| 80 | private: |
| 81 | QVector<QString> m_jointNames; |
| 82 | QVector<Qt3DCore::Sqt> m_jointLocalPoses; |
| 83 | }; |
| 84 | |
| 85 | } // namespace Animation |
| 86 | } // namespace Qt3DAnimation |
| 87 | |
| 88 | |
| 89 | QT_END_NAMESPACE |
| 90 | |
| 91 | #endif // QT3DANIMATION_ANIMATION_SKELETON_H |
| 92 | |