summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-01-21 15:53:09 +0000
committerPaul Lemire <paul.lemire@kdab.com>2017-01-27 11:17:15 +0000
commit4a94e68d5975b53f11ab2ab7755f6b944fc8b614 (patch)
tree6cc7116b0e37d69a54f6f64241240001b7e17add /tests
parent50181a712f547ec93f8ba026385c99e982535a66 (diff)
Add a job to load animation clips
Defers the actual work to AnimationClip. Also made all backend nodes have a common base class to make it easy to track the Handler. Added a manual test to exercise this and which we can build up over time as we add API. Change-Id: I7cdd8da948498544059ba51efe38642dd54ea410 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/animation/animationclip/tst_animationclip.cpp6
-rw-r--r--tests/manual/animation-keyframe-simple/DefaultSceneEntity.qml35
-rw-r--r--tests/manual/animation-keyframe-simple/animation-keyframe-simple.pro5
-rw-r--r--tests/manual/animation-keyframe-simple/cubeanimation.json35
-rw-r--r--tests/manual/animation-keyframe-simple/main.cpp25
-rw-r--r--tests/manual/animation-keyframe-simple/main.qml53
-rw-r--r--tests/manual/animation-keyframe-simple/main.qrc7
-rw-r--r--tests/manual/manual.pro3
8 files changed, 168 insertions, 1 deletions
diff --git a/tests/auto/animation/animationclip/tst_animationclip.cpp b/tests/auto/animation/animationclip/tst_animationclip.cpp
index 735646db6..cd1d2ccf0 100644
--- a/tests/auto/animation/animationclip/tst_animationclip.cpp
+++ b/tests/auto/animation/animationclip/tst_animationclip.cpp
@@ -45,6 +45,8 @@ private Q_SLOTS:
{
// GIVEN
Qt3DAnimation::Animation::AnimationClip backendClip;
+ Qt3DAnimation::Animation::Handler handler;
+ backendClip.setHandler(&handler);
Qt3DAnimation::QAnimationClip clip;
clip.setSource(QUrl::fromLocalFile("walk.qlip"));
@@ -62,6 +64,8 @@ private Q_SLOTS:
{
// GIVEN
Qt3DAnimation::Animation::AnimationClip backendClip;
+ Qt3DAnimation::Animation::Handler handler;
+ backendClip.setHandler(&handler);
// THEN
QVERIFY(backendClip.peerId().isNull());
@@ -86,6 +90,8 @@ private Q_SLOTS:
{
// GIVEN
Qt3DAnimation::Animation::AnimationClip backendClip;
+ Qt3DAnimation::Animation::Handler handler;
+ backendClip.setHandler(&handler);
Qt3DCore::QPropertyUpdatedChangePtr updateChange;
// WHEN
diff --git a/tests/manual/animation-keyframe-simple/DefaultSceneEntity.qml b/tests/manual/animation-keyframe-simple/DefaultSceneEntity.qml
new file mode 100644
index 000000000..efffd44c9
--- /dev/null
+++ b/tests/manual/animation-keyframe-simple/DefaultSceneEntity.qml
@@ -0,0 +1,35 @@
+/*************************************************************************
+ *
+ * Copyright (c) 2016, Klaralvdalens Datakonsult AB (KDAB)
+ * All rights reserved.
+ *
+ * See the LICENSE.txt file shipped along with this file for the license.
+ *
+ *************************************************************************/
+
+import Qt3D.Core 2.0
+import Qt3D.Render 2.0
+import Qt3D.Input 2.0
+import Qt3D.Extras 2.0
+
+Entity {
+ id: root
+ property Camera camera
+
+ components: [
+ RenderSettings {
+ activeFrameGraph: ForwardRenderer {
+ camera: root.camera
+ }
+ },
+ // Event Source will be set by the Qt3DQuickWindow
+ InputSettings { }
+ ]
+
+ Entity {
+ components: [
+ PointLight { intensity: 0.5 },
+ Transform { translation: camera.position }
+ ]
+ }
+}
diff --git a/tests/manual/animation-keyframe-simple/animation-keyframe-simple.pro b/tests/manual/animation-keyframe-simple/animation-keyframe-simple.pro
new file mode 100644
index 000000000..04db4207e
--- /dev/null
+++ b/tests/manual/animation-keyframe-simple/animation-keyframe-simple.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+QT += 3dquickextras 3dquickanimation
+SOURCES += main.cpp
+RESOURCES += main.qrc
+OTHER_FILES += main.qml DefaultSceneEntity.qml
diff --git a/tests/manual/animation-keyframe-simple/cubeanimation.json b/tests/manual/animation-keyframe-simple/cubeanimation.json
new file mode 100644
index 000000000..e9c55177f
--- /dev/null
+++ b/tests/manual/animation-keyframe-simple/cubeanimation.json
@@ -0,0 +1,35 @@
+{
+ "animations": [
+ { "object": "Cube",
+ "action": "CubeAction",
+ "groups": [
+ { "group": "Location",
+ "channels": [
+ { "keyframes": [
+ { "co": [1.0, 0.0],
+ "handle_left": [-22.034278869628906, 0.0],
+ "handle_right": [24.034278869628906, 0.0]}
+ ,{ "co": [60.0, 5.0],
+ "handle_left": [36.965721130371094, 5.0],
+ "handle_right": [83.0342788696289, 5.0]}
+ ]}
+ ,{ "keyframes": [
+ { "co": [1.0, 0.0],
+ "handle_left": [-22.034278869628906, 0.0],
+ "handle_right": [24.034278869628906, 0.0]}
+ ,{ "co": [60.0, 0.0],
+ "handle_left": [36.965721130371094, 0.0],
+ "handle_right": [83.0342788696289, 0.0]}
+ ]}
+ ,{ "keyframes": [
+ { "co": [1.0, 0.0],
+ "handle_left": [-22.034278869628906, 0.0],
+ "handle_right": [24.034278869628906, 0.0]}
+ ,{ "co": [60.0, 0.0],
+ "handle_left": [36.965721130371094, 0.0],
+ "handle_right": [83.0342788696289, 0.0]}
+ ]}
+ ]}
+ ]}
+ ]
+}
diff --git a/tests/manual/animation-keyframe-simple/main.cpp b/tests/manual/animation-keyframe-simple/main.cpp
new file mode 100644
index 000000000..fc48fc702
--- /dev/null
+++ b/tests/manual/animation-keyframe-simple/main.cpp
@@ -0,0 +1,25 @@
+/*************************************************************************
+ *
+ * Copyright (c) 2016, Klaralvdalens Datakonsult AB (KDAB)
+ * All rights reserved.
+ *
+ * See the LICENSE.txt file shipped along with this file for the license.
+ *
+ *************************************************************************/
+
+#include <QGuiApplication>
+#include <Qt3DAnimation/QAnimationAspect>
+#include <Qt3DQuickExtras/Qt3DQuickWindow>
+#include <Qt3DQuick/QQmlAspectEngine>
+#include <QQmlEngine>
+#include <QQmlContext>
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+ Qt3DExtras::Quick::Qt3DQuickWindow view;
+ view.registerAspect(new Qt3DAnimation::QAnimationAspect());
+ view.setSource(QUrl("qrc:/main.qml"));
+ view.show();
+ return app.exec();
+}
diff --git a/tests/manual/animation-keyframe-simple/main.qml b/tests/manual/animation-keyframe-simple/main.qml
new file mode 100644
index 000000000..37f5eba2f
--- /dev/null
+++ b/tests/manual/animation-keyframe-simple/main.qml
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * Copyright (c) 2016, Klaralvdalens Datakonsult AB (KDAB)
+ * All rights reserved.
+ *
+ * See the LICENSE.txt file shipped along with this file for the license.
+ *
+ *************************************************************************/
+
+import Qt3D.Core 2.0
+import Qt3D.Render 2.0
+import Qt3D.Input 2.0
+import Qt3D.Animation 2.2
+import Qt3D.Extras 2.0
+
+DefaultSceneEntity {
+ id: scene
+
+ Entity {
+ id: cube
+
+ components: [
+ CuboidMesh {
+ },
+ PhongMaterial {
+ ambient: Qt.rgba(0.02, 0.02, 0.02, 1.0)
+ diffuse: "blue"
+ shininess: 50
+ },
+ Transform {
+ id: cubeTransform
+ },
+ ClipAnimator {
+ running: true
+ clip: AnimationClip {
+ source: "cubeanimation.json"
+ }
+ }
+
+ ]
+ }
+
+ camera: Camera {
+ position: Qt.vector3d(10, 10, 10)
+ viewCenter: Qt.vector3d(0, 0, 0)
+ }
+
+ OrbitCameraController {
+ camera: scene.camera
+ linearSpeed: 8
+ lookSpeed: 180
+ }
+}
diff --git a/tests/manual/animation-keyframe-simple/main.qrc b/tests/manual/animation-keyframe-simple/main.qrc
new file mode 100644
index 000000000..ca5342f26
--- /dev/null
+++ b/tests/manual/animation-keyframe-simple/main.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>DefaultSceneEntity.qml</file>
+ <file>cubeanimation.json</file>
+ </qresource>
+</RCC>
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index 90e9c250e..a2ca61758 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -37,7 +37,8 @@ SUBDIRS += \
transparency-qml-scene3d \
rendercapture-qml \
additional-attributes-qml \
- dynamic-model-loader-qml
+ dynamic-model-loader-qml \
+ animation-keyframe-simple
qtHaveModule(widgets): {
SUBDIRS += \