diff options
Diffstat (limited to 'examples')
9 files changed, 62 insertions, 2 deletions
diff --git a/examples/3dstudioruntime2/simpleoffscreen/simpleoffscreen.qrc b/examples/3dstudioruntime2/simpleoffscreen/simpleoffscreen.qrc index 4558e47..e9b7006 100644 --- a/examples/3dstudioruntime2/simpleoffscreen/simpleoffscreen.qrc +++ b/examples/3dstudioruntime2/simpleoffscreen/simpleoffscreen.qrc @@ -1,5 +1,6 @@ <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> diff --git a/examples/3dstudioruntime2/simpleqml/main.qml b/examples/3dstudioruntime2/simpleqml/main.qml index f3b6466..8dc46ff 100644 --- a/examples/3dstudioruntime2/simpleqml/main.qml +++ b/examples/3dstudioruntime2/simpleqml/main.qml @@ -68,6 +68,8 @@ Rectangle { focus: true anchors.margins: 60 anchors.fill: parent + property string textValue: "hello world" + Presentation { id: s3dpres source: "qrc:/presentation/barrel.uip" @@ -76,6 +78,11 @@ Rectangle { onCustomSignalEmitted: customSignalName.text = Date.now() + ": " + name onSlideEntered: slideEnter.text = "Entered slide " + name + "(index " + index + ") on " + elementPath onSlideExited: slideExit.text = "Exited slide " + name + "(index " + index + ") on " + elementPath + + DataInput { + name: "di_text" + value: s3d.textValue + } } ignoredEvents: mouseEvCb.checked ? Studio3D.EnableAllEvents : (Studio3D.IgnoreMouseEvents | Studio3D.IgnoreWheelEvents) onRunningChanged: console.log("running: " + s3d.running) @@ -170,6 +177,12 @@ Rectangle { } focusPolicy: Qt.NoFocus } + Button { + text: "Send new data input value" + property int invocationCount: 0 + onClicked: s3d.textValue = "Data input value " + (++invocationCount) + focusPolicy: Qt.NoFocus + } } Text { diff --git a/examples/3dstudioruntime2/simpleqml/presentation/barrel.uia b/examples/3dstudioruntime2/simpleqml/presentation/barrel.uia new file mode 100644 index 0000000..22494b1 --- /dev/null +++ b/examples/3dstudioruntime2/simpleqml/presentation/barrel.uia @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<application xmlns="http://qt.io/qt3dstudio/uia"> + <assets initial="barrel"> + <presentation id="barrel" src="barrel.uip"/> + <dataInput name="di_text" type="String"/> + </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/simpleqml/presentation/barrel.uip b/examples/3dstudioruntime2/simpleqml/presentation/barrel.uip index 50981d3..4c58ed4 100644 --- a/examples/3dstudioruntime2/simpleqml/presentation/barrel.uip +++ b/examples/3dstudioruntime2/simpleqml/presentation/barrel.uip @@ -1,7 +1,9 @@ <?xml version="1.0" encoding="UTF-8" ?> <UIP version="3" > <Project > - <ProjectSettings author="" company="" presentationWidth="800" presentationHeight="480" maintainAspect="False" /> + <ProjectSettings author="" company="" presentationWidth="800" 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" > <Layer id="Layer" > @@ -16,6 +18,7 @@ </Material> </Model> <Text id="Text" /> + <Text id="Text2" /> </Layer> </Scene> </Graph> @@ -31,7 +34,7 @@ <AnimationTrack property="rotation.y" type="EaseInOut" >0 0 100 100 5 -302 100 100 10 0 100 100</AnimationTrack> <AnimationTrack property="rotation.z" type="EaseInOut" >0 0 100 100 5 0 100 100 10 0 100 100</AnimationTrack> </Add> - <Add ref="#Material" bumpamount="0" diffusemap="#Material_diffusemap" emissivemap="#Material_emissivemap" fresnelPower="25" normalmap="#Material_normalmap" specularamount="4" specularmap="#Material_specularmap" specularmodel="Default" specularroughness="0.001" > + <Add ref="#Material" bumpamount="0" diffuse="1 1 1" diffusemap="#Material_diffusemap" emissivemap="#Material_emissivemap" fresnelPower="25" normalmap="#Material_normalmap" specularamount="4" specularmap="#Material_specularmap" specularmodel="Default" specularroughness="0.001" > <AnimationTrack property="bumpamount" type="EaseInOut" >0 0 100 100 5 1 100 100</AnimationTrack> </Add> <Add ref="#Material_diffusemap" sourcepath=".\maps\barrel_barrel_Diffuse.png" /> @@ -47,6 +50,7 @@ <AnimationTrack property="textcolor.y" type="EaseInOut" >0 1 100 100 5.009 0.235294 100 100 10 1 100 100</AnimationTrack> <AnimationTrack property="textcolor.z" type="EaseInOut" >0 0 100 100 5.009 0.333333 100 100 10 0 100 100</AnimationTrack> </Add> + <Add ref="#Text2" name="Text2" controlledproperty="di_text textstring" font="Arimo-Regular" position="435.899 267.025 0" /> </State> </State> </Logic> diff --git a/examples/3dstudioruntime2/simpleqml/simpleqml.qrc b/examples/3dstudioruntime2/simpleqml/simpleqml.qrc index 88c9a32..bc843a9 100644 --- a/examples/3dstudioruntime2/simpleqml/simpleqml.qrc +++ b/examples/3dstudioruntime2/simpleqml/simpleqml.qrc @@ -2,6 +2,7 @@ <qresource prefix="/"> <file>main.qml</file> <file>presentation/barrel.uip</file> + <file>presentation/barrel.uia</file> <file>presentation/barrel_no_background.uip</file> <file>presentation/barrel/meshes/Barrel.mesh</file> <file>presentation/fonts/Arimo-Regular.ttf</file> diff --git a/examples/3dstudioruntime2/simplewidget/main.cpp b/examples/3dstudioruntime2/simplewidget/main.cpp index 34ed8ab..50b3fac 100644 --- a/examples/3dstudioruntime2/simplewidget/main.cpp +++ b/examples/3dstudioruntime2/simplewidget/main.cpp @@ -59,6 +59,7 @@ #include <q3dsruntimeglobal.h> #include <Q3DSWidget> #include <Q3DSPresentation> +#include <Q3DSDataInput> int main(int argc, char *argv[]) { @@ -79,6 +80,16 @@ int main(int argc, char *argv[]) if (!msg.isEmpty()) 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"))); layout->addWidget(w3DS); diff --git a/examples/3dstudioruntime2/simplewidget/simplewidget.qrc b/examples/3dstudioruntime2/simplewidget/simplewidget.qrc index 4558e47..e9b7006 100644 --- a/examples/3dstudioruntime2/simplewidget/simplewidget.qrc +++ b/examples/3dstudioruntime2/simplewidget/simplewidget.qrc @@ -1,5 +1,6 @@ <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> diff --git a/examples/3dstudioruntime2/simplewindow/main.cpp b/examples/3dstudioruntime2/simplewindow/main.cpp index c335b96..15796b4 100644 --- a/examples/3dstudioruntime2/simplewindow/main.cpp +++ b/examples/3dstudioruntime2/simplewindow/main.cpp @@ -55,6 +55,7 @@ #include <q3dsruntimeglobal.h> #include <Q3DSSurfaceViewer> #include <Q3DSPresentation> +#include <Q3DSDataInput> #include "window_manualupdate.h" #include "window_autoupdate.h" @@ -77,6 +78,16 @@ int main(int argc, char *argv[]) if (!msg.isEmpty()) qWarning() << msg; }); + + // The presentation has a data input entry "di_text" for the textstring + // property of one of the Text nodes. Provide a custom value. + 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")); + viewer.presentation()->setSource(QUrl(QLatin1String("qrc:/barrel.uip"))); viewer.create(&w, w.context()); w.setViewer(&viewer); diff --git a/examples/3dstudioruntime2/simplewindow/simplewindow.qrc b/examples/3dstudioruntime2/simplewindow/simplewindow.qrc index 4558e47..e9b7006 100644 --- a/examples/3dstudioruntime2/simplewindow/simplewindow.qrc +++ b/examples/3dstudioruntime2/simplewindow/simplewindow.qrc @@ -1,5 +1,6 @@ <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> |