diff options
Diffstat (limited to 'examples/3dstudioruntime2')
30 files changed, 619 insertions, 69 deletions
diff --git a/examples/3dstudioruntime2/qmldatainput/doc/images/qmldatainput.png b/examples/3dstudioruntime2/qmldatainput/doc/images/qmldatainput.png Binary files differnew file mode 100644 index 0000000..e0567ee --- /dev/null +++ b/examples/3dstudioruntime2/qmldatainput/doc/images/qmldatainput.png diff --git a/examples/3dstudioruntime2/qmldatainput/doc/src/qmldatainput.qdoc b/examples/3dstudioruntime2/qmldatainput/doc/src/qmldatainput.qdoc new file mode 100644 index 0000000..58e6ae5 --- /dev/null +++ b/examples/3dstudioruntime2/qmldatainput/doc/src/qmldatainput.qdoc @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** 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 qmldatainput + \title Qt 3D Studio Runtime: QML DataInput Example + \ingroup qt3dstudioruntime2-examples-qml + \brief Demonstrates using DataInput elements in QML + + \image qmldatainput.png + + \e {This example demonstrates using DataInput elements with QML in Studio} + + \include examples-run.qdocinc + + \section1 Description + + The presentation consists of a static text element serving as a label and a rotating text + element for showing the input data as text. There is also a data input of type \e{Ranged Number} + in the presentation. This data input is used to control both the rotation animation time and + the text shown on the second text element. + The range is specified as [0 .. 360] in the presentation, where zero maps + to the beginning of the animation and 360 maps to the end of the animation. + + The \l {qmldatainput/qml/qmldatainput/main.qml}{qml main} loads the presentation and animates + a number property. The value of the animated property is bound to the + \l{DataInput::value}{value} property of the DataInput element, making the value show up in the + linked text element in the presentation. The same value is used to control the animation time: + + \snippet qmldatainput/qml/qmldatainput/main.qml 1 +*/ diff --git a/examples/3dstudioruntime2/qmldatainput/presentation/Paper05.png b/examples/3dstudioruntime2/qmldatainput/presentation/Paper05.png Binary files differnew file mode 100644 index 0000000..e70749d --- /dev/null +++ b/examples/3dstudioruntime2/qmldatainput/presentation/Paper05.png diff --git a/examples/3dstudioruntime2/qmldatainput/presentation/datainput.uip b/examples/3dstudioruntime2/qmldatainput/presentation/datainput.uip index 6b47e44..901e994 100644 --- a/examples/3dstudioruntime2/qmldatainput/presentation/datainput.uip +++ b/examples/3dstudioruntime2/qmldatainput/presentation/datainput.uip @@ -24,16 +24,21 @@ </Model> <Text id="Text3" /> <Text id="Text4" /> + <Model id="Rectangle" > + <Material id="Default_001" name="Default" > + <Image id="Default_001_diffusemap" /> + </Material> + </Model> </Layer> </Scene> </Graph> <Logic > <State name="Master Slide" component="#Scene" > - <Add ref="#Layer" multisampleaa="None" progressiveaa="4x" temporalaa="True" /> - <Add ref="#Camera" controlledproperty="$cameraRotInput rotation" pivot="0 0 0" rotation="0 0 0" /> - <Add ref="#Light" castshadow="True" controlledproperty="$colorInput lightdiffuse" lightdiffuse="1 0 0" position="-350.984 -229.258 -30" /> + <Add ref="#Layer" multisampleaa="SSAA" progressiveaa="8x" /> + <Add ref="#Camera" controlledproperty="$cameraRotInput rotation" pivot="0 0 0" position="0 0 -800" rotation="0 0 0" /> + <Add ref="#Light" castshadow="True" controlledproperty="$colorInput lightdiffuse" lightdiffuse="1 0 0" lighttype="Point" position="-300.444 70.829 -30" shdwfactor="11.89" shdwfilter="6.94" shdwmapres="11" /> <State id="Scene-Slide1" name="Slide1" initialplaystate="Pause" > - <Add ref="#Text" name="Text" font="TitilliumWeb-Regular" position="216.513 76.6172 -113.498" scale="1 1 1" size="24" textstring="0" > + <Add ref="#Text" name="Text" controlledproperty="$stringInput textstring" font="TitilliumWeb-Regular" position="216.513 76.6172 -113.498" scale="1 1 1" size="24" textstring="0" > <AnimationTrack property="rotation.x" type="EaseInOut" >0 0 0 0 10 0 0 0</AnimationTrack> <AnimationTrack property="rotation.y" type="EaseInOut" >0 0 0 0 10 0 0 0</AnimationTrack> <AnimationTrack property="rotation.z" type="EaseInOut" >0 0 0 0 10 -360 0 0</AnimationTrack> @@ -42,13 +47,16 @@ <Add ref="#Cone" name="Cone" controlledproperty="$scaleInput scale" position="-417.135 -225.166 0" sourcepath="#Cone" /> <Add ref="#Default" /> <Add ref="#Cylinder" name="Cylinder" controlledproperty="$variantInput opacity" position="131.347 -180.422 0" sourcepath="#Cylinder" /> - <Add ref="#Default_002" /> + <Add ref="#Default_002" diffuse="0.666667 1 0.498039" /> <Add ref="#Text6" name="Text6" font="TitilliumWeb-Regular" position="135.678 -300.019 -8.28656" size="16" textstring="Opacity control (Variant type)" /> <Add ref="#Text8" name="Text8" font="TitilliumWeb-Regular" position="-428.683 -290.118 0" size="16" textstring="Scale control" /> - <Add ref="#Cube2" name="Cube2" controlledproperty="$vec3Input rotation" position="409.919 -177.535 0" sourcepath="#Cube" /> + <Add ref="#Cube2" name="Cube2" controlledproperty="$cameraRotInput rotation" position="409.919 -177.535 0" sourcepath="#Cube" /> <Add ref="#Default_003" controlledproperty="$vec3Input2 diffuse" /> <Add ref="#Text3" name="Text3" font="TitilliumWeb-Regular" position="434.456 -304.552 0" size="16" textstring="Rotation control Diffuse color control" /> - <Add ref="#Text4" name="Text4" font="TitilliumWeb-Regular" position="-381.051 290.118 0" size="18" textstring="Directional light color and Camera xy rotation controlled via Datainput" /> + <Add ref="#Text4" name="Text4" font="TitilliumWeb-Regular" position="-381.051 290.118 0" size="18" textstring="Directional light color control Camera xy rotation control" /> + <Add ref="#Rectangle" name="Rectangle" position="0 -400 20" rotation="90.5 0 0" scale="11.0468 7.99191 9.12813" sourcepath="#Rectangle" /> + <Add ref="#Default_001" diffuse="0.623529 0.623529 0.623529" diffusemap="#Default_001_diffusemap" /> + <Add ref="#Default_001_diffusemap" sourcepath="Paper05.png" /> </State> </State> </Logic> diff --git a/examples/3dstudioruntime2/qmldatainput/qml/qmldatainput/main.qml b/examples/3dstudioruntime2/qmldatainput/qml/qmldatainput/main.qml index ef7d0e7..c0757e2 100644 --- a/examples/3dstudioruntime2/qmldatainput/qml/qmldatainput/main.qml +++ b/examples/3dstudioruntime2/qmldatainput/qml/qmldatainput/main.qml @@ -83,14 +83,14 @@ Item { property: "inputScaleVec3" duration: 12000 from: Qt.vector3d(0.3, 0.5, 0.5) - to: Qt.vector3d(1.0, 1.0, 1.0) + to: Qt.vector3d(4.0, 4.0, 1.0) loops: Animation.Infinite running: true } Vector3dAnimation { target: studio3D property: "inputColorVec3" - duration: 2000 + duration: 6000 from: Qt.vector3d(0.1, 0.1, 0.3) to: Qt.vector3d(1.0, 0.5, 1.0) loops: Animation.Infinite diff --git a/examples/3dstudioruntime2/qmldatainput/qmldatainput.qrc b/examples/3dstudioruntime2/qmldatainput/qmldatainput.qrc index 6fb7388..97aaeaa 100644 --- a/examples/3dstudioruntime2/qmldatainput/qmldatainput.qrc +++ b/examples/3dstudioruntime2/qmldatainput/qmldatainput.qrc @@ -3,5 +3,6 @@ <file>qml/qmldatainput/main.qml</file> <file>presentation/datainput.uia</file> <file>presentation/datainput.uip</file> + <file>presentation/Paper05.png</file> </qresource> </RCC> diff --git a/examples/3dstudioruntime2/simpleoffscreen/doc/images/simpleoffscreen.png b/examples/3dstudioruntime2/simpleoffscreen/doc/images/simpleoffscreen.png Binary files differnew file mode 100644 index 0000000..f406b3a --- /dev/null +++ b/examples/3dstudioruntime2/simpleoffscreen/doc/images/simpleoffscreen.png diff --git a/examples/3dstudioruntime2/simpleoffscreen/doc/src/simpleoffscreen.qdoc b/examples/3dstudioruntime2/simpleoffscreen/doc/src/simpleoffscreen.qdoc new file mode 100644 index 0000000..ecc0da8 --- /dev/null +++ b/examples/3dstudioruntime2/simpleoffscreen/doc/src/simpleoffscreen.qdoc @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** 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 simpleoffscreen + \title Qt 3D Studio Runtime: Simple Offscreen Example + \ingroup qt3dstudioruntime2-examples-cpp + \brief Demonstrates using the Q3DSSurfaceViewer class render frames into image files + + \image simpleoffscreen.png + + \e {This example demonstrates offscreen usage of the Q3DSSurfaceViewer class} + + \include examples-run.qdocinc + + \section1 Description + + In this example there is no on-screen user interface. Instead, an + OpenGL framebuffer object is created. With the help of a + QOffscreenSurface the Qt 3D Studio presentation is rendered into + the OpenGL texture. The contents is then read back into a QImage + and saved into image files. +*/ diff --git a/examples/3dstudioruntime2/simpleqml/doc/images/simpleqml.png b/examples/3dstudioruntime2/simpleqml/doc/images/simpleqml.png Binary files differnew file mode 100644 index 0000000..a22b467 --- /dev/null +++ b/examples/3dstudioruntime2/simpleqml/doc/images/simpleqml.png diff --git a/examples/3dstudioruntime2/simpleqml/doc/src/simpleqml.qdoc b/examples/3dstudioruntime2/simpleqml/doc/src/simpleqml.qdoc new file mode 100644 index 0000000..dfd0f16 --- /dev/null +++ b/examples/3dstudioruntime2/simpleqml/doc/src/simpleqml.qdoc @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** 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 simpleqml + \title Qt 3D Studio Runtime: Simple QML Example + \ingroup qt3dstudioruntime2-examples-qml + \brief Demonstrates using the Studio3D element in a Qt Quick application + + \image simpleqml.png + + \e {This example demonstrates basic usage of the Studio3D 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, \l Presentation, \l DataInput, \l SceneElement, and \l + Element QML types. + + Besides displaying the presentation designed in the Qt 3D Studio + application, a few simple cases of interacting with the scene + (such as, changing 3D object properties via data input, changing + slides, controlling the timeline) are also demonstrated. +*/ diff --git a/examples/3dstudioruntime2/simpleqml/main.cpp b/examples/3dstudioruntime2/simpleqml/main.cpp index 897b59a..a0a3de3 100644 --- a/examples/3dstudioruntime2/simpleqml/main.cpp +++ b/examples/3dstudioruntime2/simpleqml/main.cpp @@ -56,6 +56,10 @@ int main(int argc, char *argv[]) { qputenv("QSG_INFO", "1"); QApplication 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; diff --git a/examples/3dstudioruntime2/simpleqml/main.qml b/examples/3dstudioruntime2/simpleqml/main.qml index 4d47a47..0490a5a 100644 --- a/examples/3dstudioruntime2/simpleqml/main.qml +++ b/examples/3dstudioruntime2/simpleqml/main.qml @@ -98,33 +98,6 @@ Rectangle { id: barrelRef elementPath: "Barrel" // or Scene.Layer.Barrel but as long as it's unique the name's good enough } - - // Let's try out a QML subpresentation defined in-line, i.e. no separate .qml file. - SubPresentationSettings { - qmlStreams: [ - QmlStream { - presentationId: "embeddedQmlScene" - Rectangle { - color: "white" - Rectangle { - color: "red" - width: parent.width * 0.8 - height: parent.height * 0.8 - anchors.centerIn: parent - Text { - anchors.centerIn: parent - text: "Hello from\nembedded Qt Quick" - color: "white" - } - NumberAnimation on rotation { - from: 0; to: 360; duration: 10000 - loops: Animation.Infinite - } - } - } - } - ] - } } ignoredEvents: mouseEvCb.checked ? Studio3D.EnableAllEvents : (Studio3D.IgnoreMouseEvents | Studio3D.IgnoreWheelEvents) onRunningChanged: console.log("running: " + s3d.running) @@ -214,11 +187,6 @@ Rectangle { focusPolicy: Qt.NoFocus } Button { - text: "Fire event" - onClicked: s3dpres.fireEvent("Scene.Layer.Camera", "customCameraEvent") // in actionevent.uip this will change the sphere's color - focusPolicy: Qt.NoFocus - } - Button { text: "Toggle camera" onClicked: { var v = s3dpres.getAttribute("Scene.Layer.Camera", "eyeball") diff --git a/examples/3dstudioruntime2/simpleqml/presentation/barrel.uia b/examples/3dstudioruntime2/simpleqml/presentation/barrel.uia index 71d8e26..d936e42 100644 --- a/examples/3dstudioruntime2/simpleqml/presentation/barrel.uia +++ b/examples/3dstudioruntime2/simpleqml/presentation/barrel.uia @@ -3,7 +3,6 @@ <assets initial="barrel"> <dataInput name="di_text" type="String"/> <presentation id="barrel" src="barrel.uip"/> - <presentation-qml id="embeddedQmlScene" args="dummy"/> </assets> <statemachine ref="#logic"> <visual-states> diff --git a/examples/3dstudioruntime2/simpleqml/presentation/barrel.uip b/examples/3dstudioruntime2/simpleqml/presentation/barrel.uip index 66b40c2..9299f39 100644 --- a/examples/3dstudioruntime2/simpleqml/presentation/barrel.uip +++ b/examples/3dstudioruntime2/simpleqml/presentation/barrel.uip @@ -6,7 +6,6 @@ </ProjectSettings> <Graph > <Scene id="Scene" > - <Layer id="splayer" /> <Layer id="Layer" > <Camera id="Camera" /> <Light id="Light" /> @@ -25,10 +24,10 @@ </Graph> <Logic > <State name="Master Slide" component="#Scene" > + <Add ref="#Layer" /> <Add ref="#Camera" /> <Add ref="#Light" /> <State id="Scene-Slide1" name="Slide1" playmode="Looping" > - <Add ref="#splayer" name="splayer" height="30" sourcepath="embeddedQmlScene" top="50" width="30" /> <Add ref="#Barrel" name="Barrel" position="0 -42 -483" rotation="90 0 0" scale="100 100 100" sourcepath=".\barrel\meshes\Barrel.mesh#1" > <AnimationTrack property="opacity" type="EaseInOut" /> <AnimationTrack property="rotation.x" type="EaseInOut" >0 90 100 100 5 64 100 100 10 90 100 100</AnimationTrack> diff --git a/examples/3dstudioruntime2/simplewidget/doc/images/simplewidget.png b/examples/3dstudioruntime2/simplewidget/doc/images/simplewidget.png Binary files differnew file mode 100644 index 0000000..a975c73 --- /dev/null +++ b/examples/3dstudioruntime2/simplewidget/doc/images/simplewidget.png diff --git a/examples/3dstudioruntime2/simplewidget/doc/src/simplewidget.qdoc b/examples/3dstudioruntime2/simplewidget/doc/src/simplewidget.qdoc new file mode 100644 index 0000000..ab02d59 --- /dev/null +++ b/examples/3dstudioruntime2/simplewidget/doc/src/simplewidget.qdoc @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** 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 simplewidget + \title Qt 3D Studio Runtime: Simple Widget Example + \ingroup qt3dstudioruntime2-examples-cpp + \brief Demonstrates using the Q3DSWidget widget in a Qt C++ application + + \image simplewidget.png + + \e {This example demonstrates basic usage of the Q3DSWidget class} + + \include examples-run.qdocinc + + \section1 Description + + This example consists of a simple widget UI that includes a + Q3DSWidget. This QOpenGLWidget subclass displays and controls Qt + 3D Studio presentations. Changing the value of a text node via + data input, basic error handling, and the means of reloading or + opening presentations, as well as toggling the in-scene profiling + pane are also demonstrated. +*/ diff --git a/examples/3dstudioruntime2/simplewidget/main.cpp b/examples/3dstudioruntime2/simplewidget/main.cpp index 50b3fac..6d02374 100644 --- a/examples/3dstudioruntime2/simplewidget/main.cpp +++ b/examples/3dstudioruntime2/simplewidget/main.cpp @@ -59,7 +59,6 @@ #include <q3dsruntimeglobal.h> #include <Q3DSWidget> #include <Q3DSPresentation> -#include <Q3DSDataInput> int main(int argc, char *argv[]) { @@ -81,17 +80,8 @@ int main(int argc, char *argv[]) QMessageBox::critical(&w, QLatin1String("Failed to load presentation"), msg, QLatin1String("Ok")); }); - // The presentation has a data input entry "di_text" for the textstring - // property of one of the Text nodes. Provide a custom value. Do this in a - // manner so that the value is set even when doing a Reload or changing the - // presentation object's source. - Q3DSDataInput dataInput(w3DS->presentation(), QLatin1String("di_text")); - QObject::connect(w3DS, &Q3DSWidget::presentationLoaded, w3DS, [&dataInput] { - dataInput.setValue(QLatin1String("Hello world")); - }); - w3DS->presentation()->setProfilingEnabled(true); - w3DS->presentation()->setSource(QUrl(QLatin1String("qrc:/barrel.uip"))); + w3DS->presentation()->setSource(QUrl(QLatin1String("qrc:/presentation/SampleProject.uia"))); layout->addWidget(w3DS); QPushButton *openBtn = new QPushButton(QLatin1String("Open")); diff --git a/examples/3dstudioruntime2/simplewidget/presentation/SampleProject.uia b/examples/3dstudioruntime2/simplewidget/presentation/SampleProject.uia new file mode 100644 index 0000000..d59165e --- /dev/null +++ b/examples/3dstudioruntime2/simplewidget/presentation/SampleProject.uia @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<application xmlns="http://qt.io/qt3dstudio/uia"> + <assets initial="SampleProject"> + <presentation id="SampleProject" src="SampleProject.uip"/> + </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/simplewidget/presentation/SampleProject.uip b/examples/3dstudioruntime2/simplewidget/presentation/SampleProject.uip new file mode 100644 index 0000000..4c1325e --- /dev/null +++ b/examples/3dstudioruntime2/simplewidget/presentation/SampleProject.uip @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<UIP version="3" > + <Project > + <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="800" maintainAspect="True" > + <CustomColors count="16" >#ff5500 #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors> + </ProjectSettings> + <Classes > + <CustomMaterial id="simple_glass" name="simple_glass" sourcepath="materials/simple_glass.material" /> + </Classes> + <Graph > + <Scene id="Scene" > + <Layer id="Layer2" > + <Camera id="Camera_001" /> + <Light id="Light_001" /> + <Model id="NeedleSpeed_001" name="NeedleSpeed" importid="NeedleSpeed" orientation="Right Handed" position="0 0 -0" rotation="0 -0 0" rotationorder="XYZr" scale="1 1 1" sourcepath="models/Speedometer/meshes/NeedleSpeed.mesh" > + <Material id="NeedleBlack_002" name="NeedleBlack" blendmode="Normal" diffuse="0 0 0" emissivepower="0" importid="NeedleBlack" opacity="100" specularamount="0" specularroughness="9.41177" /> + <Material id="NeedleWhite_002" /> + </Model> + </Layer> + <Layer id="Layer" > + <Camera id="Camera" /> + <Light id="Light" /> + <Group id="Speedometer" importid="__import__root__" > + <Group id="Group_Speedometer_Master" name="Group_Speedometer_Master" importid="Group_Speedometer_Master" orientation="Right Handed" position="0 0 -0" rotation="0 -0 0" rotationorder="XYZr" scale="1 1 1" > + <Model id="Speedometer_001" name="Speedometer" importid="Speedometer" orientation="Right Handed" position="0 0 -0" rotation="0 -0 0" rotationorder="XYZr" scale="1 1 1" sourcepath="models/Speedometer/meshes/Speedometer.mesh" > + <CustomMaterial id="BaseMetal" class="#simple_glass" /> + <ReferencedMaterial id="HighLight" /> + <Material id="NeedleWhite_001" name="NeedleWhite" blendmode="Normal" diffuse="0.8 0.8 0.8" emissivepower="0" importid="NeedleWhite_0005" opacity="100" specularamount="0" specularroughness="27.451" /> + <Material id="BlackMetalRing" name="BlackMetalRing" blendmode="Normal" diffuse="0.0578313 0.0578313 0.0578313" emissivepower="0" importid="BlackMetalRing" opacity="100" specularamount="0" specularroughness="99.8039" /> + <Material id="NeedleBlack_001" name="NeedleBlack" blendmode="Normal" diffuse="0 0 0" emissivepower="0" importid="NeedleBlack_0006" opacity="100" specularamount="0" specularroughness="9.41177" /> + <Material id="SpeedometerBg" name="SpeedometerBg" blendmode="Normal" diffuse="1 1 1" diffusemap="#SpeedometerBg_diffusemap" emissivepower="0" importid="SpeedometerBg" opacity="100" specularamount="0" specularroughness="9.41177" > + <Image id="SpeedometerBg_diffusemap" name="SpeedometerBg_diffusemap" importid="SpeedometerBg_diffusemap" sourcepath="models/Speedometer/maps/Speed.png" /> + </Material> + </Model> + </Group> + </Group> + </Layer> + </Scene> + </Graph> + <Logic > + <State name="Master Slide" component="#Scene" > + <Add ref="#Layer" multisampleaa="SSAA" probebright="500" /> + <Add ref="#Camera" fov="30" position="0 0 -400" /> + <Add ref="#Light" brightness="200" lightdiffuse="1 1 1" lightspecular="0 0.666667 1" lighttype="Point" pivot="100 0 0" position="0 0 -50" > + <AnimationTrack property="rotation.x" type="EaseInOut" >0 0 100 100 5 0 100 100</AnimationTrack> + <AnimationTrack property="rotation.y" type="EaseInOut" >0 0 100 100 5 0 100 100</AnimationTrack> + <AnimationTrack property="rotation.z" type="EaseInOut" >0 45 100 100 5 -225 100 100</AnimationTrack> + </Add> + <State id="Scene-Slide1" name="Slide1" playmode="PingPong" playthroughto="Next" > + <Set ref="#Layer" endtime="5000" /> + <Set ref="#Camera" endtime="5000" /> + <Set ref="#Light" endtime="5000" /> + <Add ref="#Layer2" name="Layer2" endtime="5000" multisampleaa="None" progressiveaa="8x" /> + <Add ref="#Camera_001" endtime="5000" fov="30" position="0 0 -600" /> + <Add ref="#Light_001" endtime="5000" /> + <Add ref="#NeedleSpeed_001" name="NeedleSpeed" endtime="5000" importfile="models/Speedometer/Speedometer.import" pivot="5 5 0" > + <AnimationTrack property="rotation.x" type="EaseInOut" >0 0 100 100 2.13 0 0 0 5 0 100 100</AnimationTrack> + <AnimationTrack property="rotation.y" type="EaseInOut" >0 0 100 100 2.13 0 0 0 5 0 100 100</AnimationTrack> + <AnimationTrack property="rotation.z" type="EaseInOut" >0 0 100 100 2.13 -105.249 0 0 5 -270 100 100</AnimationTrack> + </Add> + <Add ref="#NeedleBlack_002" diffuse="0 0.333333 1" importfile="models/Speedometer/Speedometer.import" /> + <Add ref="#NeedleWhite_002" name="NeedleWhite" diffuse="1 1 1" specularamount="0" /> + <Add ref="#Speedometer" name="Speedometer" endtime="5000" importfile="models/Speedometer/Speedometer.import" position="0 0 0" scale="0.7 0.7 0.7" sourcepath="models/Speedometer/Speedometer.import" /> + <Add ref="#Group_Speedometer_Master" endtime="5000" importfile="models/Speedometer/Speedometer.import" /> + <Add ref="#Speedometer_001" endtime="5000" importfile="models/Speedometer/Speedometer.import" /> + <Add ref="#BaseMetal" name="BaseMetal" glass_color="0 0.333333 1" /> + <Add ref="#HighLight" name="HighLight" endtime="5000" referencedmaterial="#BaseMetal" /> + <Add ref="#NeedleWhite_001" importfile="models/Speedometer/Speedometer.import" /> + <Add ref="#BlackMetalRing" diffuse="0 0.0862745 0.596078" importfile="models/Speedometer/Speedometer.import" specularamount="0" /> + <Add ref="#NeedleBlack_001" importfile="models/Speedometer/Speedometer.import" /> + <Add ref="#SpeedometerBg" diffuse="0.270588 0.501961 1" importfile="models/Speedometer/Speedometer.import" specularamount="0.1" specularroughness="1" speculartint="0.529412 0.772549 1" /> + <Add ref="#SpeedometerBg_diffusemap" importfile="models/Speedometer/Speedometer.import" /> + </State> + </State> + </Logic> + </Project> +</UIP> diff --git a/examples/3dstudioruntime2/simplewidget/presentation/maps/materials/shadow.png b/examples/3dstudioruntime2/simplewidget/presentation/maps/materials/shadow.png Binary files differnew file mode 100644 index 0000000..599b1cc --- /dev/null +++ b/examples/3dstudioruntime2/simplewidget/presentation/maps/materials/shadow.png diff --git a/examples/3dstudioruntime2/simplewidget/presentation/maps/materials/spherical_checker.png b/examples/3dstudioruntime2/simplewidget/presentation/maps/materials/spherical_checker.png Binary files differnew file mode 100644 index 0000000..e42394d --- /dev/null +++ b/examples/3dstudioruntime2/simplewidget/presentation/maps/materials/spherical_checker.png diff --git a/examples/3dstudioruntime2/simplewidget/presentation/materials/simple_glass.material b/examples/3dstudioruntime2/simplewidget/presentation/materials/simple_glass.material new file mode 100644 index 0000000..a6b4ee0 --- /dev/null +++ b/examples/3dstudioruntime2/simplewidget/presentation/materials/simple_glass.material @@ -0,0 +1,197 @@ +<Material name="simple_glass" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Enable Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Fresnel Power" name="uFresnelPower" description="Fresnel power of the material" type="Float" default="1.0" category="Material"/> + <Property formalName="Minimum Opacity" name="uMinOpacity" description="Minimum opacity of the material" type="Float" default="0.5" category="Material"/> + <Property formalName="Reflectivity" name="reflectivity_amount" type="Float" min="0.000000" max="1.000000" default="1.000000" description="Reflectivity factor" category="Material"/> + <Property formalName="Glass ior" name="glass_ior" hidden="True" type="Float" default="1.100000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Glass Color" name="glass_color" type="Color" default="0.9 0.9 0.9" description="Color of the material" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define scatter_reflect 0 +#define scatter_transmit 1 +#define scatter_reflect_transmit 2 + +#define QT3DS_ENABLE_UV0 1 +#define QT3DS_ENABLE_WORLD_POSITION 1 +#define QT3DS_ENABLE_TEXTAN 1 +#define QT3DS_ENABLE_BINORMAL 0 + +#include "vertexFragmentBase.glsllib" + +// set shader output +out vec4 fragColor; + +// add structure defines +struct layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +// temporary declarations +vec3 ftmp0; + vec4 tmpShadowTerm; + +layer_result layers[1]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "luminance.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "abbeNumberIOR.glsllib" +#include "fresnelLayer.glsllib" +#include "refraction.glsllib" + +bool evalTwoSided() +{ + return( true ); +} + +vec3 computeFrontMaterialEmissive() +{ + return( vec3( 0, 0, 0 ) ); +} + +void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir, in vec3 lightDiffuse, in vec3 lightSpecular, in float materialIOR, float aoFactor ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, 0.000000, 0.000000, scatter_reflect_transmit ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, 0.000000, 0.000000 ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].base += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, 0.000000, 0.000000, scatter_reflect_transmit ); + +#else + layers[0].base += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, 0.000000, 0.000000 ); + +#endif +} + +vec3 computeBackMaterialEmissive() +{ + return( vec3(0, 0, 0) ); +} + +void computeBackLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir, in vec3 lightDiffuse, in vec3 lightSpecular, in float materialIOR, float aoFactor ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += vec4( 0.0, 0.0, 0.0, 1.0 ); +#endif +} + +void computeBackAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += vec4( 0.0, 0.0, 0.0, 1.0 ); +#endif +} + +void computeBackLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].base += vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += vec4( 0.0, 0.0, 0.0, 1.0 ); +#else + layers[0].base += vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += vec4( 0.0, 0.0, 0.0, 1.0 ); +#endif +} + +float computeIOR() +{ + return( true ? 1.0 : luminance( vec3( abbeNumberIOR(glass_ior, 0.000000 ) ) ) ); +} + +float evalCutout() +{ + return( 1.000000 ); +} + +vec3 computeNormal() +{ + return( normal ); +} + +void computeTemporaries() +{ + ftmp0 = vec3( reflectivity_amount ); + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = layers[0].base * vec4( ftmp0, 1.0); + return color; +} + + +void initializeLayerVariables(void) +{ + // clear layers + layers[0].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[0].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[0].tanFrame = orthoNormalize( tangentFrame( normal, varWorldPos ) ); +} + +vec4 computeGlass(in vec3 normal, in float materialIOR, in float alpha, in vec4 color) +{ + vec4 rgba = color; + float ratio = simpleFresnel( normal, materialIOR, uFresnelPower ); + vec3 absorb_color = ( log( glass_color )/-1.000000 ); + // prevent log(0) -> inf number issue + if ( isinf(absorb_color.r) ) absorb_color.r = 1.0; + if ( isinf(absorb_color.g) ) absorb_color.g = 1.0; + if ( isinf(absorb_color.b) ) absorb_color.b = 1.0; + rgba.rgb = mix(vec3(1.0) - absorb_color, rgba.rgb * (vec3(1.0) - absorb_color), ratio); + rgba.a = mix(uMinOpacity, alpha, ratio); + return rgba; +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="36"/> + <LayerKey count="1"/> + <Pass > + <Blending source="SrcAlpha" dest="OneMinusSrcAlpha"/> + <RenderState name="CullFace"/> + </Pass> +</Passes> +</Material> diff --git a/examples/3dstudioruntime2/simplewidget/presentation/models/Speedometer/Speedometer.import b/examples/3dstudioruntime2/simplewidget/presentation/models/Speedometer/Speedometer.import new file mode 100644 index 0000000..d74ef62 --- /dev/null +++ b/examples/3dstudioruntime2/simplewidget/presentation/models/Speedometer/Speedometer.import @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<UIP Version="1" > + <Project Revision="1" > + <Graph > + <Group id="__import__root__" > + <Group id="Group_Speedometer_Master" name="Group_Speedometer_Master" orientation="Right Handed" position="0 0 -0" rotation="0 -0 0" rotationorder="XYZr" scale="1 1 1" > + <Model id="NeedleSpeed" name="NeedleSpeed" orientation="Right Handed" position="0 0 -0" rotation="0 -0 0" rotationorder="XYZr" scale="1 1 1" sourcepath="meshes/NeedleSpeed.mesh" > + <Material id="NeedleBlack" name="NeedleBlack" blendmode="Normal" diffuse="0 0 0" emissivepower="0" opacity="100" specularamount="0" specularroughness="9.41177" /> + <Material id="NeedleWhite" name="NeedleWhite" blendmode="Normal" diffuse="0.8 0.8 0.8" emissivepower="0" opacity="100" specularamount="0" specularroughness="27.451" /> + </Model> + <Model id="Speedometer" name="Speedometer" orientation="Right Handed" position="0 0 -0" rotation="0 -0 0" rotationorder="XYZr" scale="1 1 1" sourcepath="meshes/Speedometer.mesh" > + <Material id="BaseMetal" name="BaseMetal" blendmode="Normal" diffuse="0.01728 0.01728 0.01728" emissivepower="0" opacity="100" specularamount="0" specularroughness="11.3725" /> + <Material id="HighLight" name="HighLight" blendmode="Normal" diffuse="0.298 0.54088 0.8" emissivepower="0" opacity="66.8675" specularamount="0" specularroughness="100" /> + <Material id="NeedleWhite_0005" name="NeedleWhite" blendmode="Normal" diffuse="0.8 0.8 0.8" emissivepower="0" opacity="100" specularamount="0" specularroughness="27.451" /> + <Material id="BlackMetalRing" name="BlackMetalRing" blendmode="Normal" diffuse="0.0578313 0.0578313 0.0578313" emissivepower="0" opacity="100" specularamount="0" specularroughness="99.8039" /> + <Material id="NeedleBlack_0006" name="NeedleBlack" blendmode="Normal" diffuse="0 0 0" emissivepower="0" opacity="100" specularamount="0" specularroughness="9.41177" /> + <Material id="SpeedometerBg" name="SpeedometerBg" blendmode="Normal" diffuse="1 1 1" diffusemap="SpeedometerBg_diffusemap" emissivepower="0" opacity="100" specularamount="0" specularroughness="9.41177" > + <Image id="SpeedometerBg_diffusemap" name="SpeedometerBg_diffusemap" sourcepath="maps/Speed.png" /> + </Material> + </Model> + </Group> + </Group> + </Graph> + <Import SrcFile="" ImageDir="Images" MeshDir="Meshes" > + <Image > + <Source >Speed.png</Source> + <Dest >maps/Speed.png</Dest> + </Image> + <Mesh > + <Source >Speedometer</Source> + <Dest >meshes/Speedometer.mesh</Dest> + </Mesh> + <Mesh > + <Source >NeedleSpeed</Source> + <Dest >meshes/NeedleSpeed.mesh</Dest> + </Mesh> + </Import> + </Project> +</UIP> diff --git a/examples/3dstudioruntime2/simplewidget/presentation/models/Speedometer/maps/Speed.png b/examples/3dstudioruntime2/simplewidget/presentation/models/Speedometer/maps/Speed.png Binary files differnew file mode 100644 index 0000000..84b7e4d --- /dev/null +++ b/examples/3dstudioruntime2/simplewidget/presentation/models/Speedometer/maps/Speed.png diff --git a/examples/3dstudioruntime2/simplewidget/presentation/models/Speedometer/meshes/NeedleSpeed.mesh b/examples/3dstudioruntime2/simplewidget/presentation/models/Speedometer/meshes/NeedleSpeed.mesh Binary files differnew file mode 100644 index 0000000..72220cd --- /dev/null +++ b/examples/3dstudioruntime2/simplewidget/presentation/models/Speedometer/meshes/NeedleSpeed.mesh diff --git a/examples/3dstudioruntime2/simplewidget/presentation/models/Speedometer/meshes/Speedometer.mesh b/examples/3dstudioruntime2/simplewidget/presentation/models/Speedometer/meshes/Speedometer.mesh Binary files differnew file mode 100644 index 0000000..9f7ba34 --- /dev/null +++ b/examples/3dstudioruntime2/simplewidget/presentation/models/Speedometer/meshes/Speedometer.mesh diff --git a/examples/3dstudioruntime2/simplewidget/simplewidget.qrc b/examples/3dstudioruntime2/simplewidget/simplewidget.qrc index e9b7006..3f6f2fa 100644 --- a/examples/3dstudioruntime2/simplewidget/simplewidget.qrc +++ b/examples/3dstudioruntime2/simplewidget/simplewidget.qrc @@ -1,12 +1,12 @@ <RCC> <qresource prefix="/"> - <file alias="barrel.uia">../simpleqml/presentation/barrel.uia</file> - <file alias="barrel.uip">../simpleqml/presentation/barrel.uip</file> - <file alias="barrel/meshes/Barrel.mesh">../simpleqml/presentation/barrel/meshes/Barrel.mesh</file> - <file alias="fonts/Arimo-Regular.ttf">../simpleqml/presentation/fonts/Arimo-Regular.ttf</file> - <file alias="maps/barrel_barrel_Diffuse.png">../simpleqml/presentation/maps/barrel_barrel_Diffuse.png</file> - <file alias="maps/barrel_barrel_Emissive.png">../simpleqml/presentation/maps/barrel_barrel_Emissive.png</file> - <file alias="maps/barrel_barrel_Normal.png">../simpleqml/presentation/maps/barrel_barrel_Normal.png</file> - <file alias="maps/barrel_barrel_Specular.png">../simpleqml/presentation/maps/barrel_barrel_Specular.png</file> + <file>presentation/SampleProject.uia</file> + <file>presentation/SampleProject.uip</file> + <file>presentation/maps/materials/spherical_checker.png</file> + <file>presentation/maps/materials/shadow.png</file> + <file>presentation/materials/simple_glass.material</file> + <file>presentation/models/Speedometer/maps/Speed.png</file> + <file>presentation/models/Speedometer/meshes/Speedometer.mesh</file> + <file>presentation/models/Speedometer/meshes/NeedleSpeed.mesh</file> </qresource> </RCC> diff --git a/examples/3dstudioruntime2/simplewindow/doc/images/simplewindow.png b/examples/3dstudioruntime2/simplewindow/doc/images/simplewindow.png Binary files differnew file mode 100644 index 0000000..37550c7 --- /dev/null +++ b/examples/3dstudioruntime2/simplewindow/doc/images/simplewindow.png diff --git a/examples/3dstudioruntime2/simplewindow/doc/src/simplewindow.qdoc b/examples/3dstudioruntime2/simplewindow/doc/src/simplewindow.qdoc new file mode 100644 index 0000000..b00bc3e --- /dev/null +++ b/examples/3dstudioruntime2/simplewindow/doc/src/simplewindow.qdoc @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** 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 simplewindow + \title Qt 3D Studio Runtime: Simple Window Example + \ingroup qt3dstudioruntime2-examples-cpp + \brief Demonstrates using the Q3DSSurfaceViewer class in order to render in a QWindow + + \image simplewindow.png + + \e {This example demonstrates basic usage of the Q3DSSurfaceViewer class} + + \include examples-run.qdocinc + + \section1 Description + + This example consists of an OpenGL-based QWindow. The contents is + provided by a Q3DSSurfaceViewer instance by loading up a simple Qt + 3D Studio presentation. + + When targeting a QWindow, the application can choose whether it + wants to be in control of updates (i.e. manually requesting the + next frame by calling Q3DSSurfaceViewer::update()). By passing + the \c{--multi} command-line argument the example demonstrates + both types of usages. +*/ diff --git a/examples/3dstudioruntime2/simplewindow/main.cpp b/examples/3dstudioruntime2/simplewindow/main.cpp index 15796b4..3fea28b 100644 --- a/examples/3dstudioruntime2/simplewindow/main.cpp +++ b/examples/3dstudioruntime2/simplewindow/main.cpp @@ -80,13 +80,13 @@ int main(int argc, char *argv[]) }); // The presentation has a data input entry "di_text" for the textstring - // property of one of the Text nodes. Provide a custom value. + // property of one of the Text nodes. Provide a custom value. Do this in a + // manner so that the value is set even when doing a Reload or changing the + // presentation object's source. Q3DSDataInput dataInput(viewer.presentation(), QLatin1String("di_text")); - // Assuming the source is never changed or reloaded, a plain setValue() - // call is good enough. Otherwise, we would need to connect to the - // presentationLoaded() signal and set the value whenever a new - // presentation is loaded. - dataInput.setValue(QLatin1String("Hello world")); + QObject::connect(&viewer, &Q3DSSurfaceViewer::presentationLoaded, &viewer, [&dataInput] { + dataInput.setValue(QLatin1String("Hello world")); + }); viewer.presentation()->setSource(QUrl(QLatin1String("qrc:/barrel.uip"))); viewer.create(&w, w.context()); |