summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2018-10-24 10:24:51 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2018-10-29 13:21:44 +0000
commit575f9bd1073f8a2f7f621985e8177f56b2b17266 (patch)
treef8a6572e7aaa051e036ab848bf4f3ecd18ef8179
parente4daccb9ba8e8cef5dd61e72fdc93fa26986a425 (diff)
Add another View3D example
As we should demo the case where View3D's are inside a ListView's delegate. Will crash eventually when scrolling. That needs to be fixed separately in the engine. Change-Id: I32fd35608c98e182b7e22a92f4f5f9b69a387c5d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r--examples/3dstudioruntime2/3dstudioruntime2.pro3
-rw-r--r--examples/3dstudioruntime2/manylayersinquick/main.cpp75
-rw-r--r--examples/3dstudioruntime2/manylayersinquick/main.qml119
-rw-r--r--examples/3dstudioruntime2/manylayersinquick/manylayers.uia15
-rw-r--r--examples/3dstudioruntime2/manylayersinquick/manylayers.uip78
-rw-r--r--examples/3dstudioruntime2/manylayersinquick/manylayersinquick.pro14
-rw-r--r--examples/3dstudioruntime2/manylayersinquick/manylayersinquick.qrc6
7 files changed, 309 insertions, 1 deletions
diff --git a/examples/3dstudioruntime2/3dstudioruntime2.pro b/examples/3dstudioruntime2/3dstudioruntime2.pro
index 37e384d..b60052f 100644
--- a/examples/3dstudioruntime2/3dstudioruntime2.pro
+++ b/examples/3dstudioruntime2/3dstudioruntime2.pro
@@ -7,7 +7,8 @@ SUBDIRS += \
qtHaveModule(quick) {
SUBDIRS += simpleqml \
qmldatainput \
- layersinquick
+ layersinquick \
+ manylayersinquick
}
qtHaveModule(widgets) {
diff --git a/examples/3dstudioruntime2/manylayersinquick/main.cpp b/examples/3dstudioruntime2/manylayersinquick/main.cpp
new file mode 100644
index 0000000..f6a5c0c
--- /dev/null
+++ b/examples/3dstudioruntime2/manylayersinquick/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 No. 2"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.resize(1280, 720);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/3dstudioruntime2/manylayersinquick/main.qml b/examples/3dstudioruntime2/manylayersinquick/main.qml
new file mode 100644
index 0000000..a1ffa6c
--- /dev/null
+++ b/examples/3dstudioruntime2/manylayersinquick/main.qml
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** 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 QtQuick.Controls 2.2
+import QtStudio3D 2.2
+
+Rectangle {
+ id: root
+ color: "lightGray"
+
+ Studio3D {
+ id: s3d
+ Presentation {
+ id: pres
+ source: "qrc:/manylayers.uip"
+ profilingEnabled: true
+ }
+ property int layerCount: 3 // Layer1, Layer2, Layer3
+ }
+
+ ListView {
+ anchors.fill: parent
+
+ model: 32
+ delegate: Rectangle {
+ width: parent.width
+ height: 100
+ color: index % 2 ? "steelblue" : "lightsteelblue"
+ Rectangle {
+ border.color: "gray"
+ border.width: 2
+ radius: 8
+ color: "transparent"
+ anchors.centerIn: parent
+ width: parent.width / 2
+ height: parent.height - 10
+ View3D {
+ id: view3D
+ anchors.fill: parent
+ engine: s3d
+ source: "Layer" + ((index % s3d.layerCount) + 1)
+ }
+ }
+ Text {
+ anchors.verticalCenter: parent.verticalCenter
+ color: "green"
+ text: "3D layer '" + view3D.source + "'"
+ font.bold: true
+ }
+ }
+ }
+
+ 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
+ }
+
+ // 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 button
+ }
+}
diff --git a/examples/3dstudioruntime2/manylayersinquick/manylayers.uia b/examples/3dstudioruntime2/manylayersinquick/manylayers.uia
new file mode 100644
index 0000000..828a44b
--- /dev/null
+++ b/examples/3dstudioruntime2/manylayersinquick/manylayers.uia
@@ -0,0 +1,15 @@
+<?xml version='1.0' encoding='utf-8'?>
+<application xmlns="http://qt.io/qt3dstudio/uia">
+ <assets initial="ClassicContextMain">
+ <presentation src="manylayers.uip" id="ClassicContextMain"/>
+ </assets>
+ <statemachine ref="#logic">
+ <visual-states>
+ <state ref="Initial">
+ <enter>
+ <goto-slide element="main:Scene" rel="next"/>
+ </enter>
+ </state>
+ </visual-states>
+ </statemachine>
+</application>
diff --git a/examples/3dstudioruntime2/manylayersinquick/manylayers.uip b/examples/3dstudioruntime2/manylayersinquick/manylayers.uip
new file mode 100644
index 0000000..8ed17cd
--- /dev/null
+++ b/examples/3dstudioruntime2/manylayersinquick/manylayers.uip
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<UIP version="4" >
+ <Project >
+ <ProjectSettings author="" company="" presentationWidth="640" presentationHeight="480" 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="False" >
+ <Layer id="Layer1" >
+ <Camera id="Camera" />
+ <Light id="Light" />
+ <Model id="Cube" >
+ <Material id="Default" name="Default" />
+ </Model>
+ </Layer>
+ <Layer id="Layer2" >
+ <Camera id="Camera_001" />
+ <Light id="Light_001" />
+ <Model id="Sphere" >
+ <Material id="Default_001" name="Default" />
+ </Model>
+ </Layer>
+ <Layer id="Layer3" >
+ <Camera id="Camera_002" />
+ <Light id="Light_002" />
+ <Model id="Cylinder" >
+ <Material id="Default_002" name="Default" />
+ </Model>
+ <Model id="Cone" >
+ <Material id="Default_003" name="Default" />
+ </Model>
+ </Layer>
+ </Scene>
+ </Graph>
+ <Logic >
+ <State name="Master Slide" component="#Scene" >
+ <Add ref="#Layer1" name="Layer1" />
+ <Add ref="#Camera" position="0 0 -600" rotation="0 0 0" />
+ <Add ref="#Light" lightdiffuse="1 1 0.721569" />
+ <State id="Scene-Slide1" name="Slide1" playmode="Looping" >
+ <Add ref="#Cube" name="Cube" position="0.180962 -0.720062 32.5651" rotation="-16.5703 -27.2172 8.34447" scale="2.7901 4.29753 1" sourcepath="#Cube" >
+ <AnimationTrack property="rotation.x" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack>
+ <AnimationTrack property="rotation.y" type="EaseInOut" >0 0 100 100 10 360 100 100</AnimationTrack>
+ <AnimationTrack property="rotation.z" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack>
+ </Add>
+ <Add ref="#Default" />
+ <Add ref="#Layer2" name="Layer2" background="Transparent" backgroundcolor="0.239216 0.647059 1" />
+ <Add ref="#Camera_001" />
+ <Add ref="#Light_001" />
+ <Add ref="#Sphere" name="Sphere" rotation="0 -45 0" scale="3.44068 3.09375 1" 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>
+ <AnimationTrack property="rotation.x" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack>
+ <AnimationTrack property="rotation.y" type="EaseInOut" >0 45 100 100 10 -45 100 100</AnimationTrack>
+ <AnimationTrack property="rotation.z" type="EaseInOut" >0 0 100 100 10 0 100 100</AnimationTrack>
+ </Add>
+ <Add ref="#Default_001" />
+ <Add ref="#Layer3" name="Layer3" background="Transparent" backgroundcolor="0.239216 0.647059 1" />
+ <Add ref="#Camera_002" />
+ <Add ref="#Light_002" />
+ <Add ref="#Cylinder" name="Cylinder" rotation="-42.4866 14.7144 -21.247" scale="1.85959 3.83831 1" sourcepath="#Cylinder" >
+ <AnimationTrack property="position.x" type="EaseInOut" >0 0 100 100 6.15 0 100 100 10 0 100 100</AnimationTrack>
+ <AnimationTrack property="position.y" type="EaseInOut" >0 0 100 100 6.15 100 100 100 10 0 100 100</AnimationTrack>
+ <AnimationTrack property="position.z" type="EaseInOut" >0 0 100 100 6.15 0 100 100 10 0 100 100</AnimationTrack>
+ </Add>
+ <Add ref="#Default_002" />
+ <Add ref="#Cone" name="Cone" position="-316.099 34.641 0" scale="1.85248 2.08915 1" sourcepath="#Cone" >
+ <AnimationTrack property="position.x" type="EaseInOut" >0 -316.099 100 100 5.65 -316.099 100 100 10 -316.099 100 100</AnimationTrack>
+ <AnimationTrack property="position.y" type="EaseInOut" >0 34.641 100 100 5.65 -50 100 100 10 -34 100 100</AnimationTrack>
+ <AnimationTrack property="position.z" type="EaseInOut" >0 0 100 100 5.65 0 100 100 10 0 100 100</AnimationTrack>
+ </Add>
+ <Add ref="#Default_003" />
+ </State>
+ </State>
+ </Logic>
+ </Project>
+</UIP>
diff --git a/examples/3dstudioruntime2/manylayersinquick/manylayersinquick.pro b/examples/3dstudioruntime2/manylayersinquick/manylayersinquick.pro
new file mode 100644
index 0000000..2fbd78a
--- /dev/null
+++ b/examples/3dstudioruntime2/manylayersinquick/manylayersinquick.pro
@@ -0,0 +1,14 @@
+TEMPLATE = app
+
+QT += quick 3dstudioruntime2
+
+SOURCES += \
+ main.cpp
+
+RESOURCES += manylayersinquick.qrc
+
+OTHER_FILES += \
+ main.qml
+
+target.path = $$[QT_INSTALL_EXAMPLES]/3dstudioruntime2/$$TARGET
+INSTALLS += target
diff --git a/examples/3dstudioruntime2/manylayersinquick/manylayersinquick.qrc b/examples/3dstudioruntime2/manylayersinquick/manylayersinquick.qrc
new file mode 100644
index 0000000..a91206f
--- /dev/null
+++ b/examples/3dstudioruntime2/manylayersinquick/manylayersinquick.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>manylayers.uip</file>
+ </qresource>
+</RCC>