summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2015-01-20 15:16:21 +0100
committerKevin Ottens <kevin.ottens@kdab.com>2015-01-23 07:51:29 +0100
commitae03c0af3b07712f6a5a1c75fe729215ea820d54 (patch)
treeed9d117f4a384c1f3a113b47347c16d0c4537c01
parentf901090a4144d64bd8b483b75af3af4fd7142b45 (diff)
Move CameraController in the input aspect
With this move it also becomes a private class. As a result I had to touch all the examples as you won't get camera navigation anymore if the input aspect is not registered. Quick3DConfiguration doesn't depend on the QuickWindow singleton hack anymore, it tries to get back to the aspects and set the camera on the ones having a corresponding property. It also mostly empties Window and QuickWindow. Change-Id: Ife1644bd338e51929bad1e99089bd5e4c68ebc68 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--examples/assimp/assimp.pro2
-rw-r--r--examples/assimp/main.cpp2
-rw-r--r--examples/bigmodel-qml/bigmodel-qml.pro2
-rw-r--r--examples/bigmodel-qml/main.cpp2
-rw-r--r--examples/bigscene-cpp/bigscene-cpp.pro2
-rw-r--r--examples/bigscene-cpp/main.cpp5
-rw-r--r--examples/cpp_example/cpp_example.pro2
-rw-r--r--examples/cpp_example/main.cpp6
-rw-r--r--examples/cylinder-cpp/cylinder-cpp.pro2
-rw-r--r--examples/cylinder-cpp/main.cpp6
-rw-r--r--examples/cylinder-qml/cylinder-qml.pro2
-rw-r--r--examples/cylinder-qml/main.cpp3
-rw-r--r--examples/deferred-renderer-cpp/deferred-renderer-cpp.pro2
-rw-r--r--examples/deferred-renderer-cpp/main.cpp7
-rw-r--r--examples/deferred-renderer-qml/deferred-renderer-qml.pro2
-rw-r--r--examples/deferred-renderer-qml/main.cpp2
-rw-r--r--examples/dynamicscene-cpp/dynamicscene-cpp.pro2
-rw-r--r--examples/dynamicscene-cpp/main.cpp6
-rw-r--r--examples/gltf/gltf.pro2
-rw-r--r--examples/gltf/main.cpp2
-rw-r--r--examples/loader-qml/loader-qml.pro2
-rw-r--r--examples/loader-qml/main.cpp2
-rw-r--r--examples/materials-cpp/main.cpp6
-rw-r--r--examples/materials-cpp/materials-cpp.pro2
-rw-r--r--examples/materials/main.cpp2
-rw-r--r--examples/materials/materials.pro2
-rw-r--r--examples/multiviewport/main.cpp2
-rw-r--r--examples/multiviewport/multiviewport.pro2
-rw-r--r--examples/rollerball/main.cpp2
-rw-r--r--examples/rollerball/rollerball.pro2
-rw-r--r--examples/shadow-map-qml/main.cpp2
-rw-r--r--examples/shadow-map-qml/shadow-map-qml.pro2
-rw-r--r--examples/simple-cpp/main.cpp6
-rw-r--r--examples/simple-cpp/simple-cpp.pro2
-rw-r--r--examples/simple-qml/main.cpp2
-rw-r--r--examples/simple-qml/simple-qml.pro2
-rw-r--r--examples/tessellation-modes/main.cpp2
-rw-r--r--examples/tessellation-modes/tessellation-modes.pro2
-rw-r--r--examples/torus-cpp/main.cpp6
-rw-r--r--examples/torus-cpp/torus-cpp.pro2
-rw-r--r--examples/torus-qml/main.cpp3
-rw-r--r--examples/torus-qml/torus-qml.pro2
-rw-r--r--examples/wireframe/main.cpp2
-rw-r--r--examples/wireframe/wireframe.pro2
-rw-r--r--src/core/core.pri2
-rw-r--r--src/core/window.cpp9
-rw-r--r--src/core/window.h14
-rw-r--r--src/input/cameracontroller.cpp (renamed from src/core/cameracontroller.cpp)13
-rw-r--r--src/input/cameracontroller_p.h (renamed from src/core/cameracontroller.h)12
-rw-r--r--src/input/input.pri2
-rw-r--r--src/input/qinputaspect.cpp17
-rw-r--r--src/input/qinputaspect.h8
-rw-r--r--src/input/qinputaspect_p.h2
-rw-r--r--src/quick3d/quick3d/items/quick3dconfiguration.cpp28
-rw-r--r--src/quick3d/quick3d/items/quick3dconfiguration.h3
-rw-r--r--src/quick3d/quick3d/quickwindow.cpp2
-rw-r--r--src/src.pro2
57 files changed, 165 insertions, 71 deletions
diff --git a/examples/assimp/assimp.pro b/examples/assimp/assimp.pro
index e2871ca80..1db64789d 100644
--- a/examples/assimp/assimp.pro
+++ b/examples/assimp/assimp.pro
@@ -2,7 +2,7 @@ TEMPLATE = app
SOURCE += main.cpp
-QT += qml quick 3dcore 3drenderer 3dquick
+QT += qml quick 3dcore 3drenderer 3dinput 3dquick
OTHER_FILES += main.qml
diff --git a/examples/assimp/main.cpp b/examples/assimp/main.cpp
index 4a73f8821..a2e864437 100644
--- a/examples/assimp/main.cpp
+++ b/examples/assimp/main.cpp
@@ -43,6 +43,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
#include <QGuiApplication>
#include <QtQml>
@@ -57,6 +58,7 @@ int main(int argc, char* argv[])
Qt3D::Quick::QQmlAspectEngine engine;
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
data.insert(QStringLiteral("window"), QVariant::fromValue(&view));
diff --git a/examples/bigmodel-qml/bigmodel-qml.pro b/examples/bigmodel-qml/bigmodel-qml.pro
index 76b9b972d..e0535a346 100644
--- a/examples/bigmodel-qml/bigmodel-qml.pro
+++ b/examples/bigmodel-qml/bigmodel-qml.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
SOURCES += \
main.cpp
diff --git a/examples/bigmodel-qml/main.cpp b/examples/bigmodel-qml/main.cpp
index e7baa1bf2..f912f4cc6 100644
--- a/examples/bigmodel-qml/main.cpp
+++ b/examples/bigmodel-qml/main.cpp
@@ -41,6 +41,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
#include <QGuiApplication>
#include <QtQml>
@@ -65,6 +66,7 @@ int main(int argc, char* argv[])
Qt3D::Quick::QQmlAspectEngine engine;
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
engine.qmlEngine()->rootContext()->setContextProperty("_meshFileNames", meshFileNames);
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
diff --git a/examples/bigscene-cpp/bigscene-cpp.pro b/examples/bigscene-cpp/bigscene-cpp.pro
index 62853b0db..d95efa7a1 100644
--- a/examples/bigscene-cpp/bigscene-cpp.pro
+++ b/examples/bigscene-cpp/bigscene-cpp.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer
+QT += 3dcore 3drenderer 3dinput
SOURCES += \
main.cpp
diff --git a/examples/bigscene-cpp/main.cpp b/examples/bigscene-cpp/main.cpp
index 64a6b790b..e90a10b15 100644
--- a/examples/bigscene-cpp/main.cpp
+++ b/examples/bigscene-cpp/main.cpp
@@ -51,6 +51,7 @@
#include <Qt3DCore/QRotateTransform>
#include <Qt3DCore/QScaleTransform>
#include <Qt3DCore/qaspectengine.h>
+#include <Qt3DInput/QInputAspect>
#include <Qt3DRenderer/QParameter>
#include <Qt3DRenderer/QFrameGraph>
#include <Qt3DRenderer/QCylinderMesh>
@@ -69,6 +70,8 @@ int main(int ac, char **av)
Window view;
Qt3D::QAspectEngine engine;
engine.registerAspect(new Qt3D::QRenderAspect());
+ Qt3D::QInputAspect *input = new Qt3D::QInputAspect;
+ engine.registerAspect(input);
engine.initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
@@ -83,7 +86,7 @@ int main(int ac, char **av)
cameraEntity->setPosition(QVector3D(0, -250.0f, -50.0f));
cameraEntity->setUpVector(QVector3D(0, 1, 0));
cameraEntity->setViewCenter(QVector3D(0, 0, 0));
- view.setCamera(cameraEntity);
+ input->setCamera(cameraEntity);
// FrameGraph
QFrameGraph *frameGraph = new QFrameGraph();
diff --git a/examples/cpp_example/cpp_example.pro b/examples/cpp_example/cpp_example.pro
index 8bdaaf170..943f81533 100644
--- a/examples/cpp_example/cpp_example.pro
+++ b/examples/cpp_example/cpp_example.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer
+QT += 3dcore 3drenderer 3dinput
include("../exampleresources/exampleresources.pri")
diff --git a/examples/cpp_example/main.cpp b/examples/cpp_example/main.cpp
index e36a93513..197b101ec 100644
--- a/examples/cpp_example/main.cpp
+++ b/examples/cpp_example/main.cpp
@@ -49,6 +49,8 @@
#include <Qt3DCore/qcameralens.h>
#include <Qt3DCore/qaspectengine.h>
+#include <Qt3DInput/QInputAspect>
+
#include <Qt3DRenderer/qtorusmesh.h>
#include <Qt3DRenderer/qmesh.h>
#include <Qt3DRenderer/qtechnique.h>
@@ -81,6 +83,8 @@ int main(int ac, char **av)
Qt3D::Window view;
Qt3D::QAspectEngine engine;
engine.registerAspect(new Qt3D::QRenderAspect());
+ Qt3D::QInputAspect *input = new Qt3D::QInputAspect;
+ engine.registerAspect(input);
engine.initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
@@ -135,7 +139,7 @@ int main(int ac, char **av)
cameraEntity->setPosition(QVector3D(-5, 0, -20.0f));
cameraEntity->setViewCenter(QVector3D(11, 0, 5));
cameraEntity->setUpVector(QVector3D(0, 1, 0));
- view.setCamera(cameraEntity);
+ input->setCamera(cameraEntity);
// FrameGraph
Qt3D::QFrameGraph *frameGraph = new Qt3D::QFrameGraph();
diff --git a/examples/cylinder-cpp/cylinder-cpp.pro b/examples/cylinder-cpp/cylinder-cpp.pro
index 2bee5ff07..5ad940ff1 100644
--- a/examples/cylinder-cpp/cylinder-cpp.pro
+++ b/examples/cylinder-cpp/cylinder-cpp.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer
+QT += 3dcore 3drenderer 3dinput
SOURCES += main.cpp
diff --git a/examples/cylinder-cpp/main.cpp b/examples/cylinder-cpp/main.cpp
index edc5e45d9..2eaf4931d 100644
--- a/examples/cylinder-cpp/main.cpp
+++ b/examples/cylinder-cpp/main.cpp
@@ -46,6 +46,8 @@
#include <Qt3DCore/qentity.h>
#include <Qt3DCore/qcameralens.h>
+#include <Qt3DInput/QInputAspect>
+
#include <Qt3DRenderer/qcylindermesh.h>
#include <Qt3DRenderer/qmesh.h>
#include <Qt3DRenderer/qtechnique.h>
@@ -71,6 +73,8 @@ int main(int argc, char **argv)
Qt3D::Window view;
Qt3D::QAspectEngine engine;
engine.registerAspect(new Qt3D::QRenderAspect());
+ Qt3D::QInputAspect *input = new Qt3D::QInputAspect;
+ engine.registerAspect(input);
engine.initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
@@ -88,7 +92,7 @@ int main(int argc, char **argv)
cameraEntity->setPosition(QVector3D(0, 0, -20.0f));
cameraEntity->setUpVector(QVector3D(0, 1, 0));
cameraEntity->setViewCenter(QVector3D(0, 0, 0));
- view.setCamera(cameraEntity);
+ input->setCamera(cameraEntity);
// FrameGraph
Qt3D::QFrameGraph *frameGraph = new Qt3D::QFrameGraph();
diff --git a/examples/cylinder-qml/cylinder-qml.pro b/examples/cylinder-qml/cylinder-qml.pro
index 85392449b..218ab62b5 100644
--- a/examples/cylinder-qml/cylinder-qml.pro
+++ b/examples/cylinder-qml/cylinder-qml.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
SOURCES += \
main.cpp
diff --git a/examples/cylinder-qml/main.cpp b/examples/cylinder-qml/main.cpp
index bee96cb2f..8b7d5c2f4 100644
--- a/examples/cylinder-qml/main.cpp
+++ b/examples/cylinder-qml/main.cpp
@@ -41,7 +41,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
-
+#include <Qt3DInput/QInputAspect>
#include <QGuiApplication>
#include <QtQml>
@@ -54,6 +54,7 @@ int main(int argc, char* argv[])
Qt3D::Quick::QQmlAspectEngine engine;
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
diff --git a/examples/deferred-renderer-cpp/deferred-renderer-cpp.pro b/examples/deferred-renderer-cpp/deferred-renderer-cpp.pro
index 8fc5d682c..eaebea4ed 100644
--- a/examples/deferred-renderer-cpp/deferred-renderer-cpp.pro
+++ b/examples/deferred-renderer-cpp/deferred-renderer-cpp.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer
+QT += 3dcore 3drenderer 3dinput
include("../exampleresources/exampleresources.pri")
diff --git a/examples/deferred-renderer-cpp/main.cpp b/examples/deferred-renderer-cpp/main.cpp
index 4fc7c24b3..62732d25b 100644
--- a/examples/deferred-renderer-cpp/main.cpp
+++ b/examples/deferred-renderer-cpp/main.cpp
@@ -41,6 +41,9 @@
#include <Qt3DCore/QEntity>
#include <Qt3DCore/Window>
+
+#include <Qt3DInput/QInputAspect>
+
#include <Qt3DRenderer/QRenderAspect>
#include <Qt3DRenderer/QFrameGraph>
#include <Qt3DRenderer/QMaterial>
@@ -72,6 +75,8 @@ int main(int ac, char **av)
Qt3D::Window view;
Qt3D::QAspectEngine engine;
engine.registerAspect(new Qt3D::QRenderAspect());
+ Qt3D::QInputAspect *input = new Qt3D::QInputAspect;
+ engine.registerAspect(input);
engine.initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
@@ -121,7 +126,7 @@ int main(int ac, char **av)
camera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f));
camera->setViewCenter(QVector3D(0.0f, 0.0f, 10.0f));
- view.setCamera(camera);
+ input->setCamera(camera);
// FrameGraph
Qt3D::QFrameGraph *frameGraph = new Qt3D::QFrameGraph();
diff --git a/examples/deferred-renderer-qml/deferred-renderer-qml.pro b/examples/deferred-renderer-qml/deferred-renderer-qml.pro
index f31398e22..2b1329c2e 100644
--- a/examples/deferred-renderer-qml/deferred-renderer-qml.pro
+++ b/examples/deferred-renderer-qml/deferred-renderer-qml.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
include("../exampleresources/exampleresources.pri")
diff --git a/examples/deferred-renderer-qml/main.cpp b/examples/deferred-renderer-qml/main.cpp
index 0408188e9..371ca9cb2 100644
--- a/examples/deferred-renderer-qml/main.cpp
+++ b/examples/deferred-renderer-qml/main.cpp
@@ -42,6 +42,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
#include <exampleresources.h>
@@ -58,6 +59,7 @@ int main(int argc, char* argv[])
Qt3D::Quick::QQmlAspectEngine engine;
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
engine.aspectEngine()->initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
diff --git a/examples/dynamicscene-cpp/dynamicscene-cpp.pro b/examples/dynamicscene-cpp/dynamicscene-cpp.pro
index b67888946..715460121 100644
--- a/examples/dynamicscene-cpp/dynamicscene-cpp.pro
+++ b/examples/dynamicscene-cpp/dynamicscene-cpp.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer
+QT += 3dcore 3drenderer 3dinput
include("../exampleresources/exampleresources.pri")
diff --git a/examples/dynamicscene-cpp/main.cpp b/examples/dynamicscene-cpp/main.cpp
index abc67732f..aee718524 100644
--- a/examples/dynamicscene-cpp/main.cpp
+++ b/examples/dynamicscene-cpp/main.cpp
@@ -45,6 +45,8 @@
#include <Qt3DCore/QCamera>
#include <Qt3DCore/Window>
+#include <Qt3DInput/QInputAspect>
+
#include <Qt3DRenderer/QRenderAspect>
#include <Qt3DRenderer/QFrameGraph>
#include <Qt3DRenderer/QForwardRenderer>
@@ -59,6 +61,8 @@ int main(int argc, char* argv[])
Qt3D::Window view;
Qt3D::QAspectEngine engine;
engine.registerAspect(new Qt3D::QRenderAspect());
+ Qt3D::QInputAspect *input = new Qt3D::QInputAspect;
+ engine.registerAspect(input);
engine.initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
@@ -75,7 +79,7 @@ int main(int argc, char* argv[])
basicCamera->setViewCenter(QVector3D(0.0f, 3.5f, 0.0f));
basicCamera->setPosition(QVector3D(0.0f, 3.5f, 25.0f));
// For camera controls
- view.setCamera(basicCamera);
+ input->setCamera(basicCamera);
// Forward Renderer FrameGraph
Qt3D::QFrameGraph *frameGraph = new Qt3D::QFrameGraph(sceneRoot);
diff --git a/examples/gltf/gltf.pro b/examples/gltf/gltf.pro
index 5a1dde26d..d2ac810a9 100644
--- a/examples/gltf/gltf.pro
+++ b/examples/gltf/gltf.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
include("../exampleresources/exampleresources.pri")
diff --git a/examples/gltf/main.cpp b/examples/gltf/main.cpp
index c80add25e..00dac1331 100644
--- a/examples/gltf/main.cpp
+++ b/examples/gltf/main.cpp
@@ -42,6 +42,7 @@
#include <exampleresources.h>
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
#include <QGuiApplication>
#include <QtQml>
@@ -56,6 +57,7 @@ int main(int argc, char* argv[])
Qt3D::Quick::QQmlAspectEngine engine;
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
diff --git a/examples/loader-qml/loader-qml.pro b/examples/loader-qml/loader-qml.pro
index d54671248..c4f4b38cf 100644
--- a/examples/loader-qml/loader-qml.pro
+++ b/examples/loader-qml/loader-qml.pro
@@ -1,5 +1,5 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
SOURCES += \
main.cpp
diff --git a/examples/loader-qml/main.cpp b/examples/loader-qml/main.cpp
index a9d5d101d..3488ffa52 100644
--- a/examples/loader-qml/main.cpp
+++ b/examples/loader-qml/main.cpp
@@ -41,6 +41,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
#include <QGuiApplication>
@@ -52,6 +53,7 @@ int main(int argc, char* argv[])
Qt3D::Quick::QQmlAspectEngine engine;
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
engine.aspectEngine()->initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
diff --git a/examples/materials-cpp/main.cpp b/examples/materials-cpp/main.cpp
index eee06f22b..3a84c33f7 100644
--- a/examples/materials-cpp/main.cpp
+++ b/examples/materials-cpp/main.cpp
@@ -46,6 +46,8 @@
#include <Qt3DCore/QAspectEngine>
#include <Qt3DCore/QCamera>
+#include <Qt3DInput/QInputAspect>
+
#include <Qt3DRenderer/QRenderAspect>
#include <Qt3DRenderer/QPhongMaterial>
#include <Qt3DRenderer/QDiffuseMapMaterial>
@@ -66,6 +68,8 @@ int main(int argc, char* argv[])
Qt3D::Window view;
Qt3D::QAspectEngine engine;
engine.registerAspect(new Qt3D::QRenderAspect());
+ Qt3D::QInputAspect *input = new Qt3D::QInputAspect;
+ engine.registerAspect(input);
engine.initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
@@ -83,7 +87,7 @@ int main(int argc, char* argv[])
basicCamera->setViewCenter(QVector3D(0.0f, 3.5f, 0.0f));
basicCamera->setPosition(QVector3D(0.0f, 3.5f, 25.0f));
// For camera controls
- view.setCamera(basicCamera);
+ input->setCamera(basicCamera);
// Forward Renderer FrameGraph
Qt3D::QFrameGraph *frameGraphComponent = new Qt3D::QFrameGraph(sceneRoot);
diff --git a/examples/materials-cpp/materials-cpp.pro b/examples/materials-cpp/materials-cpp.pro
index bc32d5491..351ed82f8 100644
--- a/examples/materials-cpp/materials-cpp.pro
+++ b/examples/materials-cpp/materials-cpp.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer
+QT += 3dcore 3drenderer 3dinput
include("../exampleresources/exampleresources.pri")
diff --git a/examples/materials/main.cpp b/examples/materials/main.cpp
index 068b475f0..3adf1e08d 100644
--- a/examples/materials/main.cpp
+++ b/examples/materials/main.cpp
@@ -41,6 +41,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
#include <exampleresources.h>
@@ -57,6 +58,7 @@ int main(int argc, char* argv[])
Qt3D::Quick::QQmlAspectEngine engine;
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
engine.aspectEngine()->initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
diff --git a/examples/materials/materials.pro b/examples/materials/materials.pro
index d87485513..23d4d38a8 100644
--- a/examples/materials/materials.pro
+++ b/examples/materials/materials.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
include("../exampleresources/exampleresources.pri")
diff --git a/examples/multiviewport/main.cpp b/examples/multiviewport/main.cpp
index 0d003cdb8..d332c2e7b 100644
--- a/examples/multiviewport/main.cpp
+++ b/examples/multiviewport/main.cpp
@@ -41,6 +41,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
#include <exampleresources.h>
@@ -54,6 +55,7 @@ int main(int ac, char **av)
initializeAssetResources("../exampleresources/example-assets.qrb");
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect);
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
data.insert(QStringLiteral("window"), QVariant::fromValue(&view));
diff --git a/examples/multiviewport/multiviewport.pro b/examples/multiviewport/multiviewport.pro
index 237c4bbbb..d7ed38b6d 100644
--- a/examples/multiviewport/multiviewport.pro
+++ b/examples/multiviewport/multiviewport.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
include("../exampleresources/exampleresources.pri")
diff --git a/examples/rollerball/main.cpp b/examples/rollerball/main.cpp
index f8efd86cf..89b32c4fe 100644
--- a/examples/rollerball/main.cpp
+++ b/examples/rollerball/main.cpp
@@ -41,6 +41,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
#include <Qt3DBulletPhysics/bulletphysicsaspect.h>
#include <exampleresources.h>
@@ -58,6 +59,7 @@ int main(int argc, char* argv[])
Qt3D::Quick::QQmlAspectEngine engine;
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
engine.aspectEngine()->registerAspect(new Qt3D::BulletPhysicsAspect());
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
diff --git a/examples/rollerball/rollerball.pro b/examples/rollerball/rollerball.pro
index e7c906f97..601b3811f 100644
--- a/examples/rollerball/rollerball.pro
+++ b/examples/rollerball/rollerball.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dbulletphysics 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dbulletphysics 3dquick qml quick
include("../exampleresources/exampleresources.pri")
diff --git a/examples/shadow-map-qml/main.cpp b/examples/shadow-map-qml/main.cpp
index 2e70ba22b..886dfe35a 100644
--- a/examples/shadow-map-qml/main.cpp
+++ b/examples/shadow-map-qml/main.cpp
@@ -41,6 +41,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
#include <QGuiApplication>
#include <QQmlContext>
@@ -59,6 +60,7 @@ int main(int argc, char* argv[])
view.resize(1600, 800);
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
engine.aspectEngine()->initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
diff --git a/examples/shadow-map-qml/shadow-map-qml.pro b/examples/shadow-map-qml/shadow-map-qml.pro
index 5d7467f5a..7d7670022 100644
--- a/examples/shadow-map-qml/shadow-map-qml.pro
+++ b/examples/shadow-map-qml/shadow-map-qml.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
include("../exampleresources/exampleresources.pri")
diff --git a/examples/simple-cpp/main.cpp b/examples/simple-cpp/main.cpp
index 720308d68..4f1fab7fc 100644
--- a/examples/simple-cpp/main.cpp
+++ b/examples/simple-cpp/main.cpp
@@ -52,6 +52,8 @@
#include <Qt3DCore/QTranslateTransform>
#include <Qt3DCore/QAspectEngine>
+#include <Qt3DInput/QInputAspect>
+
#include <Qt3DRenderer/QRenderAspect>
#include <Qt3DRenderer/QFrameGraph>
#include <Qt3DRenderer/QForwardRenderer>
@@ -70,6 +72,8 @@ int main(int argc, char* argv[])
Qt3D::QAspectEngine engine;
engine.registerAspect(new Qt3D::QRenderAspect());
+ Qt3D::QInputAspect *input = new Qt3D::QInputAspect;
+ engine.registerAspect(input);
engine.initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
@@ -87,7 +91,7 @@ int main(int argc, char* argv[])
cameraEntity->setPosition(QVector3D(0, 0, -40.0f));
cameraEntity->setUpVector(QVector3D(0, 1, 0));
cameraEntity->setViewCenter(QVector3D(0, 0, 0));
- view.setCamera(cameraEntity);
+ input->setCamera(cameraEntity);
// FrameGraph
diff --git a/examples/simple-cpp/simple-cpp.pro b/examples/simple-cpp/simple-cpp.pro
index 9bf36fff7..c7f008ae9 100644
--- a/examples/simple-cpp/simple-cpp.pro
+++ b/examples/simple-cpp/simple-cpp.pro
@@ -1,5 +1,5 @@
TEMPLATE = app
-QT += 3dcore 3drenderer
+QT += 3dcore 3drenderer 3dinput
SOURCES += \
main.cpp
diff --git a/examples/simple-qml/main.cpp b/examples/simple-qml/main.cpp
index a9d5d101d..3488ffa52 100644
--- a/examples/simple-qml/main.cpp
+++ b/examples/simple-qml/main.cpp
@@ -41,6 +41,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
#include <QGuiApplication>
@@ -52,6 +53,7 @@ int main(int argc, char* argv[])
Qt3D::Quick::QQmlAspectEngine engine;
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
engine.aspectEngine()->initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
diff --git a/examples/simple-qml/simple-qml.pro b/examples/simple-qml/simple-qml.pro
index b5fdfffe7..0df3ee3e6 100644
--- a/examples/simple-qml/simple-qml.pro
+++ b/examples/simple-qml/simple-qml.pro
@@ -1,5 +1,5 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
SOURCES += \
main.cpp
diff --git a/examples/tessellation-modes/main.cpp b/examples/tessellation-modes/main.cpp
index 93c006e02..7b503356a 100644
--- a/examples/tessellation-modes/main.cpp
+++ b/examples/tessellation-modes/main.cpp
@@ -43,6 +43,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
#include <exampleresources.h>
@@ -59,6 +60,7 @@ int main(int argc, char* argv[])
Qt3D::Quick::QQmlAspectEngine engine;
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
diff --git a/examples/tessellation-modes/tessellation-modes.pro b/examples/tessellation-modes/tessellation-modes.pro
index b95545243..683dd7f9f 100644
--- a/examples/tessellation-modes/tessellation-modes.pro
+++ b/examples/tessellation-modes/tessellation-modes.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
include("../exampleresources/exampleresources.pri")
diff --git a/examples/torus-cpp/main.cpp b/examples/torus-cpp/main.cpp
index 330700d4c..4ca4a3df8 100644
--- a/examples/torus-cpp/main.cpp
+++ b/examples/torus-cpp/main.cpp
@@ -46,6 +46,8 @@
#include <Qt3DCore/qentity.h>
#include <Qt3DCore/qcameralens.h>
+#include <Qt3DInput/QInputAspect>
+
#include <Qt3DRenderer/qtorusmesh.h>
#include <Qt3DRenderer/qmesh.h>
#include <Qt3DRenderer/qtechnique.h>
@@ -72,6 +74,8 @@ int main(int argc, char **argv)
Qt3D::Window view;
Qt3D::QAspectEngine engine;
engine.registerAspect(new Qt3D::QRenderAspect());
+ Qt3D::QInputAspect *input = new Qt3D::QInputAspect;
+ engine.registerAspect(input);
engine.initialize();
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
@@ -89,7 +93,7 @@ int main(int argc, char **argv)
cameraEntity->setPosition(QVector3D(0, 0, -20.0f));
cameraEntity->setUpVector(QVector3D(0, 1, 0));
cameraEntity->setViewCenter(QVector3D(0, 0, 0));
- view.setCamera(cameraEntity);
+ input->setCamera(cameraEntity);
// FrameGraph
Qt3D::QFrameGraph *frameGraph = new Qt3D::QFrameGraph();
diff --git a/examples/torus-cpp/torus-cpp.pro b/examples/torus-cpp/torus-cpp.pro
index 2bee5ff07..5ad940ff1 100644
--- a/examples/torus-cpp/torus-cpp.pro
+++ b/examples/torus-cpp/torus-cpp.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer
+QT += 3dcore 3drenderer 3dinput
SOURCES += main.cpp
diff --git a/examples/torus-qml/main.cpp b/examples/torus-qml/main.cpp
index 30ce9b65e..baa6daefb 100644
--- a/examples/torus-qml/main.cpp
+++ b/examples/torus-qml/main.cpp
@@ -41,7 +41,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
-
+#include <Qt3DInput/QInputAspect>
#include <QGuiApplication>
#include <QtQml>
@@ -54,6 +54,7 @@ int main(int argc, char* argv[])
Qt3D::Quick::QQmlAspectEngine engine;
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
QVariantMap data;
data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
data.insert(QStringLiteral("window"), QVariant::fromValue(&view));
diff --git a/examples/torus-qml/torus-qml.pro b/examples/torus-qml/torus-qml.pro
index cb1a88003..060164fa9 100644
--- a/examples/torus-qml/torus-qml.pro
+++ b/examples/torus-qml/torus-qml.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
SOURCES += \
main.cpp
diff --git a/examples/wireframe/main.cpp b/examples/wireframe/main.cpp
index 71d792ac9..1dbdec85e 100644
--- a/examples/wireframe/main.cpp
+++ b/examples/wireframe/main.cpp
@@ -41,6 +41,7 @@
#include <Qt3DQuick/quickwindow.h>
#include <Qt3DRenderer/qrenderaspect.h>
+#include <Qt3DInput/QInputAspect>
#include <exampleresources.h>
@@ -57,6 +58,7 @@ int main(int argc, char* argv[])
Qt3D::Quick::QQmlAspectEngine engine;
engine.aspectEngine()->registerAspect(new Qt3D::QRenderAspect());
+ engine.aspectEngine()->registerAspect(new Qt3D::QInputAspect());
// Expose the window as a context property so we can set the aspect ratio
engine.qmlEngine()->rootContext()->setContextProperty("_window", &view);
diff --git a/examples/wireframe/wireframe.pro b/examples/wireframe/wireframe.pro
index 7dc5eb255..2b2fd991a 100644
--- a/examples/wireframe/wireframe.pro
+++ b/examples/wireframe/wireframe.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-QT += 3dcore 3drenderer 3dquick qml quick
+QT += 3dcore 3drenderer 3dinput 3dquick qml quick
include("../exampleresources/exampleresources.pri")
diff --git a/src/core/core.pri b/src/core/core.pri
index 59c2c4b59..1ffa7c75d 100644
--- a/src/core/core.pri
+++ b/src/core/core.pri
@@ -22,7 +22,6 @@ HEADERS += \
$$PWD/window.h \
$$PWD/qtickclock_p.h \
$$PWD/qscheduler_p.h \
- $$PWD/cameracontroller.h \
$$PWD/corelogging_p.h \
$$PWD/qscenechange.h \
$$PWD/qscenepropertychange.h \
@@ -43,7 +42,6 @@ SOURCES += \
$$PWD/window.cpp \
$$PWD/qtickclock.cpp \
$$PWD/qscheduler.cpp \
- $$PWD/cameracontroller.cpp \
$$PWD/qchangearbiter.cpp \
$$PWD/corelogging.cpp \
$$PWD/qobservableinterface.cpp \
diff --git a/src/core/window.cpp b/src/core/window.cpp
index 3ea9a8a8c..00d4d4b16 100644
--- a/src/core/window.cpp
+++ b/src/core/window.cpp
@@ -49,7 +49,6 @@
#include "qcamera.h"
#include "qentity.h"
#include "qaspectengine.h"
-#include "cameracontroller.h"
#include <Qt3DCore/private/corelogging_p.h>
QT_BEGIN_NAMESPACE
@@ -58,7 +57,6 @@ namespace Qt3D {
Window::Window(QScreen *screen)
: QWindow(screen)
- , m_controller(new CameraController(this))
{
setSurfaceType(QSurface::OpenGLSurface);
@@ -72,19 +70,12 @@ Window::Window(QScreen *screen)
format.setProfile(QSurfaceFormat::CoreProfile);
setFormat(format);
create();
-
- installEventFilter(m_controller);
}
Window::~Window()
{
}
-void Window::setCamera(QCamera *camera)
-{
- m_controller->setCamera(camera);
-}
-
void Window::keyPressEvent( QKeyEvent* e )
{
switch ( e->key() )
diff --git a/src/core/window.h b/src/core/window.h
index d82aa8b44..8257bd716 100644
--- a/src/core/window.h
+++ b/src/core/window.h
@@ -49,14 +49,6 @@ QT_BEGIN_NAMESPACE
namespace Qt3D {
-class QAbstractAspect;
-class QAspectEngine;
-class QCamera;
-class QEntity;
-
-// temporary solution to get control over camera
-class CameraController;
-
class QT3DCORESHARED_EXPORT Window : public QWindow
{
Q_OBJECT
@@ -64,14 +56,8 @@ public:
explicit Window(QScreen *screen = 0);
~Window();
- void setCamera(QCamera *camera);
-
protected:
virtual void keyPressEvent(QKeyEvent *e);
-
-protected:
- // temporary, borrowed from training material
- CameraController *m_controller;
};
} // namespace Qt3D
diff --git a/src/core/cameracontroller.cpp b/src/input/cameracontroller.cpp
index 1b3ef7f87..508b0ff0d 100644
--- a/src/core/cameracontroller.cpp
+++ b/src/input/cameracontroller.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "cameracontroller.h"
+#include "cameracontroller_p.h"
#include <QMouseEvent>
#include <QKeyEvent>
@@ -52,8 +52,8 @@
QT_BEGIN_NAMESPACE
-namespace Qt3D
-{
+using namespace Qt3D;
+using namespace Qt3D::Input;
CameraController::CameraController(QObject *parent) :
QObject(parent),
@@ -95,6 +95,11 @@ void CameraController::setCamera( QCamera* cam )
m_updateTimer->stop();
}
+QCamera *CameraController::camera() const
+{
+ return m_camera;
+}
+
void CameraController::setLinearSpeed( float speed )
{
if ( qFuzzyCompare( m_linearSpeed, speed ) )
@@ -328,6 +333,4 @@ void CameraController::onUpdate()
update(1.0 / 60.0);
}
-} // of namespace Qt3D
-
QT_END_NAMESPACE
diff --git a/src/core/cameracontroller.h b/src/input/cameracontroller_p.h
index 50690677d..51b717ddf 100644
--- a/src/core/cameracontroller.h
+++ b/src/input/cameracontroller_p.h
@@ -43,7 +43,6 @@
#define CAMERA_CONTROLLER_H
#include <QObject>
-#include <Qt3DCore/qt3dcore_global.h>
#include <QPoint>
@@ -54,13 +53,14 @@ class QWheelEvent;
class QKeyEvent;
class QTimer;
-namespace Qt3D
-{
+namespace Qt3D {
class QCamera;
class QEntity;
-class QT3DCORESHARED_EXPORT CameraController : public QObject
+namespace Input {
+
+class CameraController : public QObject
{
Q_OBJECT
@@ -73,6 +73,8 @@ public:
explicit CameraController(QObject *parent = 0);
void setCamera( QCamera* cam );
+ QCamera *camera() const;
+
void setLinearSpeed( float speed );
float linearSpeed() const;
@@ -135,6 +137,8 @@ private:
QTimer *m_updateTimer;
};
+} // of namespace Input
+
} // of namespace Qt3D
QT_END_NAMESPACE
diff --git a/src/input/input.pri b/src/input/input.pri
index 9c9b82fb4..e83bc69f5 100644
--- a/src/input/input.pri
+++ b/src/input/input.pri
@@ -1,4 +1,5 @@
HEADERS += \
+ $$PWD/cameracontroller_p.h \
$$PWD/qinputaspect.h \
$$PWD/qkeyboardcontroller.h \
$$PWD/qkeyboardcontroller_p.h \
@@ -16,6 +17,7 @@ HEADERS += \
$$PWD/q3dkeyevent.h
SOURCES += \
+ $$PWD/cameracontroller.cpp \
$$PWD/qinputaspect.cpp \
$$PWD/qkeyboardcontroller.cpp \
$$PWD/qkeyboardinput.cpp \
diff --git a/src/input/qinputaspect.cpp b/src/input/qinputaspect.cpp
index b43f24ae2..6068acf79 100644
--- a/src/input/qinputaspect.cpp
+++ b/src/input/qinputaspect.cpp
@@ -41,6 +41,7 @@
#include "qinputaspect.h"
#include "qinputaspect_p.h"
+#include "cameracontroller_p.h"
#include "inputhandler_p.h"
#include "keyboardcontroller_p.h"
#include "keyboardinput_p.h"
@@ -57,6 +58,7 @@ namespace Qt3D {
QInputAspectPrivate::QInputAspectPrivate(QInputAspect *qq)
: QAbstractAspectPrivate(qq)
, m_inputHandler(new Input::InputHandler())
+ , m_cameraController(new Input::CameraController())
{
m_aspectType = QAbstractAspect::AspectOther;
}
@@ -68,6 +70,18 @@ QInputAspect::QInputAspect(QObject *parent)
registerBackendType<QKeyboardInput>(QBackendNodeFunctorPtr(new Input::KeyboardInputFunctor(d_func()->m_inputHandler)));
}
+QCamera *QInputAspect::camera() const
+{
+ Q_D(const QInputAspect);
+ return d->m_cameraController->camera();
+}
+
+void QInputAspect::setCamera(QCamera *camera)
+{
+ Q_D(QInputAspect);
+ d->m_cameraController->setCamera(camera);
+}
+
QVector<QAspectJobPtr> QInputAspect::jobsToExecute(qint64 time)
{
Q_UNUSED(time);
@@ -110,12 +124,15 @@ void QInputAspect::onInitialize(const QVariantMap &data)
if (v.isValid())
w = v.value<QWindow *>();
Q_D(QInputAspect);
+ if (w)
+ w->installEventFilter(d->m_cameraController);
d->m_inputHandler->setWindow(w);
}
void QInputAspect::onCleanup()
{
Q_D(QInputAspect);
+ d->m_inputHandler->window()->removeEventFilter(d->m_cameraController);
d->m_inputHandler->setWindow(Q_NULLPTR);
}
diff --git a/src/input/qinputaspect.h b/src/input/qinputaspect.h
index b3b20c5ab..c411c19aa 100644
--- a/src/input/qinputaspect.h
+++ b/src/input/qinputaspect.h
@@ -49,14 +49,22 @@ QT_BEGIN_NAMESPACE
namespace Qt3D {
+class QCamera;
class QInputAspectPrivate;
class QT3DINPUTSHARED_EXPORT QInputAspect : public QAbstractAspect
{
Q_OBJECT
+ Q_PROPERTY(Qt3D::QCamera* camera READ camera WRITE setCamera)
public:
explicit QInputAspect(QObject *parent = 0);
+ QCamera *camera() const;
+
+public Q_SLOTS:
+ void setCamera(QCamera *camera);
+
+public:
QVector<QAspectJobPtr> jobsToExecute(qint64 time) Q_DECL_OVERRIDE;
void sceneNodeAdded(QSceneChangePtr &e) Q_DECL_OVERRIDE;
diff --git a/src/input/qinputaspect_p.h b/src/input/qinputaspect_p.h
index 8b11dd02a..62c399009 100644
--- a/src/input/qinputaspect_p.h
+++ b/src/input/qinputaspect_p.h
@@ -52,6 +52,7 @@ class QInputAspect;
namespace Input {
+class CameraController;
class InputHandler;
}
@@ -63,6 +64,7 @@ public:
Q_DECLARE_PUBLIC(QInputAspect)
Input::InputHandler *m_inputHandler;
+ Input::CameraController *m_cameraController;
};
} // Qt3D
diff --git a/src/quick3d/quick3d/items/quick3dconfiguration.cpp b/src/quick3d/quick3d/items/quick3dconfiguration.cpp
index e511c981a..cc532b2cc 100644
--- a/src/quick3d/quick3d/items/quick3dconfiguration.cpp
+++ b/src/quick3d/quick3d/items/quick3dconfiguration.cpp
@@ -40,9 +40,15 @@
****************************************************************************/
#include "quick3dconfiguration.h"
-#include "quickwindow.h"
#include <QDebug>
+#include <Qt3DCore/QAspectEngine>
+#include <Qt3DCore/QCamera>
+#include <Qt3DCore/QScene>
+#include <Qt3DCore/private/qnode_p.h>
+
+#include <Qt3DInput/QInputAspect>
+
QT_BEGIN_NAMESPACE
namespace Qt3D {
@@ -60,7 +66,7 @@ void Quick3DConfiguration::setControlledCamera(QCamera *camera)
if (m_camera != camera) {
m_camera = camera;
emit controlledCameraChanged();
- Qt3D::Quick::QuickWindow::getInstance()->setCamera(camera);
+ QMetaObject::invokeMethod(this, "applyControlledCameraChange", Qt::QueuedConnection);
}
}
@@ -69,6 +75,24 @@ QCamera *Quick3DConfiguration::controlledCamera() const
return m_camera;
}
+void Quick3DConfiguration::applyControlledCameraChange()
+{
+ QScene *scene = static_cast<QScene*>(QNodePrivate::get(m_camera)->scene());
+
+ // Too early, let's try again later
+ if (!scene) {
+ QMetaObject::invokeMethod(this, "applyControlledCameraChange", Qt::QueuedConnection);
+ return;
+ }
+
+ Q_FOREACH (QAbstractAspect *aspect, scene->engine()->aspects()) {
+ if (aspect->property("camera").isValid()) {
+ aspect->setProperty("camera", QVariant::fromValue(m_camera));
+ break;
+ }
+ }
+}
+
} // Quick
} // Qt3D
diff --git a/src/quick3d/quick3d/items/quick3dconfiguration.h b/src/quick3d/quick3d/items/quick3dconfiguration.h
index 2e14640e4..c2464400f 100644
--- a/src/quick3d/quick3d/items/quick3dconfiguration.h
+++ b/src/quick3d/quick3d/items/quick3dconfiguration.h
@@ -66,6 +66,9 @@ public:
Q_SIGNALS:
void controlledCameraChanged();
+private Q_SLOTS:
+ void applyControlledCameraChange();
+
private:
QCamera *m_camera;
};
diff --git a/src/quick3d/quick3d/quickwindow.cpp b/src/quick3d/quick3d/quickwindow.cpp
index 574dea235..c176b510f 100644
--- a/src/quick3d/quick3d/quickwindow.cpp
+++ b/src/quick3d/quick3d/quickwindow.cpp
@@ -41,8 +41,6 @@
#include "quickwindow.h"
-#include <Qt3DCore/cameracontroller.h>
-
QT_BEGIN_NAMESPACE
namespace Qt3D {
diff --git a/src/src.pro b/src/src.pro
index e1a6851ce..ad5508322 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -22,7 +22,7 @@ src_input.depends = src_render
# Quick3D libs
src_quick3d_core.subdir = $$PWD/quick3d/quick3d
src_quick3d_core.target = sub-quick3d-core
-src_quick3d_core.depends = src_core
+src_quick3d_core.depends = src_core src_input
src_quick3d_render.subdir = $$PWD/quick3d/quick3drenderer
src_quick3d_render.target = sub-quick3d-render