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
20#include <Qt3DCore/private/sqt_p.h>
21
22#include <QtGui/qquaternion.h>
23
24QT_BEGIN_NAMESPACE
25
26namespace Qt3DAnimation {
27namespace Animation {
28
29class Q_AUTOTEST_EXPORT Skeleton : public BackendNode
30{
31public:
32 Skeleton();
33
34 void cleanup();
35 void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
36
37 QVector<Qt3DCore::Sqt> joints() const { return m_jointLocalPoses; }
38 int jointCount() const { return m_jointLocalPoses.size(); }
39 QString jointName(int jointIndex) const { return m_jointNames.at(i: jointIndex); }
40
41 void setJointScale(int jointIndex, const QVector3D &scale)
42 {
43 m_jointLocalPoses[jointIndex].scale = scale;
44 }
45
46 QVector3D jointScale(int jointIndex) const
47 {
48 return m_jointLocalPoses[jointIndex].scale;
49 }
50
51 void setJointRotation(int jointIndex, const QQuaternion &rotation)
52 {
53 m_jointLocalPoses[jointIndex].rotation = rotation;
54 }
55
56 QQuaternion jointRotation(int jointIndex) const
57 {
58 return m_jointLocalPoses[jointIndex].rotation;
59 }
60
61 void setJointTranslation(int jointIndex, const QVector3D &translation)
62 {
63 m_jointLocalPoses[jointIndex].translation = translation;
64 }
65
66 QVector3D jointTranslation(int jointIndex) const
67 {
68 return m_jointLocalPoses[jointIndex].translation;
69 }
70
71#if defined(QT_BUILD_INTERNAL)
72 void setJointCount(int jointCount)
73 {
74 m_jointNames.resize(size: jointCount);
75 m_jointLocalPoses.resize(size: jointCount);
76 }
77 void setJointNames(const QVector<QString> &names) { m_jointNames = names; }
78 QVector<QString> jointNames() const { return m_jointNames; }
79 void setJointLocalPoses(const QVector<Qt3DCore::Sqt> &localPoses) { m_jointLocalPoses = localPoses; }
80 QVector<Qt3DCore::Sqt> jointLocalPoses() const { return m_jointLocalPoses; }
81#endif
82
83private:
84 QVector<QString> m_jointNames;
85 QVector<Qt3DCore::Sqt> m_jointLocalPoses;
86};
87
88} // namespace Animation
89} // namespace Qt3DAnimation
90
91
92QT_END_NAMESPACE
93
94#endif // QT3DANIMATION_ANIMATION_SKELETON_H
95

source code of qt3d/src/animation/backend/skeleton_p.h