summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2018-10-11 14:36:07 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2018-10-12 12:15:57 +0000
commit91dba60d9f7d6291ff51a8f716f7cb5a0a6b61ac (patch)
tree46bbcff0059273f7390e5932e7e3b6bb228f7e38 /examples
parent96f21667252ff3afffb78ff7e7556c5be10dd0b1 (diff)
Bring View3D and Studio3DProfiler back as public
This reverts commit 0752ab7e7b7c3d2e5daa6023c4ea93c84b8e45ec. Change-Id: Ie2f71e19a8a05fd1d2554934a9dba235dca9933c Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/3dstudioruntime2/3dstudioruntime2.pro3
-rw-r--r--examples/3dstudioruntime2/layersinquick/doc/images/layersinquick.pngbin0 -> 60482 bytes
-rw-r--r--examples/3dstudioruntime2/layersinquick/doc/src/layersinquick.qdoc65
-rw-r--r--examples/3dstudioruntime2/layersinquick/layers.uip58
-rw-r--r--examples/3dstudioruntime2/layersinquick/layers_ssaa_msaa.uip58
-rw-r--r--examples/3dstudioruntime2/layersinquick/layersinquick.pro14
-rw-r--r--examples/3dstudioruntime2/layersinquick/layersinquick.qrc7
-rw-r--r--examples/3dstudioruntime2/layersinquick/main.cpp75
-rw-r--r--examples/3dstudioruntime2/layersinquick/main.qml220
9 files changed, 499 insertions, 1 deletions
diff --git a/examples/3dstudioruntime2/3dstudioruntime2.pro b/examples/3dstudioruntime2/3dstudioruntime2.pro
index 1ad83f1..37e384d 100644
--- a/examples/3dstudioruntime2/3dstudioruntime2.pro
+++ b/examples/3dstudioruntime2/3dstudioruntime2.pro
@@ -6,7 +6,8 @@ SUBDIRS += \
qtHaveModule(quick) {
SUBDIRS += simpleqml \
- qmldatainput
+ qmldatainput \
+ layersinquick
}
qtHaveModule(widgets) {
diff --git a/examples/3dstudioruntime2/layersinquick/doc/images/layersinquick.png b/examples/3dstudioruntime2/layersinquick/doc/images/layersinquick.png
new file mode 100644
index 0000000..d486b90
--- /dev/null
+++ b/examples/3dstudioruntime2/layersinquick/doc/images/layersinquick.png
Binary files differ
diff --git a/examples/3dstudioruntime2/layersinquick/doc/src/layersinquick.qdoc b/examples/3dstudioruntime2/layersinquick/doc/src/layersinquick.qdoc
new file mode 100644
index 0000000..46ed0f7
--- /dev/null
+++ b/examples/3dstudioruntime2/layersinquick/doc/src/layersinquick.qdoc
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example layersinquick
+ \title Qt 3D Studio Runtime: Layers in Qt Quick Example
+ \ingroup qt3dstudioruntime2-examples-qml
+ \brief Demonstrates using the View3D element in a Qt Quick application
+
+ \image layersinquick.png
+
+ \e {This example demonstrates basic usage of the View3D element in Qt Quick applications}
+
+ \include examples-run.qdocinc
+
+ \section1 Description
+
+ This example consists of a simple C++ main() function that sets up a
+ QQuickView and a QML scene demonstrating the usage of the \l Studio3D and
+ \l View3D QML types. This combination is important because once a \l View3D
+ element is added to the Qt Quick scene, the behavior of \l Studio3D changes
+ significantly: instead of displaying the composited image of all layers
+ from the Qt 3D Studio presentation loaded from the \c{.uip} file(s), it
+ rather delegates the rendering of the individual layers to the \l View3D
+ items.
+
+ This offers a lightweight and efficient way to create user interfaces that
+ have 3D content present in a number of different areas in the window. In
+ contrast, the traditional approach treats the 3D view as a "box", a
+ rectangular area defined by the bounds of the \l Studio3D element. With \l
+ View3D this limitation can be lifted since each layer from the 3D scene can
+ be managed (positioned, transformed, blended) individually via a \l View3D
+ instance dedicated to that layer.
+
+ In the example the source \c{.uip} file has two layers. Both have
+ transparent backgrounds, one contains a single cube, while the other a
+ sphere and some text nodes. When it comes to the \l Studio3D item, the QML
+ code is no different from other examples. What makes it special is the
+ inclusion of two \l View3D items, each referencing a layer from the
+ \c{.uip} presentation by name.
+ */
diff --git a/examples/3dstudioruntime2/layersinquick/layers.uip b/examples/3dstudioruntime2/layersinquick/layers.uip
new file mode 100644
index 0000000..171f226
--- /dev/null
+++ b/examples/3dstudioruntime2/layersinquick/layers.uip
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<UIP version="4" >
+ <Project >
+ <ProjectSettings author="" company="" presentationWidth="1366" presentationHeight="768" maintainAspect="False" >
+ <CustomColors count="16" >#ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors>
+ </ProjectSettings>
+ <Graph >
+ <Scene id="Scene" backgroundcolor="0.317647 0.65098 0.956863" bgcolorenable="True" >
+ <Layer id="Layer" >
+ <Camera id="Camera" />
+ <Light id="Light" />
+ <Model id="Cube" >
+ <Material id="Default" name="Default" />
+ </Model>
+ </Layer>
+ <Layer id="LayerWithSolidBackground" >
+ <Text id="Text4" />
+ <Text id="Text2" />
+ <Text id="Text" />
+ <Camera id="Camera_001" />
+ <Light id="Light_001" />
+ <Model id="Sphere" >
+ <Material id="Default_001" name="Default" />
+ </Model>
+ <Text id="Text3" />
+ </Layer>
+ </Scene>
+ </Graph>
+ <Logic >
+ <State name="Master Slide" component="#Scene" >
+ <Add ref="#Layer" name="LayerWithTransparentBackground" />
+ <Add ref="#Camera" position="0 0 -600" rotation="0 0 0" />
+ <Add ref="#Light" />
+ <State id="Scene-Slide1" name="Slide1" playmode="Looping" >
+ <Add ref="#Cube" name="Cube" position="-43.3013 29.7696 0" rotation="-16.5703 -27.2172 8.34447" sourcepath="#Cube" >
+ <AnimationTrack property="rotation.x" type="EaseInOut" >0 -16.5703 100 100 10 -16.57 100 100</AnimationTrack>
+ <AnimationTrack property="rotation.y" type="EaseInOut" >0 -27.2172 100 100 10 360 100 100</AnimationTrack>
+ <AnimationTrack property="rotation.z" type="EaseInOut" >0 8.34447 100 100 10 8.344 100 100</AnimationTrack>
+ </Add>
+ <Add ref="#Default" />
+ <Add ref="#LayerWithSolidBackground" name="LayerWithSolidBackground" background="SolidColor" backgroundcolor="0.239216 0.647059 1" />
+ <Add ref="#Text4" name="Text4" font="TitilliumWeb-Regular" position="569.231 -0.902103 0" textstring="Right" />
+ <Add ref="#Text2" name="Text2" font="TitilliumWeb-Regular" position="-6.31475 -306.717 0" textstring="Bottom" />
+ <Add ref="#Text" name="Text" font="TitilliumWeb-Regular" position="-3.60843 313.032 0" textstring="Top" />
+ <Add ref="#Camera_001" />
+ <Add ref="#Light_001" />
+ <Add ref="#Sphere" name="Sphere" sourcepath="#Sphere" >
+ <AnimationTrack property="position.x" type="EaseInOut" >0 0 100 100 5.083 -6.31474 100 100 10 0 100 100</AnimationTrack>
+ <AnimationTrack property="position.y" type="EaseInOut" >0 0 100 100 5.083 163.282 100 100 10 0 100 100</AnimationTrack>
+ <AnimationTrack property="position.z" type="EaseInOut" >0 0 100 100 5.083 0 100 100 10 0 100 100</AnimationTrack>
+ </Add>
+ <Add ref="#Default_001" />
+ <Add ref="#Text3" name="Text3" font="TitilliumWeb-Regular" position="-572.84 27.0633 0" textstring="Left" />
+ </State>
+ </State>
+ </Logic>
+ </Project>
+</UIP>
diff --git a/examples/3dstudioruntime2/layersinquick/layers_ssaa_msaa.uip b/examples/3dstudioruntime2/layersinquick/layers_ssaa_msaa.uip
new file mode 100644
index 0000000..9396fa8
--- /dev/null
+++ b/examples/3dstudioruntime2/layersinquick/layers_ssaa_msaa.uip
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<UIP version="4" >
+ <Project >
+ <ProjectSettings author="" company="" presentationWidth="1366" presentationHeight="768" maintainAspect="False" >
+ <CustomColors count="16" >#ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors>
+ </ProjectSettings>
+ <Graph >
+ <Scene id="Scene" backgroundcolor="0.317647 0.65098 0.956863" bgcolorenable="True" >
+ <Layer id="Layer" >
+ <Camera id="Camera" />
+ <Light id="Light" />
+ <Model id="Cube" >
+ <Material id="Default" name="Default" />
+ </Model>
+ </Layer>
+ <Layer id="LayerWithSolidBackground" >
+ <Text id="Text4" />
+ <Text id="Text2" />
+ <Text id="Text" />
+ <Camera id="Camera_001" />
+ <Light id="Light_001" />
+ <Model id="Sphere" >
+ <Material id="Default_001" name="Default" />
+ </Model>
+ <Text id="Text3" />
+ </Layer>
+ </Scene>
+ </Graph>
+ <Logic >
+ <State name="Master Slide" component="#Scene" >
+ <Add ref="#Layer" name="LayerWithTransparentBackground" multisampleaa="SSAA" />
+ <Add ref="#Camera" position="0 0 -600" rotation="0 0 0" />
+ <Add ref="#Light" />
+ <State id="Scene-Slide1" name="Slide1" playmode="Looping" >
+ <Add ref="#Cube" name="Cube" position="-43.3013 29.7696 0" rotation="-16.5703 -27.2172 8.34447" sourcepath="#Cube" >
+ <AnimationTrack property="rotation.x" type="EaseInOut" >0 -16.5703 100 100 10 -16.57 100 100</AnimationTrack>
+ <AnimationTrack property="rotation.y" type="EaseInOut" >0 -27.2172 100 100 10 360 100 100</AnimationTrack>
+ <AnimationTrack property="rotation.z" type="EaseInOut" >0 8.34447 100 100 10 8.344 100 100</AnimationTrack>
+ </Add>
+ <Add ref="#Default" />
+ <Add ref="#LayerWithSolidBackground" name="LayerWithSolidBackground" background="SolidColor" backgroundcolor="0.239216 0.647059 1" multisampleaa="4x" />
+ <Add ref="#Text4" name="Text4" font="TitilliumWeb-Regular" position="569.231 -0.902103 0" textstring="Right" />
+ <Add ref="#Text2" name="Text2" font="TitilliumWeb-Regular" position="-6.31475 -306.717 0" textstring="Bottom" />
+ <Add ref="#Text" name="Text" font="TitilliumWeb-Regular" position="-3.60843 313.032 0" textstring="Top" />
+ <Add ref="#Camera_001" />
+ <Add ref="#Light_001" />
+ <Add ref="#Sphere" name="Sphere" sourcepath="#Sphere" >
+ <AnimationTrack property="position.x" type="EaseInOut" >0 0 100 100 5.083 -6.31474 100 100 10 0 100 100</AnimationTrack>
+ <AnimationTrack property="position.y" type="EaseInOut" >0 0 100 100 5.083 163.282 100 100 10 0 100 100</AnimationTrack>
+ <AnimationTrack property="position.z" type="EaseInOut" >0 0 100 100 5.083 0 100 100 10 0 100 100</AnimationTrack>
+ </Add>
+ <Add ref="#Default_001" />
+ <Add ref="#Text3" name="Text3" font="TitilliumWeb-Regular" position="-572.84 27.0633 0" textstring="Left" />
+ </State>
+ </State>
+ </Logic>
+ </Project>
+</UIP>
diff --git a/examples/3dstudioruntime2/layersinquick/layersinquick.pro b/examples/3dstudioruntime2/layersinquick/layersinquick.pro
new file mode 100644
index 0000000..f26e1c4
--- /dev/null
+++ b/examples/3dstudioruntime2/layersinquick/layersinquick.pro
@@ -0,0 +1,14 @@
+TEMPLATE = app
+
+QT += quick 3dstudioruntime2
+
+SOURCES += \
+ main.cpp
+
+RESOURCES += layersinquick.qrc
+
+OTHER_FILES += \
+ main.qml
+
+target.path = $$[QT_INSTALL_EXAMPLES]/3dstudioruntime2/$$TARGET
+INSTALLS += target
diff --git a/examples/3dstudioruntime2/layersinquick/layersinquick.qrc b/examples/3dstudioruntime2/layersinquick/layersinquick.qrc
new file mode 100644
index 0000000..e487405
--- /dev/null
+++ b/examples/3dstudioruntime2/layersinquick/layersinquick.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>layers.uip</file>
+ <file>layers_ssaa_msaa.uip</file>
+ </qresource>
+</RCC>
diff --git a/examples/3dstudioruntime2/layersinquick/main.cpp b/examples/3dstudioruntime2/layersinquick/main.cpp
new file mode 100644
index 0000000..728e75d
--- /dev/null
+++ b/examples/3dstudioruntime2/layersinquick/main.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQuickView>
+#include <q3dsruntimeglobal.h>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ qputenv("QSG_INFO", "1");
+ QGuiApplication app(argc, argv);
+
+ // Use the ideal format (i.e. OpenGL version and profile) recommended by
+ // the Qt 3D Studio runtime. Without this the format set on the QQuickView
+ // would be used instead.
+ QSurfaceFormat::setDefaultFormat(Q3DS::surfaceFormat());
+
+ QQuickView viewer;
+ viewer.setSource(QUrl("qrc:/main.qml"));
+
+ viewer.setTitle(QStringLiteral("Qt 3D Studio Layers-as-Quick-items Example"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.resize(1280, 720);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/3dstudioruntime2/layersinquick/main.qml b/examples/3dstudioruntime2/layersinquick/main.qml
new file mode 100644
index 0000000..f7e3d39
--- /dev/null
+++ b/examples/3dstudioruntime2/layersinquick/main.qml
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtStudio3D 2.2
+import QtQuick.Controls 2.2
+
+Rectangle {
+ id: root
+ color: "lightGray"
+
+ Button {
+ id: profBtn
+ text: "Profile UI"
+ // we use a Studio3DProfiler item so toggle that instead of pres.profileUiVisible
+ onClicked: quickBasedProfileUI.visible = !quickBasedProfileUI.visible
+ focusPolicy: Qt.NoFocus
+ }
+
+ CheckBox {
+ id: shaderEffectCb
+ text: "ShaderEffect"
+ checked: true
+ anchors.left: profBtn.right
+ focusPolicy: Qt.NoFocus
+ }
+
+ CheckBox {
+ id: sizeFollowCb
+ text: "Layer follows View size"
+ checked: true
+ anchors.left: shaderEffectCb.right
+ focusPolicy: Qt.NoFocus
+ }
+
+ CheckBox {
+ id: msaaCb
+ text: "SSAA/MSAA version"
+ checked: false
+ anchors.left: sizeFollowCb.right
+ focusPolicy: Qt.NoFocus
+ }
+
+ Studio3D {
+ id: s3d
+ anchors.fill: parent
+ anchors.margins: 40
+
+ Presentation {
+ id: pres
+ source: msaaCb.checked ? "qrc:/layers_ssaa_msaa.uip" : "qrc:/layers.uip"
+ profilingEnabled: true
+ }
+ }
+
+ Rectangle {
+ y: 40
+ width: parent.width / 2
+ height: parent.height - 40
+ color: "red"
+
+ View3D {
+ id: viewFor3DLayer1
+ engine: s3d
+ source: "LayerWithTransparentBackground"
+ sizeLayerToView: sizeFollowCb.checked
+
+ anchors.fill: parent
+ anchors.margins: 10
+
+ property bool shaderEffectActive: shaderEffectCb.checked
+ visible: !shaderEffectActive
+ }
+
+ ShaderEffectSource {
+ id: effSource
+ sourceItem: viewFor3DLayer1
+ visible: viewFor3DLayer1.shaderEffectActive
+ }
+
+ ShaderEffect {
+ visible: viewFor3DLayer1.shaderEffectActive
+ anchors.fill: parent
+ anchors.margins: 10
+ property variant source: effSource
+ property real amplitude: 0.02
+ property real frequency: 20
+ property real time: 0
+ NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
+ fragmentShader:
+ "#version 330 core\n" +
+ "uniform float qt_Opacity;\n" +
+ "uniform float amplitude;\n" +
+ "uniform float frequency;\n" +
+ "uniform float time;\n" +
+ "uniform sampler2D source;\n" +
+ "in vec2 qt_TexCoord0;\n" +
+ "out vec4 fragColor;\n" +
+ "void main() {\n" +
+ " vec2 p = sin(time + frequency * qt_TexCoord0);\n" +
+ " fragColor = texture(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;\n" +
+ "}"
+ }
+
+ Text {
+ text: "This here is a View3D in a Rectangle\ndisplaying only one layer from the Qt 3D Studio scene"
+ color: "black"
+ font.pointSize: 16
+ }
+ }
+
+ Rectangle {
+ x: parent.width / 2
+ y: 40
+ width: parent.width / 2
+ height: parent.height - 40
+ color: "green"
+
+ View3D {
+ id: viewFor3DLayer2
+ engine: s3d
+ source: "LayerWithSolidBackground"
+ sizeLayerToView: sizeFollowCb.checked
+
+ anchors.fill: parent
+ anchors.margins: 10
+
+ transform: [
+ Rotation { id: rotation; axis.x: 0; axis.z: 0; axis.y: 1; angle: 0; origin.x: viewFor3DLayer2.width / 2; origin.y: viewFor3DLayer2.height / 2; },
+ Translate { id: txOut; x: -viewFor3DLayer2.width / 2; y: -viewFor3DLayer2.height / 2 },
+ Scale { id: scale; },
+ Translate { id: txIn; x: viewFor3DLayer2.width / 2; y: viewFor3DLayer2.height / 2 }
+ ]
+
+ SequentialAnimation {
+ PauseAnimation { duration: 2000 }
+ ParallelAnimation {
+ NumberAnimation { target: scale; property: "xScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack }
+ NumberAnimation { target: scale; property: "yScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack }
+ }
+ NumberAnimation { target: rotation; property: "angle"; to: 80; duration: 1000; easing.type: Easing.InOutCubic }
+ NumberAnimation { target: rotation; property: "angle"; to: -80; duration: 1000; easing.type: Easing.InOutCubic }
+ NumberAnimation { target: rotation; property: "angle"; to: 0; duration: 1000; easing.type: Easing.InOutCubic }
+ NumberAnimation { target: viewFor3DLayer2; property: "opacity"; to: 0.5; duration: 1000; easing.type: Easing.InOutCubic }
+ PauseAnimation { duration: 1000 }
+ NumberAnimation { target: viewFor3DLayer2; property: "opacity"; to: 0.8; duration: 1000; easing.type: Easing.InOutCubic }
+ ParallelAnimation {
+ NumberAnimation { target: scale; property: "xScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack }
+ NumberAnimation { target: scale; property: "yScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack }
+ }
+ running: true
+ loops: Animation.Infinite
+ }
+ }
+
+ Text {
+ text: "Another View3D showing the other layer"
+ color: "black"
+ font.pointSize: 16
+ }
+ }
+
+ // This example uses Qt Quick-based debug views because rendering them with
+ // Qt 3D is not feasible anymore in the separated views model (as Qt 3D is
+ // not responsible for the final composed image).
+ Studio3DProfiler {
+ id: quickBasedProfileUI
+ visible: false
+ focus: true
+ anchors.fill: parent
+ anchors.topMargin: 40 // make sure we do not cover the top area with the buttons
+ }
+}