From ef096175a0d0da6b79e5809d6a249b906ea0e578 Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Tue, 20 Jan 2015 11:49:14 +0100 Subject: enabled-qml: use enabled flag on FrameGraph nodes Change-Id: Ifd76233a38b07ee82bb0dca2cd69746144711c11 Reviewed-by: Sean Harmer --- examples/enabled-qml/main.cpp | 6 +- examples/enabled-qml/main.qml | 172 ++++++++++++++++++++++++++---------------- 2 files changed, 110 insertions(+), 68 deletions(-) (limited to 'examples') diff --git a/examples/enabled-qml/main.cpp b/examples/enabled-qml/main.cpp index f5db7be29..61425f19b 100644 --- a/examples/enabled-qml/main.cpp +++ b/examples/enabled-qml/main.cpp @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include @@ -53,13 +53,13 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - Qt3D::Quick::QuickWindow view; + Qt3D::Window view; Qt3D::Quick::QQmlAspectEngine engine; engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect()); engine.aspectEngine()->initialize(); QVariantMap data; data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast(&view))); - data.insert(QStringLiteral("window"), QVariant::fromValue(&view)); + data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); engine.aspectEngine()->setData(data); engine.setSource(QUrl(QStringLiteral("qrc:/main.qml"))); view.show(); diff --git a/examples/enabled-qml/main.qml b/examples/enabled-qml/main.qml index 0d4f2723c..5c69ee192 100644 --- a/examples/enabled-qml/main.qml +++ b/examples/enabled-qml/main.qml @@ -48,8 +48,25 @@ Entity { property int counter: 0 components: FrameGraph { - ForwardRenderer { - camera: basicCamera + Viewport { + rect: Qt.rect(0.0, 0.0, 1.0, 1.0) + clearColor: "white" + enabled: counter !== 5 + + ClearBuffer { + buffers : ClearBuffer.ColorDepthBuffer + enabled: counter !== 6 + } + + CameraSelector { + camera: basicCamera + enabled: counter !== 7 + + LayerFilter { + enabled: counter === 12 + layers: "scene" + } + } } } @@ -59,7 +76,7 @@ Entity { running: true onTriggered: { counter += 1; - if (counter > 6) + if (counter > 15) counter = 0; } } @@ -72,7 +89,7 @@ Entity { LookAt { upVector: Qt.vector3d(0, 1, 0) viewCenter: Qt.vector3d(0, 0, 0) - position: Qt.vector3d(0, 0, -10) + position: Qt.vector3d(0, 10, -10) } } components: [basicCameraTransform, cameraLens] @@ -88,76 +105,101 @@ Entity { enabled: counter !== 4 } - SphereMesh { - id: sphereMesh - enabled: counter !== 0 - } + // Sphere + Entity { + SphereMesh { + id: sphereMesh + enabled: counter !== 0 + } - PhongMaterial { - id: material - ambient: "dodgerblue" - diffuse: "chartreuse" - specular: "ghostwhite" - enabled: counter !== 1 - } + PhongMaterial { + id: material + ambient: "dodgerblue" + diffuse: "chartreuse" + specular: "ghostwhite" + enabled: counter !== 1 + } - Layer { - id: layer - enabled: counter !== 2 - } + Layer { + id: layer + enabled: counter !== 2 + names: "scene" + } - Transform { - id: transform - enabled: counter !== 3 - - Translate { - id: translate - - QQ2.SequentialAnimation { - running: true - loops: QQ2.Animation.Infinite - QQ2.NumberAnimation { - target: translate; property: "dx" - from: 0; to: 5; - duration: 550 - easing.type: QQ2.Easing.InOutQuad - } - QQ2.NumberAnimation { - target: translate; property: "dy" - from: 0; to: 5; - duration: 650 - easing.type: QQ2.Easing.InOutQuad - } - QQ2.NumberAnimation { - target: translate; property: "dz" - from: 0; to: 5; - duration: 350 - easing.type: QQ2.Easing.InOutQuad - } - QQ2.NumberAnimation { - target: translate; property: "dx" - from: 5; to: 0; - duration: 550 - easing.type: QQ2.Easing.InOutQuad - } - QQ2.NumberAnimation { - target: translate; property: "dy" - from: 5; to: 0; - duration: 350 - easing.type: QQ2.Easing.InOutQuad - } - QQ2.NumberAnimation { - target: translate; property: "dz" - from: 5; to: 0; - duration: 650 - easing.type: QQ2.Easing.InOutQuad + Transform { + id: transform + enabled: counter !== 3 + + Translate { + id: translate + + QQ2.SequentialAnimation { + running: true + loops: QQ2.Animation.Infinite + QQ2.NumberAnimation { + target: translate; property: "dx" + from: 0; to: 5; + duration: 550 + easing.type: QQ2.Easing.InOutQuad + } + QQ2.NumberAnimation { + target: translate; property: "dy" + from: 0; to: 5; + duration: 650 + easing.type: QQ2.Easing.InOutQuad + } + QQ2.NumberAnimation { + target: translate; property: "dz" + from: 0; to: 5; + duration: 350 + easing.type: QQ2.Easing.InOutQuad + } + QQ2.NumberAnimation { + target: translate; property: "dx" + from: 5; to: 0; + duration: 550 + easing.type: QQ2.Easing.InOutQuad + } + QQ2.NumberAnimation { + target: translate; property: "dy" + from: 5; to: 0; + duration: 350 + easing.type: QQ2.Easing.InOutQuad + } + QQ2.NumberAnimation { + target: translate; property: "dz" + from: 5; to: 0; + duration: 650 + easing.type: QQ2.Easing.InOutQuad + } } } } + components: [sphereMesh, material, layer, transform] } + // Floor Entity { - components: [sphereMesh, material, layer, transform] + PlaneMesh { + id: planeMesh + width: 25.0 + height: 10 + } + + PhongMaterial { + id: floorMaterial + ambient: "lawngreen" + diffuse: "forestgreen" + specular: "floralwhite" + shininess: 0.5 + } + + Layer { + id: floorLayer + names: "floor" + } + + components: [planeMesh, floorMaterial, floorLayer] } } -- cgit v1.2.3