summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-06-04 16:36:43 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-07 12:41:15 +0200
commit5996d9e9bdf670b82545993a78b7485d19c03a90 (patch)
tree6715876d050701ed1dfde5e097ce9888988f1efb
parentd72a6f169316255cf347761b8166abded09949f2 (diff)
Skeleton example for loading (big) models from the command line
Unfortunately the Instantiator doesn't work yet (that is, dynamically updating the scene has no effect) Change-Id: I940c192440c9fb65e94e3b20a474022d2164bcda Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--examples/bigmodel-qml/ForwardRenderer.qml72
-rw-r--r--examples/bigmodel-qml/bigmodel-qml.pro13
-rw-r--r--examples/bigmodel-qml/bigmodel-qml.qrc6
-rw-r--r--examples/bigmodel-qml/main.cpp75
-rw-r--r--examples/bigmodel-qml/main.qml92
-rw-r--r--examples/examples.pro3
6 files changed, 260 insertions, 1 deletions
diff --git a/examples/bigmodel-qml/ForwardRenderer.qml b/examples/bigmodel-qml/ForwardRenderer.qml
new file mode 100644
index 000000000..1ea9b95c7
--- /dev/null
+++ b/examples/bigmodel-qml/ForwardRenderer.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D 2.0
+import Qt3D.Render 2.0
+
+TechniqueFilter {
+ id: root
+
+ // Expose the viewport rect and camera. This allows users of this
+ // forward rendering framegraph to decide which camera in the
+ // scene renders to a given viewport region.
+ //
+ // Using this as a building block for a larger framegraph would
+ // allow a scene to be rendered multiple times f.i. to different
+ // viewports using different cameras
+ property alias viewportRect: viewport.rect
+ property alias camera: cameraSelector.camera
+
+ criteria : [
+ TechniqueCriterion { criterionType : TechniqueCriterion.RenderingStyle; criterionValue : "forward"}
+ ]
+
+ Viewport {
+ id: viewport
+ rect: Qt.rect(0.0, 0.0, 1.0, 1.0) // From Top Left
+
+ CameraSelector {
+ id : cameraSelector
+ RenderPassFilter { renderPassName: "zFill" }
+ RenderPassFilter { renderPassName: "lighting" }
+ }
+ }
+}
diff --git a/examples/bigmodel-qml/bigmodel-qml.pro b/examples/bigmodel-qml/bigmodel-qml.pro
new file mode 100644
index 000000000..fd598c3ed
--- /dev/null
+++ b/examples/bigmodel-qml/bigmodel-qml.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+
+QT += 3dcore 3drenderer 3dquick qml quick
+
+SOURCES += \
+ main.cpp
+
+OTHER_FILES += \
+ main.qml \
+ ForwardRenderer.qml
+
+RESOURCES += \
+ bigmodel-qml.qrc
diff --git a/examples/bigmodel-qml/bigmodel-qml.qrc b/examples/bigmodel-qml/bigmodel-qml.qrc
new file mode 100644
index 000000000..fedae75c1
--- /dev/null
+++ b/examples/bigmodel-qml/bigmodel-qml.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>ForwardRenderer.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/bigmodel-qml/main.cpp b/examples/bigmodel-qml/main.cpp
new file mode 100644
index 000000000..47558f409
--- /dev/null
+++ b/examples/bigmodel-qml/main.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <quickwindow.h>
+#include <rendereraspect.h>
+
+#include <QGuiApplication>
+#include <QtQml>
+
+#include <iostream>
+
+int main(int argc, char* argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QCommandLineParser parser;
+ parser.addPositionalArgument(QStringLiteral("meshfile"), QStringLiteral("The mesh file to load"));
+ parser.process(app);
+
+ const QStringList meshFileNames = parser.positionalArguments();
+ if (meshFileNames.length() == 0) {
+ std::cerr << "Please specify mesh files to load" << std::endl;
+ return 1;
+ }
+
+ Qt3D::Quick::QuickWindow view;
+ view.registerAspect(new Qt3D::RendererAspect());
+ // There should be some synchronising mechanism to make sure
+ // the source is set after alll aspects have been completely initialized
+ // Otherwise we might encounter cases where an Aspect's QML elements have
+ // not yet been registered
+ view.engine()->rootContext()->setContextProperty("_meshFileNames", meshFileNames);
+ view.setSource(QUrl("qrc:/main.qml"));
+ view.show();
+
+ return app.exec();
+}
diff --git a/examples/bigmodel-qml/main.qml b/examples/bigmodel-qml/main.qml
new file mode 100644
index 000000000..a2d3c19dd
--- /dev/null
+++ b/examples/bigmodel-qml/main.qml
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 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 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D 2.0
+import Qt3D.Render 2.0
+
+// For Qt.vector3d() and friends. For some reason this is provided by
+// QQuickValueTypeProvider in QtQuick rather than the default value
+// type provider in QtQml. So we will need to replicate this in Qt3D
+// for the types that we wish to support. Otherwise we'll have to import
+// QtQuick 2.1 all over the place.
+import QtQuick 2.2 as QQ2
+import QtQml 2.2
+
+Entity {
+ id: sceneRoot
+
+ Camera {
+ id: camera
+ lens : CameraLens {
+ projectionType: CameraLens.PerspectiveProjection
+ fieldOfView: 45
+ aspectRatio: 16/9
+ nearPlane : 0.1
+ farPlane : 1000.0
+ }
+
+ transform : Transform {
+ LookAt {
+ 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
+ }
+ }
+
+ components: [external_forward_renderer]
+
+ Instantiator {
+ model: _meshFileNames
+ delegate: Scene { source: modelData; }
+ }
+}
diff --git a/examples/examples.pro b/examples/examples.pro
index f8242337f..a4449e0f4 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -8,7 +8,8 @@ SUBDIRS += \
cpp_example \
multiviewport \
torus-qml \
- torus-cpp
+ torus-cpp \
+ bigmodel-qml
# TODO Port the old examples to new APIs
#SUBDIRS += qt3d