diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-08-11 12:13:52 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-08-16 13:19:40 +0000 |
commit | c6d639e27212fc520f2d0d26b180a2c90c23a92f (patch) | |
tree | 62b5034c6d54de5d66cff97d440bc81b553605f6 /tests/manual | |
parent | a8889da8398c22e5a7f8a0a4ac6bc3c4455ce7b4 (diff) |
Attach an animation to the root joint of the simple rigged model
For now it's just a simple translation. Will build this up to make
a non-root joint do more interesting things.
Change-Id: I53496dee3b62d1979ddcb8663bfd3cdec2d53a38
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/skinned-mesh/SkinnedEntity.qml | 1 | ||||
-rw-r--r-- | tests/manual/skinned-mesh/main.qml | 35 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/manual/skinned-mesh/SkinnedEntity.qml b/tests/manual/skinned-mesh/SkinnedEntity.qml index 3abafa209..47f2bae7b 100644 --- a/tests/manual/skinned-mesh/SkinnedEntity.qml +++ b/tests/manual/skinned-mesh/SkinnedEntity.qml @@ -11,6 +11,7 @@ Entity { property alias createJointsEnabled: skeleton.createJointsEnabled property alias transform: transform property color baseColor: "red" + property alias rootJoint: skeleton.rootJoint components: [ Transform { diff --git a/tests/manual/skinned-mesh/main.qml b/tests/manual/skinned-mesh/main.qml index a3d8e3d12..47f3ee025 100644 --- a/tests/manual/skinned-mesh/main.qml +++ b/tests/manual/skinned-mesh/main.qml @@ -52,6 +52,7 @@ import Qt3D.Core 2.10 import Qt3D.Render 2.10 import Qt3D.Input 2.0 import Qt3D.Extras 2.10 +import QtQuick 2.9 DefaultSceneEntity { id: scene @@ -74,5 +75,39 @@ DefaultSceneEntity { transform.scale: 0.05 transform.translation: Qt.vector3d(0.5, 0.25, 0.0) createJointsEnabled: true + + onRootJointChanged: { + console.log("Root joint: " + rootJoint) + var animation = animationComp.createObject(rootJoint) + animation.target = rootJoint + animation.neutralPos = rootJoint.translation + animation.running = true + } + + Component { + id: animationComp + SequentialAnimation { + id: sequentialAnimation + property variant target: null + property vector3d neutralPos: Qt.vector3d(0, 0, 0) + property real dx: 1.0 + loops: Animation.Infinite + + Vector3dAnimation { + target: sequentialAnimation.target + property: "translation" + from: sequentialAnimation.neutralPos.plus(Qt.vector3d(-sequentialAnimation.dx, 0.0, 0.0)) + to: sequentialAnimation.neutralPos.plus(Qt.vector3d(sequentialAnimation.dx, 0.0, 0.0)) + duration: 1000 + } + Vector3dAnimation { + target: sequentialAnimation.target + property: "translation" + from: sequentialAnimation.neutralPos.plus(Qt.vector3d(sequentialAnimation.dx, 0.0, 0.0)) + to: sequentialAnimation.neutralPos.plus(Qt.vector3d(-sequentialAnimation.dx, 0.0, 0.0)) + duration: 1000 + } + } + } } } |