summaryrefslogtreecommitdiffstats
path: root/examples/qt3d/gooch-qml
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2015-03-13 13:52:49 +0000
committerSean Harmer <sean.harmer@kdab.com>2015-07-04 11:22:43 +0000
commitb0148f11dc87e455e8e0e711eb9950824fae9da9 (patch)
tree4e7e9d5ba07f9f796714960d8bdde9e7ca40d9dd /examples/qt3d/gooch-qml
parent454356fb663329bc075398196548472aa0c93b78 (diff)
Add gooch material and example
Edge inking will come later. So many techniques to choose from. Change-Id: Ibbea66c09c158bebba5d8efaf08d18417fa9b161 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'examples/qt3d/gooch-qml')
-rw-r--r--examples/qt3d/gooch-qml/MyEntity.qml57
-rw-r--r--examples/qt3d/gooch-qml/gooch-qml.pro16
-rw-r--r--examples/qt3d/gooch-qml/gooch-qml.qrc6
-rw-r--r--examples/qt3d/gooch-qml/main.cpp64
-rw-r--r--examples/qt3d/gooch-qml/main.qml72
5 files changed, 215 insertions, 0 deletions
diff --git a/examples/qt3d/gooch-qml/MyEntity.qml b/examples/qt3d/gooch-qml/MyEntity.qml
new file mode 100644
index 000000000..0bd449f1a
--- /dev/null
+++ b/examples/qt3d/gooch-qml/MyEntity.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** 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
+
+Entity {
+ id: root
+ property alias x: translation.dx
+ property alias y: translation.dy
+ property alias z: translation.dz
+ property alias scale: scaleTransform.scale
+ property alias material: gooch
+ property alias source: mesh.source
+
+ components: [
+ Transform {
+ Translate { id: translation }
+ Scale{ id: scaleTransform }
+ },
+ Mesh { id: mesh },
+ GoochMaterial { id: gooch }
+ ]
+}
diff --git a/examples/qt3d/gooch-qml/gooch-qml.pro b/examples/qt3d/gooch-qml/gooch-qml.pro
new file mode 100644
index 000000000..73c947c72
--- /dev/null
+++ b/examples/qt3d/gooch-qml/gooch-qml.pro
@@ -0,0 +1,16 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+QT += 3dcore 3drenderer 3dquick qml quick
+
+SOURCES += \
+ main.cpp
+
+OTHER_FILES += \
+ main.qml \
+ MyEntity.qml
+
+RESOURCES += \
+ gooch-qml.qrc \
+ ../exampleresources/obj.qrc
diff --git a/examples/qt3d/gooch-qml/gooch-qml.qrc b/examples/qt3d/gooch-qml/gooch-qml.qrc
new file mode 100644
index 000000000..6cc293f70
--- /dev/null
+++ b/examples/qt3d/gooch-qml/gooch-qml.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>MyEntity.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/qt3d/gooch-qml/main.cpp b/examples/qt3d/gooch-qml/main.cpp
new file mode 100644
index 000000000..ad2a11e62
--- /dev/null
+++ b/examples/qt3d/gooch-qml/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** 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 <window.h>
+#include <Qt3DRenderer/QRenderAspect>
+#include <Qt3DQuick/QQmlAspectEngine>
+
+#include <QGuiApplication>
+#include <QtQml>
+
+int main(int argc, char* argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ Window view;
+ Qt3D::Quick::QQmlAspectEngine engine;
+
+ engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+
+ // Expose the window as a context property so we can set the aspect ratio
+ engine.qmlEngine()->rootContext()->setContextProperty("_window", &view);
+ QVariantMap data;
+ data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
+ data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view));
+ engine.aspectEngine()->setData(data);
+ engine.aspectEngine()->initialize();
+ engine.setSource(QUrl("qrc:/main.qml"));
+ view.show();
+
+ return app.exec();
+}
diff --git a/examples/qt3d/gooch-qml/main.qml b/examples/qt3d/gooch-qml/main.qml
new file mode 100644
index 000000000..7fb070153
--- /dev/null
+++ b/examples/qt3d/gooch-qml/main.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** 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.2 as QQ2
+
+Entity {
+ id: sceneRoot
+
+ Configuration { controlledCamera: mainCamera }
+
+ components: [
+ FrameGraph { ForwardRenderer { camera: mainCamera } }
+ ]
+
+ Camera {
+ id: mainCamera
+ projectionType: CameraLens.PerspectiveProjection
+ fieldOfView: 22.5
+ aspectRatio: _window.width / _window.height
+ nearPlane: 0.01
+ farPlane: 1000.0
+ position: Qt.vector3d( 0.0, 0.0, 15.0 )
+ viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
+ upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
+ }
+
+ MyEntity {
+ id: myEntity
+
+ source: "assets/obj/trefoil.obj"
+ scale: 1.0
+ material.diffuse: Qt.rgba( 1.0, 0.75, 1.0, 1.0 )
+ material.specular: Qt.rgba( 0.2, 0.2, 0.2, 1.0 )
+ material.alpha: 0.2
+ material.beta: 0.6
+ }
+}