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 QT3DRENDER_RENDER_JOINT_H |
5 | #define QT3DRENDER_RENDER_JOINT_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 <Qt3DRender/private/backendnode_p.h> |
19 | #include <Qt3DCore/private/sqt_p.h> |
20 | #include <Qt3DRender/private/handle_types_p.h> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | namespace Qt3DRender { |
25 | namespace Render { |
26 | |
27 | class JointManager; |
28 | class SkeletonManager; |
29 | |
30 | class Q_3DRENDERSHARED_PRIVATE_EXPORT Joint : public BackendNode |
31 | { |
32 | public: |
33 | Joint(); |
34 | |
35 | void cleanup(); |
36 | void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override; |
37 | |
38 | Qt3DCore::Sqt localPose() const { return m_localPose; } |
39 | QMatrix4x4 inverseBindMatrix() const { return m_inverseBindMatrix; } |
40 | QString name() const { return m_name; } |
41 | QList<Qt3DCore::QNodeId> childJointIds() const { return m_childJointIds; } |
42 | |
43 | QVector3D translation() const { return m_localPose.translation; } |
44 | QQuaternion rotation() const { return m_localPose.rotation; } |
45 | QVector3D scale() const { return m_localPose.scale; } |
46 | |
47 | void setOwningSkeleton(HSkeleton skeletonHandle) { m_owningSkeleton = skeletonHandle; } |
48 | HSkeleton owningSkeleton() const { return m_owningSkeleton; } |
49 | |
50 | void setJointManager(JointManager *jointManager) { m_jointManager = jointManager; } |
51 | JointManager *jointManager() const { return m_jointManager; } |
52 | |
53 | void setSkeletonManager(SkeletonManager *skeletonManager) { m_skeletonManager = skeletonManager; } |
54 | SkeletonManager *skeletonManager() const { return m_skeletonManager; } |
55 | |
56 | private: |
57 | QMatrix4x4 m_inverseBindMatrix; |
58 | Qt3DCore::Sqt m_localPose; |
59 | QList<Qt3DCore::QNodeId> m_childJointIds; |
60 | QString m_name; |
61 | JointManager *m_jointManager; |
62 | SkeletonManager *m_skeletonManager; |
63 | HSkeleton m_owningSkeleton; |
64 | }; |
65 | |
66 | class JointFunctor : public Qt3DCore::QBackendNodeMapper |
67 | { |
68 | public: |
69 | explicit JointFunctor(AbstractRenderer *renderer, |
70 | JointManager *jointManager, |
71 | SkeletonManager *skeletonManager); |
72 | Qt3DCore::QBackendNode *create(Qt3DCore::QNodeId id) const final; |
73 | Qt3DCore::QBackendNode *get(Qt3DCore::QNodeId id) const final; |
74 | void destroy(Qt3DCore::QNodeId id) const final; |
75 | |
76 | private: |
77 | AbstractRenderer *m_renderer; |
78 | JointManager *m_jointManager; |
79 | SkeletonManager *m_skeletonManager; |
80 | }; |
81 | |
82 | } // namespace Render |
83 | } // namespace Qt3DRender |
84 | |
85 | |
86 | QT_END_NAMESPACE |
87 | |
88 | #endif // QT3DRENDER_RENDER_JOINT_H |
89 |