summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-07-13 17:03:08 +0200
committerPaul Lemire <paul.lemire@kdab.com>2015-07-23 20:38:25 +0000
commit7b19af1c304d503b5c83905e7f5282a0fe39177a (patch)
tree057d43e962463de54085b1fc9a549e8caad5fb91 /examples
parentd6771fde23c611382443217ae6bfe5b219b7160f (diff)
Add scene3d-loader example
Change-Id: I3f7cfc5459dbb07e395a15920cd80786689cb2e1 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/qt3d/qt3d.pro3
-rw-r--r--examples/qt3d/scene3d-loader/AnimatedEntity.qml138
-rw-r--r--examples/qt3d/scene3d-loader/Scene.qml44
-rw-r--r--examples/qt3d/scene3d-loader/Scene2.qml104
-rw-r--r--examples/qt3d/scene3d-loader/main.cpp52
-rw-r--r--examples/qt3d/scene3d-loader/main.qml68
-rw-r--r--examples/qt3d/scene3d-loader/scene3d-loader.pro17
-rw-r--r--examples/qt3d/scene3d-loader/scene3d-loader.qrc8
8 files changed, 433 insertions, 1 deletions
diff --git a/examples/qt3d/qt3d.pro b/examples/qt3d/qt3d.pro
index da6238b27..57051d9a0 100644
--- a/examples/qt3d/qt3d.pro
+++ b/examples/qt3d/qt3d.pro
@@ -34,7 +34,8 @@ SUBDIRS += \
plasma \
gooch-qml \
transparency-qml \
- transparency-qml-scene3d
+ transparency-qml-scene3d \
+ scene3d-loader
# TODO Port the old examples to new APIs
#SUBDIRS += qt3d
diff --git a/examples/qt3d/scene3d-loader/AnimatedEntity.qml b/examples/qt3d/scene3d-loader/AnimatedEntity.qml
new file mode 100644
index 000000000..cf209e39d
--- /dev/null
+++ b/examples/qt3d/scene3d-loader/AnimatedEntity.qml
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D 2.0
+import Qt3D.Renderer 2.0
+import QtQuick 2.0 as QQ2
+
+
+Entity {
+ id: sceneRoot
+
+ Camera {
+ id: camera
+ projectionType: CameraLens.PerspectiveProjection
+ fieldOfView: 45
+ aspectRatio: 16/9
+ nearPlane : 0.1
+ farPlane : 1000.0
+ position: Qt.vector3d( 0.0, 0.0, -40.0 )
+ upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
+ viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
+ }
+
+ Configuration {
+ controlledCamera: camera
+ }
+
+ components: [
+ FrameGraph {
+ activeFrameGraph: Viewport {
+ id: viewport
+ rect: Qt.rect(0.0, 0.0, 1.0, 1.0) // From Top Left
+ clearColor: Qt.rgba(0, 0.5, 1, 1)
+
+ CameraSelector {
+ id : cameraSelector
+ camera: camera
+
+ ClearBuffer {
+ buffers : ClearBuffer.ColorDepthBuffer
+ }
+ }
+ }
+ }
+ ]
+
+ PhongMaterial {
+ id: material
+ }
+
+ TorusMesh {
+ id: torusMesh
+ radius: 5
+ minorRadius: 1
+ rings: 100
+ slices: 20
+ }
+
+ Transform {
+ id: torusTransform
+ Scale { scale3D: Qt.vector3d(1.5, 1, 0.5) }
+ Rotate {
+ angle: 45
+ axis: Qt.vector3d(1, 0, 0)
+ }
+ }
+
+ Entity {
+ id: torusEntity
+ components: [ torusMesh, material, torusTransform ]
+ }
+
+ SphereMesh {
+ id: sphereMesh
+ radius: 3
+ }
+
+ Transform {
+ id: sphereTransform
+ Translate {
+ translation: Qt.vector3d(20, 0, 0)
+ }
+
+ Rotate {
+ id: sphereRotation
+ axis: Qt.vector3d(0, 1, 0)
+ }
+ }
+
+ QQ2.NumberAnimation {
+ target: sphereRotation
+ property: "angle"
+ duration: 10000
+ from: 0
+ to: 360
+
+ loops: QQ2.Animation.Infinite
+ running: true
+ }
+
+ Entity {
+ id: sphereEntity
+ components: [ sphereMesh, material, sphereTransform ]
+ }
+}
diff --git a/examples/qt3d/scene3d-loader/Scene.qml b/examples/qt3d/scene3d-loader/Scene.qml
new file mode 100644
index 000000000..5428c6c12
--- /dev/null
+++ b/examples/qt3d/scene3d-loader/Scene.qml
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Scene3D 2.0
+
+Scene3D {
+ focus: true
+ aspects: "input"
+ AnimatedEntity {}
+}
diff --git a/examples/qt3d/scene3d-loader/Scene2.qml b/examples/qt3d/scene3d-loader/Scene2.qml
new file mode 100644
index 000000000..e8e452cce
--- /dev/null
+++ b/examples/qt3d/scene3d-loader/Scene2.qml
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Scene3D 2.0
+import Qt3D 2.0
+import Qt3D.Renderer 2.0
+
+Scene3D {
+ focus: true
+ aspects: "input"
+
+ Entity {
+ id: sceneRoot
+
+ Camera {
+ id: camera
+ projectionType: CameraLens.PerspectiveProjection
+ fieldOfView: 45
+ aspectRatio: 16/9
+ nearPlane : 0.1
+ farPlane : 1000.0
+ position: Qt.vector3d( 0.0, 0.0, -20.0 )
+ upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
+ viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
+ }
+
+ Configuration {
+ controlledCamera: camera
+ }
+
+ FrameGraph {
+ id : external_forward_renderer
+ activeFrameGraph : ForwardRenderer {
+ camera: camera
+ clearColor: "black"
+ }
+ }
+
+ components: [external_forward_renderer]
+
+ TorusMesh {
+ id: mesh
+ radius: 5
+ minorRadius: 1
+ rings: 100
+ slices: 20
+ }
+
+ Transform {
+ id: transform
+ Scale { scale3D: Qt.vector3d(1.5, 1, 0.5) }
+ Rotate {
+ angle: 45
+ axis: Qt.vector3d(1, 0, 0)
+ }
+ }
+
+ Material {
+ id: material
+ effect : Effect {
+ }
+ }
+
+ Entity {
+ id: mainEntity
+ objectName: "mainEntity"
+ components: [ mesh, material, transform ]
+ }
+ }
+}
diff --git a/examples/qt3d/scene3d-loader/main.cpp b/examples/qt3d/scene3d-loader/main.cpp
new file mode 100644
index 000000000..0ed21fd88
--- /dev/null
+++ b/examples/qt3d/scene3d-loader/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQuickView>
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ QQuickView view;
+
+ view.resize(500, 500);
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl("qrc:/main.qml"));
+ view.show();
+
+ return app.exec();
+}
diff --git a/examples/qt3d/scene3d-loader/main.qml b/examples/qt3d/scene3d-loader/main.qml
new file mode 100644
index 000000000..d6d2750af
--- /dev/null
+++ b/examples/qt3d/scene3d-loader/main.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Scene3D 2.0
+import QtQuick.Controls 1.2
+
+Item {
+
+ Loader {
+ id: loader
+ anchors.fill: parent
+ focus: true
+ source: "Scene.qml"
+ }
+
+ Row {
+ id: buttonRow
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ bottom: parent.bottom
+ bottomMargin: parent.height * 0.1
+ }
+ spacing: 10
+ Button {
+ text: "Scene 1";
+ isDefault: true
+ onClicked: loader.source = "Scene.qml"
+ }
+ Button {
+ text: "Scene 2";
+ onClicked: loader.source = "Scene2.qml"
+ }
+ }
+}
diff --git a/examples/qt3d/scene3d-loader/scene3d-loader.pro b/examples/qt3d/scene3d-loader/scene3d-loader.pro
new file mode 100644
index 000000000..d2c5f786d
--- /dev/null
+++ b/examples/qt3d/scene3d-loader/scene3d-loader.pro
@@ -0,0 +1,17 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+QT += qml quick 3dcore 3drenderer 3dinput
+
+SOURCES += \
+ main.cpp
+
+OTHER_FILES += \
+ AnimatedEntity.qml \
+ main.qml \
+ Scene.qml \
+ Scene2.qml
+
+RESOURCES += \
+ scene3d-loader.qrc
diff --git a/examples/qt3d/scene3d-loader/scene3d-loader.qrc b/examples/qt3d/scene3d-loader/scene3d-loader.qrc
new file mode 100644
index 000000000..fdb5e39aa
--- /dev/null
+++ b/examples/qt3d/scene3d-loader/scene3d-loader.qrc
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/">
+ <file>AnimatedEntity.qml</file>
+ <file>main.qml</file>
+ <file>Scene.qml</file>
+ <file>Scene2.qml</file>
+ </qresource>
+</RCC>