| 1 |
// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import Qt3D.Core 2.10 |
| 5 |
import Qt3D.Render 2.10 |
| 6 |
import Qt3D.Input 2.0 |
| 7 |
import Qt3D.Animation 2.10 |
| 8 |
import Qt3D.Extras 2.10 |
| 9 |
import QtQuick 2.9 |
| 10 |
|
| 11 |
DefaultSceneEntity { |
| 12 |
id: scene |
| 13 |
|
| 14 |
SkinnedPbrEffect { |
| 15 |
id: skinnedPbrEffect |
| 16 |
} |
| 17 |
|
| 18 |
Timer { |
| 19 |
interval: 2000 |
| 20 |
running: true |
| 21 |
repeat: false |
| 22 |
onTriggered: { |
| 23 |
animator1.running = true |
| 24 |
animator2.running = true |
| 25 |
animator3.running = true |
| 26 |
animator4.running = true |
| 27 |
animator5.running = true |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
SkinnedEntity { |
| 32 |
id: riggedFigure1 |
| 33 |
effect: skinnedPbrEffect |
| 34 |
source: "qrc:/assets/gltf/2.0/RiggedFigure/RiggedFigure.gltf" |
| 35 |
baseColor: "red" |
| 36 |
|
| 37 |
components: [ |
| 38 |
// ClipAnimator { |
| 39 |
// loops: 3 |
| 40 |
// clip: AnimationClipLoader { source: "qrc:/jump.json" } |
| 41 |
// channelMapper: ChannelMapper { |
| 42 |
// mappings: [ |
| 43 |
// SkeletonChannelMapping { target: riggedFigure.skeleton } |
| 44 |
// ] |
| 45 |
// } |
| 46 |
// } |
| 47 |
BlendedClipAnimator { |
| 48 |
id: animator1 |
| 49 |
loops: 5 |
| 50 |
blendTree: ClipBlendValue { |
| 51 |
clip: AnimationClipLoader { source: "qrc:/jump.json" } |
| 52 |
} |
| 53 |
channelMapper: ChannelMapper { |
| 54 |
mappings: [ |
| 55 |
SkeletonMapping { skeleton: riggedFigure1.skeleton } |
| 56 |
] |
| 57 |
} |
| 58 |
|
| 59 |
onRunningChanged: console.log("running = " + animator1.running) |
| 60 |
} |
| 61 |
] |
| 62 |
} |
| 63 |
|
| 64 |
SkinnedEntity { |
| 65 |
id: riggedFigure2 |
| 66 |
effect: skinnedPbrEffect |
| 67 |
source: "qrc:/assets/gltf/2.0/RiggedFigure/RiggedFigure.gltf" |
| 68 |
baseColor: "purple" |
| 69 |
transform.translation: Qt.vector3d(0.0, 0.0, -1.0); |
| 70 |
|
| 71 |
components: [ |
| 72 |
BlendedClipAnimator { |
| 73 |
id: animator2 |
| 74 |
loops: 5 |
| 75 |
blendTree: ClipBlendValue { |
| 76 |
clip: AnimationClipLoader { source: "qrc:/jump.json" } |
| 77 |
} |
| 78 |
channelMapper: ChannelMapper { |
| 79 |
mappings: [ |
| 80 |
SkeletonMapping { skeleton: riggedFigure2.skeleton } |
| 81 |
] |
| 82 |
} |
| 83 |
|
| 84 |
onRunningChanged: console.log("running = " + animator2.running) |
| 85 |
} |
| 86 |
] |
| 87 |
} |
| 88 |
|
| 89 |
SkinnedEntity { |
| 90 |
id: riggedFigure3 |
| 91 |
effect: skinnedPbrEffect |
| 92 |
source: "qrc:/assets/gltf/2.0/RiggedFigure/RiggedFigure.gltf" |
| 93 |
baseColor: "blue" |
| 94 |
transform.translation: Qt.vector3d(0.0, 0.0, -2.0); |
| 95 |
|
| 96 |
components: [ |
| 97 |
BlendedClipAnimator { |
| 98 |
id: animator3 |
| 99 |
loops: 5 |
| 100 |
blendTree: ClipBlendValue { |
| 101 |
clip: AnimationClipLoader { source: "qrc:/jump.json" } |
| 102 |
} |
| 103 |
channelMapper: ChannelMapper { |
| 104 |
mappings: [ |
| 105 |
SkeletonMapping { skeleton: riggedFigure3.skeleton } |
| 106 |
] |
| 107 |
} |
| 108 |
|
| 109 |
onRunningChanged: console.log("running = " + animator3.running) |
| 110 |
} |
| 111 |
] |
| 112 |
} |
| 113 |
|
| 114 |
SkinnedEntity { |
| 115 |
id: riggedFigure4 |
| 116 |
effect: skinnedPbrEffect |
| 117 |
source: "qrc:/assets/gltf/2.0/RiggedFigure/RiggedFigure.gltf" |
| 118 |
baseColor: "green" |
| 119 |
transform.translation: Qt.vector3d(0.0, 0.0, -3.0); |
| 120 |
|
| 121 |
components: [ |
| 122 |
BlendedClipAnimator { |
| 123 |
id: animator4 |
| 124 |
loops: 5 |
| 125 |
blendTree: ClipBlendValue { |
| 126 |
clip: AnimationClipLoader { source: "qrc:/jump.json" } |
| 127 |
} |
| 128 |
channelMapper: ChannelMapper { |
| 129 |
mappings: [ |
| 130 |
SkeletonMapping { skeleton: riggedFigure4.skeleton } |
| 131 |
] |
| 132 |
} |
| 133 |
|
| 134 |
onRunningChanged: console.log("running = " + animator4.running) |
| 135 |
} |
| 136 |
] |
| 137 |
} |
| 138 |
|
| 139 |
SkinnedEntity { |
| 140 |
id: riggedFigure5 |
| 141 |
effect: skinnedPbrEffect |
| 142 |
source: "qrc:/assets/gltf/2.0/RiggedFigure/RiggedFigure.gltf" |
| 143 |
baseColor: "orange" |
| 144 |
transform.translation: Qt.vector3d(0.0, 0.0, -4.0); |
| 145 |
|
| 146 |
components: [ |
| 147 |
BlendedClipAnimator { |
| 148 |
id: animator5 |
| 149 |
loops: 5 |
| 150 |
blendTree: ClipBlendValue { |
| 151 |
clip: AnimationClipLoader { source: "qrc:/jump.json" } |
| 152 |
} |
| 153 |
channelMapper: ChannelMapper { |
| 154 |
mappings: [ |
| 155 |
SkeletonMapping { skeleton: riggedFigure5.skeleton } |
| 156 |
] |
| 157 |
} |
| 158 |
|
| 159 |
// onRunningChanged: console.log("running = " + running) |
| 160 |
} |
| 161 |
] |
| 162 |
} |
| 163 |
|
| 164 |
SkinnedEntity { |
| 165 |
id: riggedSimple |
| 166 |
effect: skinnedPbrEffect |
| 167 |
source: "qrc:/assets/gltf/2.0/RiggedSimple/RiggedSimple.gltf" |
| 168 |
baseColor: "blue" |
| 169 |
transform.scale: 0.05 |
| 170 |
transform.translation: Qt.vector3d(0.5, 0.25, 0.0) |
| 171 |
createJointsEnabled: true |
| 172 |
|
| 173 |
onRootJointChanged: { |
| 174 |
var animation = animationComp.createObject(rootJoint) |
| 175 |
var targetJoint = rootJoint.childJoints[0] |
| 176 |
animation.target = targetJoint |
| 177 |
animation.running = true |
| 178 |
} |
| 179 |
|
| 180 |
Component { |
| 181 |
id: animationComp |
| 182 |
SequentialAnimation { |
| 183 |
id: sequentialAnimation |
| 184 |
property variant target: null |
| 185 |
property real dz: 30.0 |
| 186 |
loops: Animation.Infinite |
| 187 |
|
| 188 |
NumberAnimation { |
| 189 |
target: sequentialAnimation.target |
| 190 |
property: "rotationZ" |
| 191 |
from: -dz |
| 192 |
to: dz |
| 193 |
duration: 600 |
| 194 |
easing.type: Easing.OutCubic |
| 195 |
} |
| 196 |
NumberAnimation { |
| 197 |
target: sequentialAnimation.target |
| 198 |
property: "rotationZ" |
| 199 |
from: dz |
| 200 |
to: -dz |
| 201 |
duration: 600 |
| 202 |
easing.type: Easing.OutCubic |
| 203 |
} |
| 204 |
} |
| 205 |
} |
| 206 |
} |
| 207 |
} |