summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-11-11 17:44:45 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-11-25 12:14:29 +0000
commit1324668b1b77c865c90a1352a61b0b3da3da39b1 (patch)
treef4537e31d451d2c7a6ce1265f0ce5d86918377b9
parentdf52852c57067d1fb408d075d4bddcfe681467dd (diff)
Add a qgltf example.
This is like gltf but uses the original Collada asset and generates a glTF model at build time. Now that the qgltf rule is in qtbase we can freely use it in any examples. This does not have the limitations the gltf example has: this will function both with core profiles and ES. Change-Id: I9f04cf8b77337d397e1aecd1ffb22b7ce7e15ef7 Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
-rw-r--r--examples/qt3d/qgltf/Wine.qml60
-rw-r--r--examples/qt3d/qgltf/main.cpp66
-rw-r--r--examples/qt3d/qgltf/main.qml81
-rw-r--r--examples/qt3d/qgltf/qgltf.pro21
-rw-r--r--examples/qt3d/qgltf/qgltf_example.qrc6
-rw-r--r--examples/qt3d/qt3d.pro3
6 files changed, 236 insertions, 1 deletions
diff --git a/examples/qt3d/qgltf/Wine.qml b/examples/qt3d/qgltf/Wine.qml
new file mode 100644
index 000000000..4fab28479
--- /dev/null
+++ b/examples/qt3d/qgltf/Wine.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
+** 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.Core 2.0
+import Qt3D.Render 2.0
+
+Entity {
+ id: root
+
+ property vector3d position: Qt.vector3d(0, 0, 0)
+ property real angleX: 0
+ property real angleY: 0
+ property real angleZ: 0
+ property real scale: 1
+
+ components: [
+ Transform {
+ translation: root.position
+ rotation: fromEulerAngles(root.angleX, root.angleY, root.angleZ)
+ scale: root.scale
+ },
+ SceneLoader
+ {
+ source: "qrc:/models/wine.gltf"
+ }
+ ]
+}
diff --git a/examples/qt3d/qgltf/main.cpp b/examples/qt3d/qgltf/main.cpp
new file mode 100644
index 000000000..080c007ec
--- /dev/null
+++ b/examples/qt3d/qgltf/main.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 <Qt3DRender/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
+#include <Qt3DQuick/QQmlAspectEngine>
+
+#include <QGuiApplication>
+#include <QOpenGLContext>
+#include <QtQml>
+
+int main(int argc, char* argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ Window view;
+ Qt3DCore::Quick::QQmlAspectEngine engine;
+
+ engine.aspectEngine()->registerAspect(new Qt3DRender::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3DInput::QInputAspect());
+
+ 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/qgltf/main.qml b/examples/qt3d/qgltf/main.qml
new file mode 100644
index 000000000..7f8f081ab
--- /dev/null
+++ b/examples/qt3d/qgltf/main.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
+** 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.Core 2.0
+import Qt3D.Render 2.0
+
+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, -100.0, -120.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 {
+ CameraSelector {
+ camera: camera
+ ClearBuffer {
+ buffers: ClearBuffer.ColorDepthBuffer
+ SortMethod {
+ criteria: [
+ SortCriterion { sort: SortCriterion.BackToFront }
+ ]
+ }
+ }
+ }
+ }
+ }
+
+ Wine {
+ id: wineRack
+ position: Qt.vector3d(-60.0, 0.0, 50.0)
+ angleX: 180
+ }
+}
diff --git a/examples/qt3d/qgltf/qgltf.pro b/examples/qt3d/qgltf/qgltf.pro
new file mode 100644
index 000000000..3ba543ec5
--- /dev/null
+++ b/examples/qt3d/qgltf/qgltf.pro
@@ -0,0 +1,21 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+QT += 3dcore 3drender 3dinput 3dquick qml quick
+
+HEADERS += \
+
+SOURCES += \
+ main.cpp
+
+OTHER_FILES += \
+ main.qml \
+ Wine.qml
+
+QT3D_MODELS = ../exampleresources/assets/gltf/wine/wine.dae
+QGLTF_PARAMS = -g
+load(qgltf)
+
+RESOURCES += \
+ qgltf_example.qrc
diff --git a/examples/qt3d/qgltf/qgltf_example.qrc b/examples/qt3d/qgltf/qgltf_example.qrc
new file mode 100644
index 000000000..0da7ea21f
--- /dev/null
+++ b/examples/qt3d/qgltf/qgltf_example.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>Wine.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/qt3d/qt3d.pro b/examples/qt3d/qt3d.pro
index bc26020ed..4de448259 100644
--- a/examples/qt3d/qt3d.pro
+++ b/examples/qt3d/qt3d.pro
@@ -43,7 +43,8 @@ SUBDIRS += \
custom-mesh-qml \
instanced-arrays-qml \
picking-qml \
- transforms-qml
+ transforms-qml \
+ qgltf
# TODO Port the old examples to new APIs
#SUBDIRS += qt3d