diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-08-21 14:36:23 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-08-30 12:59:13 +0000 |
commit | a60a3d30c84f3521521da01965085d41c51c1617 (patch) | |
tree | edaf385cf8df09af530680859033c632528e582d /src/animation/backend/skeleton_p.h | |
parent | dc4a29aa578c1c00fc750d1f6882e45f09134b47 (diff) |
Add Skeleton backend node to the animation aspect
The animation aspect can already animate any property of a QNode
subclass. However, the render aspect allows to render a skinned mesh
utilising a QSkeletonLoader that does not create the corresponding
frontend QJoint objects (subclasses of QNode). Some skeletons can be
large (10's or 100's of joints) so this is a good memory conserving
optimization.
The consequence of not creating the frontend joints however, is that
without the QNodes to address, we cannot animate their local poses. To
combat this without giving up on the above optimization we add a
backend node for QAbstractSkeleton to the animation aspect. This node
contains a vector of local poses for the joints in the same order as
the render aspect creates and flattens the joint hierarchy in (see the
vector of JointInfo in the SkeletonData in the render aspect). The
animation aspect can then use this special knowledge to efficiently
animate the joints of a skeleton and each frame, inform the render
aspect backend of the new set of local pose transformations, prior to
the render aspect calculating the skinning matrix palette and supplying
that to the armature component for rendering.
This will require the animation aspect to be able to map channels in
an animation onto the joint indices of the skeleton backend nodes. By
default, they will be applied to matching indices in the vector of local
poses. However, an optional name property will be allowed in the
animation clip channels to permit re-mapping of animation clips to
similar skeletons (i.e. allow animations to be reused between different
skeletons where they share some joint names). This will be done in
follow up commits.
Change-Id: I81ad258f59bb0ddd6a49456840c860783f6fb340
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/animation/backend/skeleton_p.h')
-rw-r--r-- | src/animation/backend/skeleton_p.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/animation/backend/skeleton_p.h b/src/animation/backend/skeleton_p.h new file mode 100644 index 000000000..b78e207b3 --- /dev/null +++ b/src/animation/backend/skeleton_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** 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 QT3DANIMATION_ANIMATION_SKELETON_H +#define QT3DANIMATION_ANIMATION_SKELETON_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 <Qt3DAnimation/private/backendnode_p.h> +#include <Qt3DCore/private/sqt_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DAnimation { +namespace Animation { + +class Skeleton : public BackendNode +{ +public: + Skeleton(); + + void cleanup(); + void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE; + +private: + void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) Q_DECL_FINAL; + + QVector<QString> m_jointNames; + QVector<Qt3DCore::Sqt> m_jointLocalPoses; }; + +} // namespace Animation +} // namespace Qt3DAnimation + + +QT_END_NAMESPACE + +#endif // QT3DANIMATION_ANIMATION_SKELETON_H |