From 8dcd8e42458748ca3ae3293b3d2b7e5b56b87252 Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Thu, 14 Jan 2016 08:43:34 +0100 Subject: Link examples against static lib Contains: Qt3DWindow Qt3DQuickWindow QFirstPersonCameraController FirstPersonCameraController.qml This will allow to get rid of the Camera configuration hack Change-Id: I55c5634aa4c162f9dd2852d3258073a6352b426c Reviewed-by: Sean Harmer --- examples/qt3d/anaglyph-rendering/main.cpp | 22 +- examples/qt3d/assimp/main.cpp | 16 +- examples/qt3d/assimp/main.qml | 4 +- examples/qt3d/bigmodel-qml/main.cpp | 19 +- examples/qt3d/bigmodel-qml/main.qml | 3 +- examples/qt3d/bigscene-instanced-qml/main.cpp | 19 +- examples/qt3d/bigscene-instanced-qml/main.qml | 4 +- examples/qt3d/clip-planes-qml/main.cpp | 18 +- examples/qt3d/clip-planes-qml/main.qml | 2 +- examples/qt3d/common/window.cpp | 78 ------ examples/qt3d/common/window.h | 53 ---- examples/qt3d/compute-particles/ParticlesScene.qml | 4 +- examples/qt3d/custom-mesh-qml/main.cpp | 19 +- examples/qt3d/custom-mesh-qml/main.qml | 4 +- examples/qt3d/cylinder-qml/main.cpp | 20 +- examples/qt3d/cylinder-qml/main.qml | 4 +- examples/qt3d/deferred-renderer-qml/main.cpp | 19 +- examples/qt3d/deferred-renderer-qml/main.qml | 4 +- examples/qt3d/enabled-qml/main.cpp | 19 +- examples/qt3d/exampleresources/obj.qrc | 8 +- .../FirstPersonCameraController.qml | 255 +++++++++++++++++++ examples/qt3d/examples-common/examples-common.pri | 20 ++ examples/qt3d/examples-common/examples-common.pro | 44 ++++ .../qfirstpersoncameracontroller.cpp | 278 +++++++++++++++++++++ .../examples-common/qfirstpersoncameracontroller.h | 88 +++++++ .../qfirstpersoncameracontroller_p.h | 115 +++++++++ examples/qt3d/examples-common/qt3dquickwindow.cpp | 121 +++++++++ examples/qt3d/examples-common/qt3dquickwindow.h | 94 +++++++ examples/qt3d/examples-common/qt3dwindow.cpp | 179 +++++++++++++ examples/qt3d/examples-common/qt3dwindow.h | 111 ++++++++ examples/qt3d/examples.pri | 8 +- examples/qt3d/gltf/main.cpp | 21 +- examples/qt3d/gltf/main.qml | 4 +- examples/qt3d/gooch-qml/main.cpp | 26 +- examples/qt3d/gooch-qml/main.qml | 2 +- examples/qt3d/instanced-arrays-qml/main.cpp | 24 +- examples/qt3d/instanced-arrays-qml/main.qml | 4 +- examples/qt3d/keyboardinput-qml/main.cpp | 19 +- examples/qt3d/keyboardinput-qml/main.qml | 2 +- examples/qt3d/lights/main.cpp | 17 +- examples/qt3d/lights/main.qml | 4 +- examples/qt3d/loader-qml/main.cpp | 19 +- examples/qt3d/loader-qml/main.qml | 4 +- examples/qt3d/materials/main.cpp | 25 +- examples/qt3d/materials/main.qml | 4 +- examples/qt3d/mouseinput-qml/main.cpp | 21 +- examples/qt3d/mouseinput-qml/main.qml | 4 +- examples/qt3d/multiviewport/main.cpp | 18 +- examples/qt3d/picking-qml/main.cpp | 23 +- examples/qt3d/picking-qml/main.qml | 4 +- examples/qt3d/planets-qml/SolarSystem.qml | 4 +- examples/qt3d/plasma/main.cpp | 22 +- examples/qt3d/playground-qml/main.cpp | 18 +- examples/qt3d/playground-qml/main.qml | 4 +- examples/qt3d/qt3d.pro | 8 + examples/qt3d/scene3d-loader/AnimatedEntity.qml | 4 +- examples/qt3d/scene3d/AnimatedEntity.qml | 4 +- examples/qt3d/shadow-map-qml/main.cpp | 20 +- examples/qt3d/shadow-map-qml/main.qml | 4 +- examples/qt3d/simple-cpp/main.cpp | 108 ++------ .../qt3d/simple-cpp/orbittransformcontroller.cpp | 102 ++++++++ .../qt3d/simple-cpp/orbittransformcontroller.h | 86 +++++++ examples/qt3d/simple-cpp/simple-cpp.pro | 6 +- examples/qt3d/simple-qml/main.cpp | 22 +- examples/qt3d/simple-qml/main.qml | 3 +- examples/qt3d/simple-shaders-qml/main.cpp | 19 +- examples/qt3d/simple-shaders-qml/main.qml | 4 +- examples/qt3d/skybox/main.cpp | 22 +- examples/qt3d/skybox/main.qml | 4 +- examples/qt3d/tessellation-modes/main.cpp | 25 +- examples/qt3d/tessellation-modes/main.qml | 4 +- examples/qt3d/torus-qml/main.cpp | 20 +- examples/qt3d/torus-qml/main.qml | 4 +- examples/qt3d/transforms-qml/main.cpp | 24 +- examples/qt3d/transparency-qml-scene3d/Scene.qml | 2 +- examples/qt3d/transparency-qml/main.cpp | 18 +- examples/qt3d/transparency-qml/main.qml | 2 +- examples/qt3d/wave/main.cpp | 24 +- examples/qt3d/wave/main.qml | 4 +- examples/qt3d/wireframe/main.cpp | 20 +- examples/qt3d/wireframe/main.qml | 4 +- 81 files changed, 1692 insertions(+), 820 deletions(-) delete mode 100644 examples/qt3d/common/window.cpp delete mode 100644 examples/qt3d/common/window.h create mode 100644 examples/qt3d/examples-common/FirstPersonCameraController.qml create mode 100644 examples/qt3d/examples-common/examples-common.pri create mode 100644 examples/qt3d/examples-common/examples-common.pro create mode 100644 examples/qt3d/examples-common/qfirstpersoncameracontroller.cpp create mode 100644 examples/qt3d/examples-common/qfirstpersoncameracontroller.h create mode 100644 examples/qt3d/examples-common/qfirstpersoncameracontroller_p.h create mode 100644 examples/qt3d/examples-common/qt3dquickwindow.cpp create mode 100644 examples/qt3d/examples-common/qt3dquickwindow.h create mode 100644 examples/qt3d/examples-common/qt3dwindow.cpp create mode 100644 examples/qt3d/examples-common/qt3dwindow.h create mode 100644 examples/qt3d/simple-cpp/orbittransformcontroller.cpp create mode 100644 examples/qt3d/simple-cpp/orbittransformcontroller.h (limited to 'examples') diff --git a/examples/qt3d/anaglyph-rendering/main.cpp b/examples/qt3d/anaglyph-rendering/main.cpp index c9843e10c..a48f7ca48 100644 --- a/examples/qt3d/anaglyph-rendering/main.cpp +++ b/examples/qt3d/anaglyph-rendering/main.cpp @@ -34,29 +34,19 @@ ** ****************************************************************************/ -#include -#include -#include +#include "qt3dquickwindow.h" #include - #include -#include +#include +#include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.qmlEngine()->rootContext()->setContextProperty("_window", &view); - engine.setSource(QUrl("qrc:/main.qml")); + view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/assimp/main.cpp b/examples/qt3d/assimp/main.cpp index 1b59163f2..ba238eafe 100644 --- a/examples/qt3d/assimp/main.cpp +++ b/examples/qt3d/assimp/main.cpp @@ -34,12 +34,9 @@ ** ****************************************************************************/ -#include -#include +#include #include #include -#include -#include #include #include @@ -94,17 +91,10 @@ int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); - Window view; - Qt3DCore::Quick::QQmlAspectEngine engine; + Qt3DQuickWindow view; - engine.aspectEngine()->registerAspect(new Qt3DRender::QRenderAspect()); - engine.aspectEngine()->registerAspect(new Qt3DInput::QInputAspect()); - QVariantMap data; - data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); qmlRegisterType("Qt3D.Examples", 2, 0, "SceneHelper"); - engine.setSource(QUrl("qrc:/main.qml")); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/assimp/main.qml b/examples/qt3d/assimp/main.qml index 5936313f5..9eaf21464 100644 --- a/examples/qt3d/assimp/main.qml +++ b/examples/qt3d/assimp/main.qml @@ -60,8 +60,8 @@ Entity viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { - controlledCamera: camera + FirstPersonCameraController { + camera: camera } // test_scene.dae contains three named nodes. Once the asynchronous loading of the diff --git a/examples/qt3d/bigmodel-qml/main.cpp b/examples/qt3d/bigmodel-qml/main.cpp index 0d944c883..3a94a8826 100644 --- a/examples/qt3d/bigmodel-qml/main.cpp +++ b/examples/qt3d/bigmodel-qml/main.cpp @@ -34,29 +34,16 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include "qt3dquickwindow.h" #include -#include -#include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); - Window view; - Qt3DCore::Quick::QQmlAspectEngine engine; + Qt3DQuickWindow view; - engine.aspectEngine()->registerAspect(new Qt3DRender::QRenderAspect()); - engine.aspectEngine()->registerAspect(new Qt3DInput::QInputAspect()); - QVariantMap data; - data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/bigmodel-qml/main.qml b/examples/qt3d/bigmodel-qml/main.qml index 56081055e..a4c452ee1 100644 --- a/examples/qt3d/bigmodel-qml/main.qml +++ b/examples/qt3d/bigmodel-qml/main.qml @@ -36,12 +36,13 @@ import Qt3D.Core 2.0 import Qt3D.Render 2.0 +import Qt3D.Input 2.0 import QtQuick 2.2 as QQ2 Entity { id: sceneRoot - Configuration { controlledCamera: mainCamera } + FirstPersonCameraController { camera: mainCamera } components: [ FrameGraph { activeFrameGraph: ForwardRenderer { camera: mainCamera } } diff --git a/examples/qt3d/bigscene-instanced-qml/main.cpp b/examples/qt3d/bigscene-instanced-qml/main.cpp index 1a538e49d..d6443402f 100644 --- a/examples/qt3d/bigscene-instanced-qml/main.cpp +++ b/examples/qt3d/bigscene-instanced-qml/main.cpp @@ -34,28 +34,15 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include "qt3dquickwindow.h" #include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); - + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/bigscene-instanced-qml/main.qml b/examples/qt3d/bigscene-instanced-qml/main.qml index cc04d3290..8b7623732 100644 --- a/examples/qt3d/bigscene-instanced-qml/main.qml +++ b/examples/qt3d/bigscene-instanced-qml/main.qml @@ -53,9 +53,7 @@ Entity { viewCenter: Qt.vector3d(0.0, 0.0, 0.0) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } components: [ FrameGraph { diff --git a/examples/qt3d/clip-planes-qml/main.cpp b/examples/qt3d/clip-planes-qml/main.cpp index 3ee54692b..29b4c0310 100644 --- a/examples/qt3d/clip-planes-qml/main.cpp +++ b/examples/qt3d/clip-planes-qml/main.cpp @@ -34,27 +34,15 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include "qt3dquickwindow.h" #include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); - + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/clip-planes-qml/main.qml b/examples/qt3d/clip-planes-qml/main.qml index b7bcd5adb..06fd5bf14 100644 --- a/examples/qt3d/clip-planes-qml/main.qml +++ b/examples/qt3d/clip-planes-qml/main.qml @@ -53,7 +53,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { controlledCamera: camera } + FirstPersonCameraController { camera: camera } components: FrameGraph { ClipCappingFrameGraph { diff --git a/examples/qt3d/common/window.cpp b/examples/qt3d/common/window.cpp deleted file mode 100644 index bb28f23ab..000000000 --- a/examples/qt3d/common/window.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include - -Window::Window(QScreen *screen) - : QWindow(screen) - -{ - setSurfaceType(QSurface::OpenGLSurface); - - resize(1024, 768); - - QSurfaceFormat format; - if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { - format.setVersion(4, 3); - format.setProfile(QSurfaceFormat::CoreProfile); - } - format.setDepthBufferSize( 24 ); - format.setSamples( 4 ); - format.setStencilBufferSize(8); - setFormat(format); - create(); -} - -Window::~Window() -{ -} - -void Window::keyPressEvent( QKeyEvent* e ) -{ - switch ( e->key() ) - { - case Qt::Key_Escape: - QGuiApplication::quit(); - break; - - default: - QWindow::keyPressEvent( e ); - } -} diff --git a/examples/qt3d/common/window.h b/examples/qt3d/common/window.h deleted file mode 100644 index 7c6e3606e..000000000 --- a/examples/qt3d/common/window.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef WINDOW_H -#define WINDOW_H - -#include - -class Window : public QWindow -{ - Q_OBJECT -public: - explicit Window(QScreen *screen = 0); - ~Window(); - -protected: - virtual void keyPressEvent(QKeyEvent *e); -}; - -#endif // QT3D_WINDOW_H diff --git a/examples/qt3d/compute-particles/ParticlesScene.qml b/examples/qt3d/compute-particles/ParticlesScene.qml index f1472e178..6f8139669 100644 --- a/examples/qt3d/compute-particles/ParticlesScene.qml +++ b/examples/qt3d/compute-particles/ParticlesScene.qml @@ -58,9 +58,7 @@ Entity { } ] - Configuration { - controlledCamera: sceneCamera - } + FirstPersonCameraController { camera: sceneCamera } Camera { id: sceneCamera diff --git a/examples/qt3d/custom-mesh-qml/main.cpp b/examples/qt3d/custom-mesh-qml/main.cpp index a308bfacc..c83572aa7 100644 --- a/examples/qt3d/custom-mesh-qml/main.cpp +++ b/examples/qt3d/custom-mesh-qml/main.cpp @@ -34,28 +34,15 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include "qt3dquickwindow.h" #include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); - + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/custom-mesh-qml/main.qml b/examples/qt3d/custom-mesh-qml/main.qml index b12322e2d..cb7175b07 100644 --- a/examples/qt3d/custom-mesh-qml/main.qml +++ b/examples/qt3d/custom-mesh-qml/main.qml @@ -53,9 +53,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } components: [ FrameGraph { diff --git a/examples/qt3d/cylinder-qml/main.cpp b/examples/qt3d/cylinder-qml/main.cpp index c5654586c..d6443402f 100644 --- a/examples/qt3d/cylinder-qml/main.cpp +++ b/examples/qt3d/cylinder-qml/main.cpp @@ -34,29 +34,15 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include "qt3dquickwindow.h" #include -#include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/cylinder-qml/main.qml b/examples/qt3d/cylinder-qml/main.qml index 8fb72e2ed..12663fd4f 100644 --- a/examples/qt3d/cylinder-qml/main.qml +++ b/examples/qt3d/cylinder-qml/main.qml @@ -52,9 +52,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: mainCamera } FrameGraph { id : external_forward_renderer diff --git a/examples/qt3d/deferred-renderer-qml/main.cpp b/examples/qt3d/deferred-renderer-qml/main.cpp index 65edece13..0a919aa76 100644 --- a/examples/qt3d/deferred-renderer-qml/main.cpp +++ b/examples/qt3d/deferred-renderer-qml/main.cpp @@ -35,28 +35,15 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include "qt3dquickwindow.h" #include -#include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/deferred-renderer-qml/main.qml b/examples/qt3d/deferred-renderer-qml/main.qml index 85d6094c1..41e323349 100644 --- a/examples/qt3d/deferred-renderer-qml/main.qml +++ b/examples/qt3d/deferred-renderer-qml/main.qml @@ -53,9 +53,7 @@ Entity { } } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } Entity { id : screenQuadEntity diff --git a/examples/qt3d/enabled-qml/main.cpp b/examples/qt3d/enabled-qml/main.cpp index 53939cc62..c6fb3937c 100644 --- a/examples/qt3d/enabled-qml/main.cpp +++ b/examples/qt3d/enabled-qml/main.cpp @@ -35,27 +35,14 @@ ****************************************************************************/ #include - -#include -#include -#include - -#include -#include -#include +#include "qt3dquickwindow.h" int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - Window view; - Qt3DCore::Quick::QQmlAspectEngine engine; - engine.aspectEngine()->registerAspect(new Qt3DRender::QRenderAspect()); - QVariantMap data; - data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl(QStringLiteral("qrc:/main.qml"))); + view.setSource(QUrl(QStringLiteral("qrc:/main.qml"))); view.show(); return app.exec(); diff --git a/examples/qt3d/exampleresources/obj.qrc b/examples/qt3d/exampleresources/obj.qrc index 952fd59d0..ef70706a5 100644 --- a/examples/qt3d/exampleresources/obj.qrc +++ b/examples/qt3d/exampleresources/obj.qrc @@ -1,7 +1,7 @@ - assets/obj/ball.obj - assets/obj/trefoil.obj - assets/obj/toyplane.obj - + assets/textures/pattern_09/specular.webp + assets/textures/pattern_09/normal.webp + assets/textures/pattern_09/diffuse.webp + diff --git a/examples/qt3d/examples-common/FirstPersonCameraController.qml b/examples/qt3d/examples-common/FirstPersonCameraController.qml new file mode 100644 index 000000000..27b794afc --- /dev/null +++ b/examples/qt3d/examples-common/FirstPersonCameraController.qml @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Paul Lemire +** 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 +import Qt3D.Input 2.0 +import Qt3D.Logic 2.0 +import QtQml 2.2 + +Entity { + id: root + property Camera camera + property real linearSpeed: 10.0 + property real lookSpeed: 180.0 + + QtObject { + id: d + readonly property vector3d firstPersonUp: Qt.vector3d(0, 1, 0) + property bool leftMouseButtonPressed: false + property real vx: 0; + property real vy: 0; + property real vz: 0; + property real dx: 0 + property real dy: 0 + property bool fineMotion: false + } + + KeyboardController { + id: keyboardSourceDevice + } + + MouseController { + id: mouseSourceDevice + sensitivity: d.fineMotion ? 0.01 : 0.1 + } + + LogicalDevice { + id: cameraControlDevice + + actions: [ + Action { + name: "LMB" + inputs: [ + ActionInput { + sourceDevice: mouseSourceDevice + keys: [MouseController.Left] + } + ] + }, + Action { + name: "fineMotion" + inputs: [ + ActionInput { + sourceDevice: keyboardSourceDevice + keys: [Qt.Key_Shift] + } + ] + } + ] // actions + + axes: [ + // Rotation + Axis { + name: "RX" + inputs: [ + AxisInput { + sourceDevice: mouseSourceDevice + axis: MouseController.X + } + ] + }, + Axis { + name: "RY" + inputs: [ + AxisInput { + sourceDevice: mouseSourceDevice + axis: MouseController.Y + } + ] + }, + // Translation + Axis { + name: "TX" + inputs: [ + AxisInput { + sourceDevice: keyboardSourceDevice + keys: [Qt.Key_Left] + scale: -1.0 + }, + AxisInput { + sourceDevice: keyboardSourceDevice + keys: [Qt.Key_Right] + scale: 1.0 + } + ] + }, + Axis { + name: "TZ" + inputs: [ + AxisInput { + sourceDevice: keyboardSourceDevice + keys: [Qt.Key_Up] + scale: 1.0 + }, + AxisInput { + sourceDevice: keyboardSourceDevice + keys: [Qt.Key_Down] + scale: -1.0 + } + ] + }, + Axis { + name: "TY" + inputs: [ + AxisInput { + sourceDevice: keyboardSourceDevice + keys: [Qt.Key_PageUp] + scale: 1.0 + }, + AxisInput { + sourceDevice: keyboardSourceDevice + keys: [Qt.Key_PageDown] + scale: -1.0 + } + ] + } + ] // axes + } + + components: [ + AxisActionHandler { + id: handler + logicalDevice: cameraControlDevice + + onAxisValueChanged: { + + switch (name) { + + case "TX": { + d.vx = axisValue * linearSpeed + break; + } + + case "TY": { + d.vy = axisValue * linearSpeed + break; + } + + case "TZ": { + d.vz = axisValue * linearSpeed + break; + } + + case "RX": { + d.dx = axisValue; + break; + } + + case "RY": { + d.dy = axisValue; + break; + } + case "MouseWheel": { + d.zoom = axisValue; + break + } + + } + } + + onActionStarted: { + + switch (name) { + + case "LMB": { + d.leftMouseButtonPressed = true; + break; + } + + case "fineMotion": { + console.log("fineMotion started") + d.fineMotion = true; + break; + } + + } + + } + + onActionFinished: { + + switch (name) { + + case "LMB": { + d.leftMouseButtonPressed = false; + break; + } + + case "fineMotion": { + console.log("fineMotion finished") + d.fineMotion = false; + break; + } + + } + } + }, + + LogicComponent { + onFrameUpdate: { + // The time difference since the last frame is passed in as the + // argument dt. It is a floating point value in units of seconds. + root.camera.translate(Qt.vector3d(d.vx, d.vy, d.vz).times(dt)) + + if (d.leftMouseButtonPressed) { + root.camera.pan(root.lookSpeed * d.dx * dt, d.firstPersonUp) + root.camera.tilt(root.lookSpeed * d.dy * dt) + } + } + } + ] // components +} diff --git a/examples/qt3d/examples-common/examples-common.pri b/examples/qt3d/examples-common/examples-common.pri new file mode 100644 index 000000000..e50e39edd --- /dev/null +++ b/examples/qt3d/examples-common/examples-common.pri @@ -0,0 +1,20 @@ +QT += 3dcore 3drender 3dinput 3dlogic qml + +INCLUDEPATH += $$PWD + +win32 { + build_pass { + CONFIG(debug, debug|release) { + common_static_lib = $$OUT_PWD/../examples-common/debug/$${QMAKE_PREFIX_STATICLIB}examples-common.$${QMAKE_EXTENSION_STATICLIB} + } else { + common_static_lib = $$OUT_PWD/../examples-common/release/$${QMAKE_PREFIX_STATICLIB}examples-common.$${QMAKE_EXTENSION_STATICLIB} + } + } +} else { + common_static_lib = $$OUT_PWD/../examples-common/$${QMAKE_PREFIX_STATICLIB}examples-common.$${QMAKE_EXTENSION_STATICLIB} +} + +LIBS += $$common_static_lib +PRE_TARGETDEPS += $$common_static_lib + +RESOURCES += $$OUT_PWD/../examples-common/examples-common.qrc diff --git a/examples/qt3d/examples-common/examples-common.pro b/examples/qt3d/examples-common/examples-common.pro new file mode 100644 index 000000000..7b56b9b54 --- /dev/null +++ b/examples/qt3d/examples-common/examples-common.pro @@ -0,0 +1,44 @@ +TEMPLATE = lib +CONFIG += staticlib +TARGET = examples-common +QT += core-private 3dcore 3dcore-private 3drender 3dinput 3dlogic qml quick + +SOURCES += \ + qfirstpersoncameracontroller.cpp \ + qt3dwindow.cpp \ + qt3dquickwindow.cpp + +HEADERS += \ + qfirstpersoncameracontroller.h \ + qfirstpersoncameracontroller_p.h \ + qt3dwindow.h \ + qt3dquickwindow.h + + +QML_FILES = \ + $$PWD/FirstPersonCameraController.qml + +OTHER_FILES += \ + $$QML_FILES + +# Create a resource file for qml files that need to be registered by the plugin +GENERATED_RESOURCE_FILE = $$OUT_PWD/examples-common.qrc +INCLUDED_RESOURCE_FILES = $$QML_FILES +RESOURCE_CONTENT = \ + "" \ + "" + +for(resourcefile, INCLUDED_RESOURCE_FILES) { + resourcefileabsolutepath = $$absolute_path($$resourcefile) + relativepath_in = $$relative_path($$resourcefileabsolutepath, $$_PRO_FILE_PWD_) + relativepath_out = $$relative_path($$resourcefileabsolutepath, $$OUT_PWD) + RESOURCE_CONTENT += "$$relativepath_out" +} + +RESOURCE_CONTENT += \ + "" \ + "" + +write_file($$GENERATED_RESOURCE_FILE, RESOURCE_CONTENT)|error("Aborting.") + +RESOURCES += $$GENERATED_RESOURCE_FILE diff --git a/examples/qt3d/examples-common/qfirstpersoncameracontroller.cpp b/examples/qt3d/examples-common/qfirstpersoncameracontroller.cpp new file mode 100644 index 000000000..46ae0c115 --- /dev/null +++ b/examples/qt3d/examples-common/qfirstpersoncameracontroller.cpp @@ -0,0 +1,278 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 "qfirstpersoncameracontroller_p.h" +#include "qfirstpersoncameracontroller.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DInput { + + +QFirstPersonCameraControllerPrivate::QFirstPersonCameraControllerPrivate() + : Qt3DCore::QEntityPrivate() + , m_camera(Q_NULLPTR) + , m_leftMouseButtonAction(new QAction()) + , m_fineMotionAction(new QAction()) + , m_rxAxis(new QAxis()) + , m_ryAxis(new QAxis()) + , m_txAxis(new QAxis()) + , m_tyAxis(new QAxis()) + , m_tzAxis(new QAxis()) + , m_leftMouseButtonInput(new QActionInput()) + , m_fineMotionKeyInput(new QActionInput()) + , m_mouseRxInput(new QAxisInput()) + , m_mouseRyInput(new QAxisInput()) + , m_keyboardTxPosInput(new QAxisInput()) + , m_keyboardTyPosInput(new QAxisInput()) + , m_keyboardTzPosInput(new QAxisInput()) + , m_keyboardTxNegInput(new QAxisInput()) + , m_keyboardTyNegInput(new QAxisInput()) + , m_keyboardTzNegInput(new QAxisInput()) + , m_keyboardController(new QKeyboardController()) + , m_mouseController(new QMouseController()) + , m_logicalDevice(new QLogicalDevice()) + , m_axisActionHandler(new QAxisActionHandler()) + , m_logicComponent(new Qt3DLogic::QLogicComponent()) + , m_linearSpeed(10.0f) + , m_lookSpeed(180.0f) + , m_fineMotion(false) + , m_leftMouseButtonPressed(false) + , m_firstPersonUp(QVector3D(0.0f, 1.0f, 0.0f)) +{} + +void QFirstPersonCameraControllerPrivate::init() +{ + //// Actions + + // Left Mouse Button Action + m_leftMouseButtonInput->setKeys(QVariantList() << QMouseController::Left); + m_leftMouseButtonAction->addInput(m_leftMouseButtonInput); + m_leftMouseButtonAction->setName(QStringLiteral("LMB")); + + // Fine Motion Action + m_fineMotionKeyInput->setKeys(QVariantList() << Qt::Key_Shift); + m_fineMotionAction->addInput(m_fineMotionKeyInput); + m_fineMotionAction->setName(QStringLiteral("fineMotion")); + + //// Axes + + // Mouse X + m_mouseRxInput->setAxis(QMouseController::X); + m_rxAxis->addInput(m_mouseRxInput); + m_rxAxis->setName(QStringLiteral("RX")); + + // Mouse Y + m_mouseRyInput->setAxis(QMouseController::Y); + m_ryAxis->addInput(m_mouseRyInput); + m_ryAxis->setName(QStringLiteral("RY")); + + // Keyboard Pos Tx + m_keyboardTxPosInput->setKeys(QVariantList() << Qt::Key_Right); + m_keyboardTxPosInput->setScale(1.0f); + m_txAxis->addInput(m_keyboardTxPosInput); + + // Keyboard Pos Ty + m_keyboardTyPosInput->setKeys(QVariantList() << Qt::Key_PageUp); + m_keyboardTyPosInput->setScale(1.0f); + m_tyAxis->addInput(m_keyboardTyPosInput); + + // Keyboard Pos Tz + m_keyboardTzPosInput->setKeys(QVariantList() << Qt::Key_Up); + m_keyboardTzPosInput->setScale(1.0f); + m_tzAxis->addInput(m_keyboardTzPosInput); + + // Keyboard Neg Tx + m_keyboardTxNegInput->setKeys(QVariantList() << Qt::Key_Left); + m_keyboardTxNegInput->setScale(-1.0f); + m_txAxis->addInput(m_keyboardTxNegInput); + + // Keyboard Neg Ty + m_keyboardTyNegInput->setKeys(QVariantList() << Qt::Key_PageDown); + m_keyboardTyNegInput->setScale(-1.0f); + m_tyAxis->addInput(m_keyboardTyNegInput); + + // Keyboard Neg Tz + m_keyboardTzNegInput->setKeys(QVariantList() << Qt::Key_Down); + m_keyboardTzNegInput->setScale(-1.0f); + m_tzAxis->addInput(m_keyboardTzNegInput); + + m_txAxis->setName(QStringLiteral("TX")); + m_tyAxis->setName(QStringLiteral("TY")); + m_tzAxis->setName(QStringLiteral("TZ")); + + //// Logical Device + + m_logicalDevice->addAction(m_fineMotionAction); + m_logicalDevice->addAction(m_leftMouseButtonAction); + m_logicalDevice->addAxis(m_rxAxis); + m_logicalDevice->addAxis(m_ryAxis); + m_logicalDevice->addAxis(m_txAxis); + m_logicalDevice->addAxis(m_tyAxis); + m_logicalDevice->addAxis(m_tzAxis); + + Q_Q(QFirstPersonCameraController); + + //// AxisActionHandler + + QObject::connect(m_axisActionHandler, SIGNAL(actionStarted(QString)), + q, SLOT(_q_onActionStarted(QString))); + QObject::connect(m_axisActionHandler, SIGNAL(actionFinished(QString)), + q, SLOT(_q_onActionFinished(QString))); + QObject::connect(m_axisActionHandler, SIGNAL(axisValueChanged(QString,float)), + q, SLOT(_q_onAxisValueChanged(QString,float))); + + //// LogicComponent + + QObject::connect(m_logicComponent, SIGNAL(frameUpdate(float)), + q, SLOT(_q_onFrameUpdate(float))); + + q->addComponent(m_logicComponent); + q->addComponent(m_axisActionHandler); +} + +void QFirstPersonCameraControllerPrivate::_q_onFrameUpdate(float dt) +{ + if (m_camera != Q_NULLPTR) { + m_camera->translate(m_vxyz * dt); + if (m_leftMouseButtonPressed) { + m_camera->pan(m_lookSpeed * m_rxyz.x() * dt, m_firstPersonUp); + m_camera->pan(m_lookSpeed * m_rxyz.y() * dt); + } + } +} + +void QFirstPersonCameraControllerPrivate::_q_onAxisValueChanged(QString name, float value) +{ + if (name == QStringLiteral("RX")) + m_rxyz.setX(value); + else if (name == QStringLiteral("RY")) + m_rxyz.setY(value); + else if (name == QStringLiteral("TX")) + m_vxyz.setX(value); + else if (name == QStringLiteral("TY")) + m_vxyz.setY(value); + else if (name == QStringLiteral("TZ")) + m_vxyz.setZ(value); +} + +void QFirstPersonCameraControllerPrivate::_q_onActionStarted(QString name) +{ + if (name == QStringLiteral("LMB")) + m_leftMouseButtonPressed = false; + else if (name == QStringLiteral("fineMotion")) + m_fineMotion = false; +} + +void QFirstPersonCameraControllerPrivate::_q_onActionFinished(QString name) +{ + if (name == QStringLiteral("LMB")) + m_leftMouseButtonPressed = true; + else if (name == QStringLiteral("fineMotion")) + m_fineMotion = true; +} + +QFirstPersonCameraController::QFirstPersonCameraController(Qt3DCore::QNode *parent) + : Qt3DCore::QEntity(*new QFirstPersonCameraControllerPrivate, parent) +{ + Q_D(QFirstPersonCameraController); + d->init(); +} + +QFirstPersonCameraController::~QFirstPersonCameraController() +{ +} + +Qt3DCore::QCamera *QFirstPersonCameraController::camera() const +{ + Q_D(const QFirstPersonCameraController); + return d->m_camera; +} + +float QFirstPersonCameraController::linearSpeed() const +{ + Q_D(const QFirstPersonCameraController); + return d->m_linearSpeed; +} + +float QFirstPersonCameraController::lookSpeed() const +{ + Q_D(const QFirstPersonCameraController); + return d->m_lookSpeed; +} + +void QFirstPersonCameraController::setCamera(Qt3DCore::QCamera *camera) +{ + Q_D(QFirstPersonCameraController); + if (d->m_camera != camera) { + d->m_camera = camera; + emit cameraChanged(); + } +} + +void QFirstPersonCameraController::setLinearSpeed(float linearSpeed) +{ + Q_D(QFirstPersonCameraController); + if (d->m_linearSpeed != linearSpeed) { + d->m_linearSpeed = linearSpeed; + emit linearSpeedChanged(); + } +} + +void QFirstPersonCameraController::setLookSpeed(float lookSpeed) +{ + Q_D(QFirstPersonCameraController); + if (d->m_lookSpeed != lookSpeed) { + d->m_lookSpeed = lookSpeed; + emit lookSpeedChanged(); + } +} + +} // Qt3DInput + +QT_END_NAMESPACE + +#include "moc_qfirstpersoncameracontroller.cpp" diff --git a/examples/qt3d/examples-common/qfirstpersoncameracontroller.h b/examples/qt3d/examples-common/qfirstpersoncameracontroller.h new file mode 100644 index 000000000..b1755d7d4 --- /dev/null +++ b/examples/qt3d/examples-common/qfirstpersoncameracontroller.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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$ +** +****************************************************************************/ + +#ifndef QT3DINPUT_QFIRSTPERSONCAMERACONTROLLER_H +#define QT3DINPUT_QFIRSTPERSONCAMERACONTROLLER_H + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { +class QCamera; +} + +namespace Qt3DInput { + +class QFirstPersonCameraControllerPrivate; + +class QFirstPersonCameraController : public Qt3DCore::QEntity +{ + Q_OBJECT + Q_PROPERTY(Qt3DCore::QCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged) + Q_PROPERTY(float linearSpeed READ linearSpeed WRITE setLinearSpeed NOTIFY linearSpeedChanged) + Q_PROPERTY(float lookSpeed READ lookSpeed WRITE setLookSpeed NOTIFY lookSpeedChanged) + +public: + explicit QFirstPersonCameraController(Qt3DCore::QNode *parent = Q_NULLPTR); + ~QFirstPersonCameraController(); + + Qt3DCore::QCamera *camera() const; + float linearSpeed() const; + float lookSpeed() const; + + void setCamera(Qt3DCore::QCamera *camera); + void setLinearSpeed(float linearSpeed); + void setLookSpeed(float lookSpeed); + +Q_SIGNALS: + void cameraChanged(); + void linearSpeedChanged(); + void lookSpeedChanged(); + +private: + Q_DECLARE_PRIVATE(QFirstPersonCameraController) + Q_PRIVATE_SLOT(d_func(), void _q_onFrameUpdate(float)) + Q_PRIVATE_SLOT(d_func(), void _q_onAxisValueChanged(QString, float)) + Q_PRIVATE_SLOT(d_func(), void _q_onActionStarted(QString)) + Q_PRIVATE_SLOT(d_func(), void _q_onActionFinished(QString)) +}; + +} // Qt3DInput + +QT_END_NAMESPACE + +#endif // QT3DINPUT_QFIRSTPERSONCAMERACONTROLLER_H diff --git a/examples/qt3d/examples-common/qfirstpersoncameracontroller_p.h b/examples/qt3d/examples-common/qfirstpersoncameracontroller_p.h new file mode 100644 index 000000000..985b9f536 --- /dev/null +++ b/examples/qt3d/examples-common/qfirstpersoncameracontroller_p.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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$ +** +****************************************************************************/ + +#ifndef QT3DINPUT_QFIRSTPERSONCAMERACONTROLLER_P_H +#define QT3DINPUT_QFIRSTPERSONCAMERACONTROLLER_P_H + +#include +#include +#include "qfirstpersoncameracontroller.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { +class QCamera; +} + +namespace Qt3DLogic { +class QLogicComponent; +} + +namespace Qt3DInput { + +class QKeyboardController; +class QMouseController; +class QLogicalDevice; +class QAction; +class QActionInput; +class QAxis; +class QAxisInput; +class QAxisActionHandler; + +class QFirstPersonCameraControllerPrivate : public Qt3DCore::QEntityPrivate +{ +public: + QFirstPersonCameraControllerPrivate(); + + void init(); + + Qt3DCore::QCamera *m_camera; + QAction *m_leftMouseButtonAction; + QAction *m_fineMotionAction; + QAxis *m_rxAxis; + QAxis *m_ryAxis; + QAxis *m_txAxis; + QAxis *m_tyAxis; + QAxis *m_tzAxis; + QActionInput *m_leftMouseButtonInput; + QActionInput *m_fineMotionKeyInput; + QAxisInput *m_mouseRxInput; + QAxisInput *m_mouseRyInput; + QAxisInput *m_keyboardTxPosInput; + QAxisInput *m_keyboardTyPosInput; + QAxisInput *m_keyboardTzPosInput; + QAxisInput *m_keyboardTxNegInput; + QAxisInput *m_keyboardTyNegInput; + QAxisInput *m_keyboardTzNegInput; + QKeyboardController *m_keyboardController; + QMouseController *m_mouseController; + QLogicalDevice *m_logicalDevice; + QAxisActionHandler *m_axisActionHandler; + Qt3DLogic::QLogicComponent *m_logicComponent; + float m_linearSpeed; + float m_lookSpeed; + QVector3D m_vxyz; + bool m_fineMotion; + QVector3D m_rxyz; + bool m_leftMouseButtonPressed; + QVector3D m_firstPersonUp; + + void _q_onFrameUpdate(float); + void _q_onAxisValueChanged(QString, float); + void _q_onActionStarted(QString); + void _q_onActionFinished(QString); + + Q_DECLARE_PUBLIC(QFirstPersonCameraController) +}; + +} // Qt3DInput + +QT_END_NAMESPACE + +#endif // QT3DINPUT_QFIRSTPERSONCAMERACONTROLLER_P_H diff --git a/examples/qt3d/examples-common/qt3dquickwindow.cpp b/examples/qt3d/examples-common/qt3dquickwindow.cpp new file mode 100644 index 000000000..27f2ee5ef --- /dev/null +++ b/examples/qt3d/examples-common/qt3dquickwindow.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 "qt3dquickwindow.h" +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +Qt3DQuickWindow::Qt3DQuickWindow(QWindow *parent) + : QQuickWindow(parent) + , m_engine(new Qt3DCore::Quick::QQmlAspectEngine) + , m_renderAspect(new Qt3DRender::QRenderAspect) + , m_inputAspect(new Qt3DInput::QInputAspect) + , m_logicAspect(new Qt3DLogic::QLogicAspect) + , m_initialized(false) +{ + setSurfaceType(QSurface::OpenGLSurface); + + resize(1024, 768); + + QSurfaceFormat format; + if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { + format.setVersion(4, 3); + format.setProfile(QSurfaceFormat::CoreProfile); + } + format.setDepthBufferSize(24); + format.setSamples(4); + format.setStencilBufferSize(8); + setFormat(format); + create(); + + m_engine->aspectEngine()->registerAspect(m_renderAspect); + m_engine->aspectEngine()->registerAspect(m_inputAspect); + m_engine->aspectEngine()->registerAspect(m_logicAspect); +} + +Qt3DQuickWindow::~Qt3DQuickWindow() +{ +} + +void Qt3DQuickWindow::registerAspect(Qt3DCore::QAbstractAspect *aspect) +{ + Q_ASSERT(!isVisible()); + m_engine->aspectEngine()->registerAspect(aspect); +} + +void Qt3DQuickWindow::registerAspect(const QString &name) +{ + Q_ASSERT(!isVisible()); + m_engine->aspectEngine()->registerAspect(name); +} + +void Qt3DQuickWindow::setSource(const QUrl &source) +{ + m_source = source; +} + +Qt3DCore::Quick::QQmlAspectEngine *Qt3DQuickWindow::engine() const +{ + return m_engine.data(); +} + +void Qt3DQuickWindow::showEvent(QShowEvent *e) +{ + if (!m_initialized) { + + // TODO: Get rid of this + QVariantMap data; + data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast(this))); + data.insert(QStringLiteral("eventSource"), QVariant::fromValue(this)); + m_engine->aspectEngine()->setData(data); + + m_engine->setSource(m_source); + + // Set the QQmlIncubationController on the window + // to benefit from asynchronous incubation + m_engine->qmlEngine()->setIncubationController(QQuickWindow::incubationController()); + + m_initialized = true; + } + QQuickWindow::showEvent(e); +} + +QT_END_NAMESPACE diff --git a/examples/qt3d/examples-common/qt3dquickwindow.h b/examples/qt3d/examples-common/qt3dquickwindow.h new file mode 100644 index 000000000..85009de20 --- /dev/null +++ b/examples/qt3d/examples-common/qt3dquickwindow.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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$ +** +****************************************************************************/ + +#ifndef QT3DQUICKWINDOW_H +#define QT3DQUICKWINDOW_H + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { +class QAbstractAspect; +namespace Quick { +class QQmlAspectEngine; +} +} + +namespace Qt3DRender { +class QRenderAspect; +} + +namespace Qt3DInput { +class QInputAspect; +} + +namespace Qt3DLogic { +class QLogicAspect; +} + +class Qt3DQuickWindow : public QQuickWindow +{ + Q_OBJECT +public: + Qt3DQuickWindow(QWindow *parent = Q_NULLPTR); + ~Qt3DQuickWindow(); + + void registerAspect(Qt3DCore::QAbstractAspect *aspect); + void registerAspect(const QString &name); + + void setSource(const QUrl &source); + Qt3DCore::Quick::QQmlAspectEngine *engine() const; + +protected: + void showEvent(QShowEvent *e) Q_DECL_OVERRIDE; + +private: + QScopedPointer m_engine; + + // Aspects + Qt3DRender::QRenderAspect *m_renderAspect; + Qt3DInput::QInputAspect *m_inputAspect; + Qt3DLogic::QLogicAspect *m_logicAspect; + + QUrl m_source; + bool m_initialized; +}; + +QT_END_NAMESPACE + +#endif // QT3DQUICKWINDOW_H diff --git a/examples/qt3d/examples-common/qt3dwindow.cpp b/examples/qt3d/examples-common/qt3dwindow.cpp new file mode 100644 index 000000000..9575424a8 --- /dev/null +++ b/examples/qt3d/examples-common/qt3dwindow.cpp @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 "qt3dwindow.h" + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +Qt3DWindow::Qt3DWindow(QScreen *screen) + : QWindow(screen) + , m_aspectEngine(new Qt3DCore::QAspectEngine) + , m_renderAspect(new Qt3DRender::QRenderAspect) + , m_inputAspect(new Qt3DInput::QInputAspect) + , m_logicAspect(new Qt3DLogic::QLogicAspect) + , m_frameGraph(nullptr) + , m_defaultCamera(new Qt3DCore::QCamera) + , m_root(new Qt3DCore::QEntity) + , m_userRoot(nullptr) + , m_initialized(false) +{ + setSurfaceType(QSurface::OpenGLSurface); + + resize(1024, 768); + + QSurfaceFormat format; + if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { + format.setVersion(4, 3); + format.setProfile(QSurfaceFormat::CoreProfile); + } + format.setDepthBufferSize(24); + format.setSamples(4); + format.setStencilBufferSize(8); + setFormat(format); + create(); + + m_aspectEngine->registerAspect(m_renderAspect); + m_aspectEngine->registerAspect(m_inputAspect); + m_aspectEngine->registerAspect(m_logicAspect); +} + +Qt3DWindow::Qt3DWindow(QWindow *parent) + : QWindow(parent) + , m_aspectEngine(new Qt3DCore::QAspectEngine) + , m_renderAspect(new Qt3DRender::QRenderAspect) + , m_inputAspect(new Qt3DInput::QInputAspect) + , m_logicAspect(new Qt3DLogic::QLogicAspect) + , m_frameGraph(nullptr) + , m_defaultCamera(new Qt3DCore::QCamera) + , m_root(new Qt3DCore::QEntity) + , m_userRoot(nullptr) + , m_initialized(false) +{ + setSurfaceType(QSurface::OpenGLSurface); + + resize(1024, 768); + + QSurfaceFormat format; + if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { + format.setVersion(4, 3); + format.setProfile(QSurfaceFormat::CoreProfile); + } + format.setDepthBufferSize(24); + format.setSamples(4); + format.setStencilBufferSize(8); + setFormat(format); + create(); + + m_aspectEngine->registerAspect(m_renderAspect); + m_aspectEngine->registerAspect(m_inputAspect); + m_aspectEngine->registerAspect(m_logicAspect);} + +Qt3DWindow::~Qt3DWindow() +{ +} + +void Qt3DWindow::registerAspect(Qt3DCore::QAbstractAspect *aspect) +{ + Q_ASSERT(!isVisible()); + m_aspectEngine->registerAspect(aspect); +} + +void Qt3DWindow::registerAspect(const QString &name) +{ + Q_ASSERT(!isVisible()); + m_aspectEngine->registerAspect(name); +} + +void Qt3DWindow::setRootEntity(Qt3DCore::QEntity *root) +{ + Q_ASSERT(!isVisible()); + m_userRoot = root; +} + +Qt3DCore::QCamera *Qt3DWindow::camera() const +{ + return m_defaultCamera; +} + +void Qt3DWindow::showEvent(QShowEvent *e) +{ + if (!m_initialized) { + if (m_userRoot != nullptr) + m_userRoot->setParent(m_root); + + if (m_frameGraph == nullptr) { + m_frameGraph = new Qt3DRender::QFrameGraph; + Qt3DRender::QForwardRenderer *forwardRenderer = new Qt3DRender::QForwardRenderer; + forwardRenderer->setCamera(m_defaultCamera); + m_frameGraph->setActiveFrameGraph(forwardRenderer); + } + + // TODO: Get rid of this + QVariantMap data; + data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast(this))); + data.insert(QStringLiteral("eventSource"), QVariant::fromValue(this)); + m_aspectEngine->setData(data); + + m_root->addComponent(m_frameGraph); + m_aspectEngine->setRootEntity(m_root); + + // TODO: Get rid of this too + m_inputAspect->setCamera(m_defaultCamera); + + m_initialized = true; + } + + QWindow::showEvent(e); +} + +void Qt3DWindow::resizeEvent(QResizeEvent *) +{ + m_defaultCamera->setAspectRatio(float(width()) / float(height())); +} + +QT_END_NAMESPACE diff --git a/examples/qt3d/examples-common/qt3dwindow.h b/examples/qt3d/examples-common/qt3dwindow.h new file mode 100644 index 000000000..b42e3d81c --- /dev/null +++ b/examples/qt3d/examples-common/qt3dwindow.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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$ +** +****************************************************************************/ + +#ifndef QT3DWINDOW_H +#define QT3DWINDOW_H + +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { +class QAspectEngine; +class QCamera; +class QEntity; +} + +namespace Qt3DRender { +class QFrameGraph; +class QRenderAspect; +} + +namespace Qt3DInput { +class QInputAspect; +} + +namespace Qt3DLogic { +class QLogicAspect; +} + +class Qt3DWindow : public QWindow +{ + Q_OBJECT +public: + Qt3DWindow(QScreen *screen = nullptr); + Qt3DWindow(QWindow *parent); + ~Qt3DWindow(); + + void registerAspect(Qt3DCore::QAbstractAspect *aspect); + void registerAspect(const QString &name); + + void setRootEntity(Qt3DCore::QEntity *root); + + Qt3DCore::QCamera *camera() const; + +public Q_SLOTS: + +Q_SIGNALS: + +protected: + void showEvent(QShowEvent *e) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; + +private: + QScopedPointer m_aspectEngine; + + // Aspects + Qt3DRender::QRenderAspect *m_renderAspect; + Qt3DInput::QInputAspect *m_inputAspect; + Qt3DLogic::QLogicAspect *m_logicAspect; + + // Renderer configuration + Qt3DRender::QFrameGraph *m_frameGraph; + Qt3DCore::QCamera *m_defaultCamera; + + // Input configuration + + // Logic configuration + + // Scene + Qt3DCore::QEntity *m_root; + Qt3DCore::QEntity *m_userRoot; + + bool m_initialized; +}; + +QT_END_NAMESPACE + +#endif // QT3DWINDOW_H diff --git a/examples/qt3d/examples.pri b/examples/qt3d/examples.pri index 5f67884c0..1f58b0f02 100644 --- a/examples/qt3d/examples.pri +++ b/examples/qt3d/examples.pri @@ -1,8 +1,10 @@ TEMPLATE = app -INCLUDEPATH += $$PWD/common -SOURCES += $$PWD/common/window.cpp -HEADERS += $$PWD/common/window.h +include(./examples-common/examples-common.pri) + +#INCLUDEPATH += $$PWD/common +#SOURCES += $$PWD/common/window.cpp +#HEADERS += $$PWD/common/window.h target.path = $$[QT_INSTALL_EXAMPLES]/qt3d/$$TARGET INSTALLS += target diff --git a/examples/qt3d/gltf/main.cpp b/examples/qt3d/gltf/main.cpp index 51bde76a6..cf50473ae 100644 --- a/examples/qt3d/gltf/main.cpp +++ b/examples/qt3d/gltf/main.cpp @@ -34,31 +34,16 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include "qt3dquickwindow.h" #include #include -#include int main(int argc, char* argv[]) { + Qt3DQuickWindow view; 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - - engine.setSource(QUrl("qrc:/main.qml")); + view.setSource(QUrl("qrc:/main.qml")); view.show(); const bool isES = QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES diff --git a/examples/qt3d/gltf/main.qml b/examples/qt3d/gltf/main.qml index c244c24f8..f5c280af0 100644 --- a/examples/qt3d/gltf/main.qml +++ b/examples/qt3d/gltf/main.qml @@ -53,9 +53,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 10.0, 0.0 ) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } FrameGraph { id : framegraph diff --git a/examples/qt3d/gooch-qml/main.cpp b/examples/qt3d/gooch-qml/main.cpp index c84ba5dd7..3fb22d7b5 100644 --- a/examples/qt3d/gooch-qml/main.cpp +++ b/examples/qt3d/gooch-qml/main.cpp @@ -34,31 +34,19 @@ ** ****************************************************************************/ -#include -#include +#include "qt3dquickwindow.h" #include -#include - #include -#include +#include +#include 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()); - - // 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); + Qt3DQuickWindow view; + // Expose the window as a context property so we can set the aspect ratio + view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); + view.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 index a3c340501..c6c2c3277 100644 --- a/examples/qt3d/gooch-qml/main.qml +++ b/examples/qt3d/gooch-qml/main.qml @@ -41,7 +41,7 @@ import QtQuick 2.2 as QQ2 Entity { id: sceneRoot - Configuration { controlledCamera: mainCamera } + FirstPersonCameraController { camera: mainCamera } components: [ FrameGraph { ForwardRenderer { camera: mainCamera } } diff --git a/examples/qt3d/instanced-arrays-qml/main.cpp b/examples/qt3d/instanced-arrays-qml/main.cpp index ca100d238..44d6afcfe 100644 --- a/examples/qt3d/instanced-arrays-qml/main.cpp +++ b/examples/qt3d/instanced-arrays-qml/main.cpp @@ -35,32 +35,20 @@ ****************************************************************************/ #include "instancebuffer.h" -#include -#include -#include +#include "qt3dquickwindow.h" #include -#include +#include +#include #include 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); + Qt3DQuickWindow view; InstanceBuffer buffer; - engine.qmlEngine()->rootContext()->setContextProperty("_instanceBuffer", &buffer); - - engine.setSource(QUrl("qrc:/main.qml")); - + view.engine()->qmlEngine()->rootContext()->setContextProperty("_instanceBuffer", &buffer); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/instanced-arrays-qml/main.qml b/examples/qt3d/instanced-arrays-qml/main.qml index 90344c1d0..4e9d7e144 100644 --- a/examples/qt3d/instanced-arrays-qml/main.qml +++ b/examples/qt3d/instanced-arrays-qml/main.qml @@ -53,9 +53,7 @@ Entity { viewCenter: Qt.vector3d(9.5, 0.5, 0.0) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } components: [ FrameGraph { diff --git a/examples/qt3d/keyboardinput-qml/main.cpp b/examples/qt3d/keyboardinput-qml/main.cpp index 072fef361..424aae52f 100644 --- a/examples/qt3d/keyboardinput-qml/main.cpp +++ b/examples/qt3d/keyboardinput-qml/main.cpp @@ -34,28 +34,15 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include #include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); - + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/keyboardinput-qml/main.qml b/examples/qt3d/keyboardinput-qml/main.qml index e943f190c..96cf9148e 100644 --- a/examples/qt3d/keyboardinput-qml/main.qml +++ b/examples/qt3d/keyboardinput-qml/main.qml @@ -53,7 +53,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { controlledCamera: camera } + FirstPersonCameraController { camera: camera } components: FrameGraph { activeFrameGraph: ForwardRenderer { diff --git a/examples/qt3d/lights/main.cpp b/examples/qt3d/lights/main.cpp index eb4a0f5b0..de3f5bbca 100644 --- a/examples/qt3d/lights/main.cpp +++ b/examples/qt3d/lights/main.cpp @@ -34,26 +34,15 @@ ** ****************************************************************************/ -#include -#include -#include -#include +#include "qt3dquickwindow.h" #include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/lights/main.qml b/examples/qt3d/lights/main.qml index 99bc1147d..1cfeb0cd4 100644 --- a/examples/qt3d/lights/main.qml +++ b/examples/qt3d/lights/main.qml @@ -59,9 +59,7 @@ Entity viewCenter: Qt.vector3d( 0.0, -10.0, -1.0 ) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } Entity { id: sun diff --git a/examples/qt3d/loader-qml/main.cpp b/examples/qt3d/loader-qml/main.cpp index 1a538e49d..d6443402f 100644 --- a/examples/qt3d/loader-qml/main.cpp +++ b/examples/qt3d/loader-qml/main.cpp @@ -34,28 +34,15 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include "qt3dquickwindow.h" #include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); - + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/loader-qml/main.qml b/examples/qt3d/loader-qml/main.qml index b3fbbb62a..8852d5bca 100644 --- a/examples/qt3d/loader-qml/main.qml +++ b/examples/qt3d/loader-qml/main.qml @@ -53,9 +53,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } components: [ FrameGraph { diff --git a/examples/qt3d/materials/main.cpp b/examples/qt3d/materials/main.cpp index e2eb9aa9c..89bb96736 100644 --- a/examples/qt3d/materials/main.cpp +++ b/examples/qt3d/materials/main.cpp @@ -34,31 +34,20 @@ ** ****************************************************************************/ -#include -#include -#include +#include "qt3dquickwindow.h" #include - #include -#include +#include +#include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - - engine.aspectEngine()->setData(data); - // Expose the window as a context property so we can set the aspect ratio - engine.qmlEngine()->rootContext()->setContextProperty("_window", &view); - engine.setSource(QUrl("qrc:/main.qml")); + // Expose the window as a context property so we can set the aspect ratio + view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/materials/main.qml b/examples/qt3d/materials/main.qml index de759209b..a470e2415 100644 --- a/examples/qt3d/materials/main.qml +++ b/examples/qt3d/materials/main.qml @@ -59,9 +59,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 3.5, 0.0 ) } - Configuration { - controlledCamera: mainCamera - } + FirstPersonCameraController { camera: mainCamera } PhongMaterial { id: redAdsMaterial diff --git a/examples/qt3d/mouseinput-qml/main.cpp b/examples/qt3d/mouseinput-qml/main.cpp index c102cfa2d..dfbbdc7b8 100644 --- a/examples/qt3d/mouseinput-qml/main.cpp +++ b/examples/qt3d/mouseinput-qml/main.cpp @@ -34,30 +34,15 @@ ** ****************************************************************************/ +#include "qt3dquickwindow.h" #include -#include -#include -#include -#include - int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - - engine.setSource(QUrl(QStringLiteral("qrc:/main.qml"))); - + view.setSource(QUrl(QStringLiteral("qrc:/main.qml"))); view.show(); return app.exec(); diff --git a/examples/qt3d/mouseinput-qml/main.qml b/examples/qt3d/mouseinput-qml/main.qml index b39b72ab5..8158e18f7 100644 --- a/examples/qt3d/mouseinput-qml/main.qml +++ b/examples/qt3d/mouseinput-qml/main.qml @@ -53,9 +53,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } components: FrameGraph { ForwardRenderer { diff --git a/examples/qt3d/multiviewport/main.cpp b/examples/qt3d/multiviewport/main.cpp index 254254111..30645cb89 100644 --- a/examples/qt3d/multiviewport/main.cpp +++ b/examples/qt3d/multiviewport/main.cpp @@ -34,26 +34,14 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include #include int main(int ac, char **av) { QGuiApplication app(ac, av); - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); + Qt3DQuickWindow view; + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/picking-qml/main.cpp b/examples/qt3d/picking-qml/main.cpp index d8d66801e..f6388552c 100644 --- a/examples/qt3d/picking-qml/main.cpp +++ b/examples/qt3d/picking-qml/main.cpp @@ -34,32 +34,19 @@ ** ****************************************************************************/ -#include -#include -#include -#include +#include "qt3dquickwindow.h" +#include #include #include int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.qmlEngine()->rootContext()->setContextProperty("_view", &view); - - engine.setSource(QUrl(QStringLiteral("qrc:/main.qml"))); - + view.engine()->qmlEngine()->rootContext()->setContextProperty("_view", &view); + view.setSource(QUrl(QStringLiteral("qrc:/main.qml"))); view.show(); return app.exec(); diff --git a/examples/qt3d/picking-qml/main.qml b/examples/qt3d/picking-qml/main.qml index ff632efed..2c9e7a955 100644 --- a/examples/qt3d/picking-qml/main.qml +++ b/examples/qt3d/picking-qml/main.qml @@ -54,9 +54,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } components: FrameGraph { ForwardRenderer { diff --git a/examples/qt3d/planets-qml/SolarSystem.qml b/examples/qt3d/planets-qml/SolarSystem.qml index eb8611aa5..a5a0fbfef 100644 --- a/examples/qt3d/planets-qml/SolarSystem.qml +++ b/examples/qt3d/planets-qml/SolarSystem.qml @@ -124,9 +124,7 @@ Entity { viewCenter: Qt.vector3d( xLookAtOffset, yLookAtOffset, zLookAtOffset ) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } components: [ PlanetFrameGraph { diff --git a/examples/qt3d/plasma/main.cpp b/examples/qt3d/plasma/main.cpp index bfd3cfa64..13f200e4b 100644 --- a/examples/qt3d/plasma/main.cpp +++ b/examples/qt3d/plasma/main.cpp @@ -34,30 +34,20 @@ ** ****************************************************************************/ -#include -#include +#include "qt3dquickwindow.h" #include - #include -#include +#include +#include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); - - Window view; - Qt3DCore::Quick::QQmlAspectEngine engine; - - engine.aspectEngine()->registerAspect(new Qt3DRender::QRenderAspect()); + Qt3DQuickWindow view; // 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); - + view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/playground-qml/main.cpp b/examples/qt3d/playground-qml/main.cpp index 7db0725ce..e77089ed9 100644 --- a/examples/qt3d/playground-qml/main.cpp +++ b/examples/qt3d/playground-qml/main.cpp @@ -34,10 +34,7 @@ ** ****************************************************************************/ -#include -#include -#include -#include +#include #include #include @@ -45,17 +42,8 @@ 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); + Qt3DQuickWindow view; + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/playground-qml/main.qml b/examples/qt3d/playground-qml/main.qml index 852fe03c4..0773d6198 100644 --- a/examples/qt3d/playground-qml/main.qml +++ b/examples/qt3d/playground-qml/main.qml @@ -64,9 +64,7 @@ Entity { components: [external_forward_renderer, keyboardInput] - Configuration { - controlledCamera: mainView.camera - } + FirstPersonCameraController { camera: mainView.camera } MainView { id: mainView diff --git a/examples/qt3d/qt3d.pro b/examples/qt3d/qt3d.pro index afba0a352..a46c3a52c 100644 --- a/examples/qt3d/qt3d.pro +++ b/examples/qt3d/qt3d.pro @@ -1,6 +1,7 @@ TEMPLATE = subdirs SUBDIRS += \ + examples-common \ playground-qml \ simple-qml \ simple-cpp \ @@ -47,6 +48,7 @@ SUBDIRS += \ lights \ compute-particles + # qmake seems to break in some CI configurations, disable this for now #SUBDIRS += qgltf @@ -54,3 +56,9 @@ SUBDIRS += \ #SUBDIRS += qt3d qtHaveModule(widgets): SUBDIRS += assimp-cpp \ basicshapes-cpp + +for(subdir, SUBDIRS) { + !equals(subdir, examples-common) { + $${subdir}.depends += examples-common + } +} diff --git a/examples/qt3d/scene3d-loader/AnimatedEntity.qml b/examples/qt3d/scene3d-loader/AnimatedEntity.qml index ec7cd7fc8..8f488dde3 100644 --- a/examples/qt3d/scene3d-loader/AnimatedEntity.qml +++ b/examples/qt3d/scene3d-loader/AnimatedEntity.qml @@ -55,9 +55,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } components: [ FrameGraph { diff --git a/examples/qt3d/scene3d/AnimatedEntity.qml b/examples/qt3d/scene3d/AnimatedEntity.qml index ea0167220..ba7cf4ff1 100644 --- a/examples/qt3d/scene3d/AnimatedEntity.qml +++ b/examples/qt3d/scene3d/AnimatedEntity.qml @@ -55,9 +55,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } components: [ FrameGraph { diff --git a/examples/qt3d/shadow-map-qml/main.cpp b/examples/qt3d/shadow-map-qml/main.cpp index f455f8d66..3f7573e4f 100644 --- a/examples/qt3d/shadow-map-qml/main.cpp +++ b/examples/qt3d/shadow-map-qml/main.cpp @@ -34,11 +34,8 @@ ** ****************************************************************************/ -#include -#include -#include +#include #include - #include #include #include @@ -47,19 +44,10 @@ int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); - Window view; - Qt3DCore::Quick::QQmlAspectEngine engine; - + Qt3DQuickWindow view; view.resize(1600, 800); - engine.aspectEngine()->registerAspect(new Qt3DRender::QRenderAspect()); - engine.aspectEngine()->registerAspect(new Qt3DInput::QInputAspect()); - QVariantMap data; - data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.qmlEngine()->rootContext()->setContextProperty("_window", &view); - engine.setSource(QUrl("qrc:/main.qml")); - + view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/shadow-map-qml/main.qml b/examples/qt3d/shadow-map-qml/main.qml index 37340053a..d42401f60 100644 --- a/examples/qt3d/shadow-map-qml/main.qml +++ b/examples/qt3d/shadow-map-qml/main.qml @@ -53,9 +53,7 @@ Entity { upVector: Qt.vector3d(0.0, 1.0, 0.0) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } ShadowMapLight { id: light diff --git a/examples/qt3d/simple-cpp/main.cpp b/examples/qt3d/simple-cpp/main.cpp index ac4525b02..990fd36bb 100644 --- a/examples/qt3d/simple-cpp/main.cpp +++ b/examples/qt3d/simple-cpp/main.cpp @@ -51,98 +51,16 @@ #include #include #include -#include #include -class OrbitTransformController : public QObject -{ - Q_OBJECT - Q_PROPERTY(Qt3DCore::QTransform* target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) - Q_PROPERTY(float angle READ angle WRITE setAngle NOTIFY angleChanged) - -public: - OrbitTransformController(QObject *parent = 0) - : QObject(parent) - , m_target(Q_NULLPTR) - , m_matrix() - , m_radius(1.0f) - , m_angle(0.0f) - { - } - - void setTarget(Qt3DCore::QTransform *target) - { - if (m_target != target) { - m_target = target; - emit targetChanged(); - } - } - - Qt3DCore::QTransform *target() const { return m_target; } - - void setRadius(float radius) - { - if (!qFuzzyCompare(radius, m_radius)) { - m_radius = radius; - updateMatrix(); - emit radiusChanged(); - } - } - - float radius() const { return m_radius; } - - void setAngle(float angle) - { - if (!qFuzzyCompare(angle, m_angle)) { - m_angle = angle; - updateMatrix(); - emit angleChanged(); - } - } - - float angle() const { return m_angle; } - -signals: - void targetChanged(); - void radiusChanged(); - void angleChanged(); - -protected: - void updateMatrix() - { - m_matrix.setToIdentity(); - m_matrix.rotate(m_angle, QVector3D(0.0f, 1.0f, 0.0f)); - m_matrix.translate(m_radius, 0.0f, 0.0f); - m_target->setMatrix(m_matrix); - } - -private: - Qt3DCore::QTransform *m_target; - QMatrix4x4 m_matrix; - float m_radius; - float m_angle; -}; +#include "qt3dwindow.h" +#include "orbittransformcontroller.h" -int main(int argc, char* argv[]) +Qt3DCore::QEntity *createScene() { - QGuiApplication app(argc, argv); - Qt3DRender::QWindow view; - Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect; - view.registerAspect(input); - // Root entity - Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); - - // Camera - Qt3DCore::QCamera *cameraEntity = view.defaultCamera(); - - cameraEntity->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f); - cameraEntity->setPosition(QVector3D(0, 0, 40.0f)); - cameraEntity->setUpVector(QVector3D(0, 1, 0)); - cameraEntity->setViewCenter(QVector3D(0, 0, 0)); - input->setCamera(cameraEntity); + Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity; // Material Qt3DRender::QMaterial *material = new Qt3DRender::QPhongMaterial(rootEntity); @@ -186,10 +104,22 @@ int main(int argc, char* argv[]) sphereEntity->addComponent(sphereTransform); sphereEntity->addComponent(material); - view.setRootEntity(rootEntity); + return rootEntity; +} + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + Qt3DWindow view; + + // Camera + Qt3DCore::QCamera *camera = view.camera(); + camera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f); + camera->setPosition(QVector3D(0, 0, 40.0f)); + + Qt3DCore::QEntity *scene = createScene(); + view.setRootEntity(scene); view.show(); return app.exec(); } - -#include "main.moc" diff --git a/examples/qt3d/simple-cpp/orbittransformcontroller.cpp b/examples/qt3d/simple-cpp/orbittransformcontroller.cpp new file mode 100644 index 000000000..a7d66837b --- /dev/null +++ b/examples/qt3d/simple-cpp/orbittransformcontroller.cpp @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Copyright (C) 2016 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$ +** +****************************************************************************/ + +#include "orbittransformcontroller.h" + +#include + +QT_BEGIN_NAMESPACE + +OrbitTransformController::OrbitTransformController(QObject *parent) + : QObject(parent) + , m_target(Q_NULLPTR) + , m_matrix() + , m_radius(1.0f) + , m_angle(0.0f) +{ +} + +void OrbitTransformController::setTarget(Qt3DCore::QTransform *target) +{ + if (m_target != target) { + m_target = target; + emit targetChanged(); + } +} + +Qt3DCore::QTransform *OrbitTransformController::target() const +{ + return m_target; +} + +void OrbitTransformController::setRadius(float radius) +{ + if (!qFuzzyCompare(radius, m_radius)) { + m_radius = radius; + updateMatrix(); + emit radiusChanged(); + } +} + +float OrbitTransformController::radius() const +{ + return m_radius; +} + +void OrbitTransformController::setAngle(float angle) +{ + if (!qFuzzyCompare(angle, m_angle)) { + m_angle = angle; + updateMatrix(); + emit angleChanged(); + } +} + +float OrbitTransformController::angle() const +{ + return m_angle; +} + +void OrbitTransformController::updateMatrix() +{ + m_matrix.setToIdentity(); + m_matrix.rotate(m_angle, QVector3D(0.0f, 1.0f, 0.0f)); + m_matrix.translate(m_radius, 0.0f, 0.0f); + m_target->setMatrix(m_matrix); +} + +QT_END_NAMESPACE diff --git a/examples/qt3d/simple-cpp/orbittransformcontroller.h b/examples/qt3d/simple-cpp/orbittransformcontroller.h new file mode 100644 index 000000000..87171c8ed --- /dev/null +++ b/examples/qt3d/simple-cpp/orbittransformcontroller.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Copyright (C) 2016 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$ +** +****************************************************************************/ + +#ifndef ORBITTRANSFORMCONTROLLER_H +#define ORBITTRANSFORMCONTROLLER_H + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3DCore { +class QTransform; +} + +class OrbitTransformController : public QObject +{ + Q_OBJECT + Q_PROPERTY(Qt3DCore::QTransform* target READ target WRITE setTarget NOTIFY targetChanged) + Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) + Q_PROPERTY(float angle READ angle WRITE setAngle NOTIFY angleChanged) + +public: + OrbitTransformController(QObject *parent = 0); + + void setTarget(Qt3DCore::QTransform *target); + Qt3DCore::QTransform *target() const; + + void setRadius(float radius); + float radius() const; + + void setAngle(float angle); + float angle() const; + +signals: + void targetChanged(); + void radiusChanged(); + void angleChanged(); + +protected: + void updateMatrix(); + +private: + Qt3DCore::QTransform *m_target; + QMatrix4x4 m_matrix; + float m_radius; + float m_angle; +}; + +QT_END_NAMESPACE + +#endif // ORBITTRANSFORMCONTROLLER_H diff --git a/examples/qt3d/simple-cpp/simple-cpp.pro b/examples/qt3d/simple-cpp/simple-cpp.pro index e562663bd..db0d0d972 100644 --- a/examples/qt3d/simple-cpp/simple-cpp.pro +++ b/examples/qt3d/simple-cpp/simple-cpp.pro @@ -5,4 +5,8 @@ QT += 3dcore 3drender 3dinput SOURCES += \ - main.cpp + main.cpp \ + orbittransformcontroller.cpp + +HEADERS += \ + orbittransformcontroller.h diff --git a/examples/qt3d/simple-qml/main.cpp b/examples/qt3d/simple-qml/main.cpp index 2305a685e..04fa98212 100644 --- a/examples/qt3d/simple-qml/main.cpp +++ b/examples/qt3d/simple-qml/main.cpp @@ -34,30 +34,14 @@ ** ****************************************************************************/ -#include -#include -#include -#include -#include - +#include "qt3dquickwindow.h" #include 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()); - engine.aspectEngine()->registerAspect(new Qt3DLogic::QLogicAspect()); - QVariantMap data; - data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); - + Qt3DQuickWindow view; + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/simple-qml/main.qml b/examples/qt3d/simple-qml/main.qml index 48db34618..9d25da81a 100644 --- a/examples/qt3d/simple-qml/main.qml +++ b/examples/qt3d/simple-qml/main.qml @@ -37,6 +37,7 @@ import QtQuick 2.2 as QQ2 import Qt3D.Core 2.0 import Qt3D.Render 2.0 +import Qt3D.Input 2.0 Entity { id: sceneRoot @@ -53,7 +54,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - CameraController { + FirstPersonCameraController { camera: camera } diff --git a/examples/qt3d/simple-shaders-qml/main.cpp b/examples/qt3d/simple-shaders-qml/main.cpp index a308bfacc..c83572aa7 100644 --- a/examples/qt3d/simple-shaders-qml/main.cpp +++ b/examples/qt3d/simple-shaders-qml/main.cpp @@ -34,28 +34,15 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include "qt3dquickwindow.h" #include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); - + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/simple-shaders-qml/main.qml b/examples/qt3d/simple-shaders-qml/main.qml index 991991e8f..b51a25712 100644 --- a/examples/qt3d/simple-shaders-qml/main.qml +++ b/examples/qt3d/simple-shaders-qml/main.qml @@ -53,9 +53,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } components: [ FrameGraph { diff --git a/examples/qt3d/skybox/main.cpp b/examples/qt3d/skybox/main.cpp index 54c4b6650..93a2653c7 100644 --- a/examples/qt3d/skybox/main.cpp +++ b/examples/qt3d/skybox/main.cpp @@ -34,30 +34,14 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include "qt3dquickwindow.h" #include -#include 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - - engine.setSource(QUrl("qrc:/main.qml")); + Qt3DQuickWindow view; + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); } diff --git a/examples/qt3d/skybox/main.qml b/examples/qt3d/skybox/main.qml index 46551da0d..e8cfdb2cf 100644 --- a/examples/qt3d/skybox/main.qml +++ b/examples/qt3d/skybox/main.qml @@ -66,9 +66,7 @@ Entity { extension: ".webp" } - Configuration { - controlledCamera: basicCamera - } + FirstPersonCameraController { camera: basicCamera } Entity { components: [ diff --git a/examples/qt3d/tessellation-modes/main.cpp b/examples/qt3d/tessellation-modes/main.cpp index 427058be3..d835da374 100644 --- a/examples/qt3d/tessellation-modes/main.cpp +++ b/examples/qt3d/tessellation-modes/main.cpp @@ -35,40 +35,29 @@ ****************************************************************************/ #include "tessellatedquadmesh.h" - -#include -#include -#include +#include "qt3dquickwindow.h" #include - #include -#include +#include +#include +#include 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); + Qt3DQuickWindow view; // Register our custom types qmlRegisterType("Qt3D.Examples", 1, 0, "TessellatedQuadMesh"); // Expose the window as a context property so we can set the aspect ratio - engine.qmlEngine()->rootContext()->setContextProperty("_window", &view); + view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); // There should be some synchronising mechanism to make sure // the source is set after all aspects have been completely initialized // Otherwise we might encounter cases where an Aspect's QML elements have // not yet been registered - engine.setSource(QUrl("qrc:/main.qml")); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/tessellation-modes/main.qml b/examples/qt3d/tessellation-modes/main.qml index e75664364..e2b06f21f 100644 --- a/examples/qt3d/tessellation-modes/main.qml +++ b/examples/qt3d/tessellation-modes/main.qml @@ -59,9 +59,7 @@ Entity { position: Qt.vector3d( 0.0, 0.0, 10.0 ) } - Configuration { - controlledCamera: mainCamera - } + FirstPersonCameraController { camera: mainCamera } TessellatedWireframeMaterial { id: quadMaterial diff --git a/examples/qt3d/torus-qml/main.cpp b/examples/qt3d/torus-qml/main.cpp index 24dbf55d5..dfee73d8f 100644 --- a/examples/qt3d/torus-qml/main.cpp +++ b/examples/qt3d/torus-qml/main.cpp @@ -34,28 +34,14 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include #include -#include 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); + Qt3DQuickWindow view; + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/torus-qml/main.qml b/examples/qt3d/torus-qml/main.qml index 6e38318ba..fc86231d8 100644 --- a/examples/qt3d/torus-qml/main.qml +++ b/examples/qt3d/torus-qml/main.qml @@ -52,9 +52,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { - controlledCamera: camera - } + FirstPersonCameraController { camera: camera } FrameGraph { id : external_forward_renderer diff --git a/examples/qt3d/transforms-qml/main.cpp b/examples/qt3d/transforms-qml/main.cpp index c01e066fe..6fe58a8b5 100644 --- a/examples/qt3d/transforms-qml/main.cpp +++ b/examples/qt3d/transforms-qml/main.cpp @@ -34,31 +34,19 @@ ** ****************************************************************************/ -#include -#include -#include +#include "qt3dquickwindow.h" #include - -#include - +#include +#include #include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.qmlEngine()->rootContext()->setContextProperty("_view", &view); - engine.setSource(QUrl("qrc:/main.qml")); - + view.engine()->qmlEngine()->rootContext()->setContextProperty("_view", &view); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/transparency-qml-scene3d/Scene.qml b/examples/qt3d/transparency-qml-scene3d/Scene.qml index 6b9b4683d..fe782659d 100644 --- a/examples/qt3d/transparency-qml-scene3d/Scene.qml +++ b/examples/qt3d/transparency-qml-scene3d/Scene.qml @@ -53,7 +53,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { controlledCamera: camera } + FirstPersonCameraController { camera: camera } components: FrameGraph { ForwardRenderer{ camera: camera; clearColor: Qt.rgba(0.0, 0.5, 1, 1) } } diff --git a/examples/qt3d/transparency-qml/main.cpp b/examples/qt3d/transparency-qml/main.cpp index 1119d6a21..c83572aa7 100644 --- a/examples/qt3d/transparency-qml/main.cpp +++ b/examples/qt3d/transparency-qml/main.cpp @@ -34,27 +34,15 @@ ** ****************************************************************************/ -#include -#include -#include -#include - +#include "qt3dquickwindow.h" #include int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); + Qt3DQuickWindow view; - 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); - + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/transparency-qml/main.qml b/examples/qt3d/transparency-qml/main.qml index 8d104ab76..e1e394e64 100644 --- a/examples/qt3d/transparency-qml/main.qml +++ b/examples/qt3d/transparency-qml/main.qml @@ -53,7 +53,7 @@ Entity { viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 ) } - Configuration { controlledCamera: camera } + FirstPersonCameraController { camera: camera } components: FrameGraph { activeFrameGraph: ForwardRenderer{ camera: camera ; clearColor: Qt.rgba(0.0, 0.5, 1, 1) } } diff --git a/examples/qt3d/wave/main.cpp b/examples/qt3d/wave/main.cpp index c8c456f1a..8aa5fb8b0 100644 --- a/examples/qt3d/wave/main.cpp +++ b/examples/qt3d/wave/main.cpp @@ -34,32 +34,20 @@ ** ****************************************************************************/ -#include -#include -#include +#include "qt3dquickwindow.h" #include - #include -#include +#include +#include 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()); + Qt3DQuickWindow view; // 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); - + view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/wave/main.qml b/examples/qt3d/wave/main.qml index 6f7aaddb9..a6f46bfa7 100644 --- a/examples/qt3d/wave/main.qml +++ b/examples/qt3d/wave/main.qml @@ -72,9 +72,7 @@ Entity { position: Qt.vector3d( 0.0, 10.0, 25.0 ) } - Configuration { - controlledCamera: mainCamera - } + FirstPersonCameraController { camera: mainCamera } Background { id: background diff --git a/examples/qt3d/wireframe/main.cpp b/examples/qt3d/wireframe/main.cpp index de613c520..00820a857 100644 --- a/examples/qt3d/wireframe/main.cpp +++ b/examples/qt3d/wireframe/main.cpp @@ -34,9 +34,7 @@ ** ****************************************************************************/ -#include -#include -#include +#include "qt3dquickwindow.h" #include #include @@ -45,21 +43,11 @@ 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()); + Qt3DQuickWindow view; // 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(&view))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(&view)); - engine.aspectEngine()->setData(data); - engine.setSource(QUrl("qrc:/main.qml")); - + view.engine()->qmlEngine()->rootContext()->setContextProperty("_window", &view); + view.setSource(QUrl("qrc:/main.qml")); view.show(); return app.exec(); diff --git a/examples/qt3d/wireframe/main.qml b/examples/qt3d/wireframe/main.qml index ed3f2899f..35033951d 100644 --- a/examples/qt3d/wireframe/main.qml +++ b/examples/qt3d/wireframe/main.qml @@ -56,9 +56,7 @@ Entity { position: Qt.vector3d( 0.0, 0.0, 15.0 ) } - Configuration { - controlledCamera: mainCamera - } + FirstPersonCameraController { camera: mainCamera } WireframeMaterial { id: wireframeMaterial -- cgit v1.2.3