diff options
47 files changed, 227 insertions, 1140 deletions
diff --git a/examples/qt3d/assimp-cpp/main.cpp b/examples/qt3d/assimp-cpp/main.cpp index 59f49a8fb..660cef2fd 100644 --- a/examples/qt3d/assimp-cpp/main.cpp +++ b/examples/qt3d/assimp-cpp/main.cpp @@ -37,7 +37,7 @@ #include <QFileDialog> #include <QApplication> -#include <Qt3DCore/QCamera> +#include <Qt3DRender/QCamera> #include <Qt3DCore/QEntity> #include <Qt3DCore/QAspectEngine> #include <Qt3DInput/QInputAspect> @@ -45,7 +45,8 @@ #include <Qt3DRender/QSceneLoader> #include <Qt3DRender/QRenderAspect> #include <Qt3DRender/QForwardRenderer> -#include <Qt3DRender/QWindow> +#include "qt3dwindow.h" +#include "qfirstpersoncameracontroller.h" class SceneWalker : public QObject { @@ -103,17 +104,14 @@ void SceneWalker::walkEntity(Qt3DCore::QEntity *e, int depth) int main(int ac, char **av) { QApplication app(ac, av); - - Qt3DRender::QWindow view; - Qt3DInput::QInputAspect *inputAspect = new Qt3DInput::QInputAspect(); - view.registerAspect(inputAspect); + Qt3DWindow view; // Root entity Qt3DCore::QEntity *sceneRoot = new Qt3DCore::QEntity(); // Scene Camera - Qt3DCore::QCamera *basicCamera = view.defaultCamera(); - basicCamera->setProjectionType(Qt3DCore::QCameraLens::PerspectiveProjection); + Qt3DRender::QCamera *basicCamera = view.camera(); + basicCamera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection); basicCamera->setAspectRatio(view.width() / view.height()); basicCamera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f)); basicCamera->setViewCenter(QVector3D(0.0f, 3.5f, 0.0f)); @@ -121,7 +119,8 @@ int main(int ac, char **av) basicCamera->setNearPlane(0.001f); basicCamera->setFarPlane(10000.0f); // For camera controls - inputAspect->setCamera(basicCamera); + Qt3DInput::QFirstPersonCameraController *camController = new Qt3DInput::QFirstPersonCameraController(sceneRoot); + camController->setCamera(basicCamera); // Forward Renderer FrameGraph Qt3DRender::QFrameGraph *frameGraphComponent = new Qt3DRender::QFrameGraph(sceneRoot); diff --git a/examples/qt3d/basicshapes-cpp/main.cpp b/examples/qt3d/basicshapes-cpp/main.cpp index f7e50fdd5..586647849 100644 --- a/examples/qt3d/basicshapes-cpp/main.cpp +++ b/examples/qt3d/basicshapes-cpp/main.cpp @@ -38,9 +38,9 @@ #include <QGuiApplication> -#include <Qt3DCore/qcamera.h> +#include <Qt3DRender/qcamera.h> #include <Qt3DCore/qentity.h> -#include <Qt3DCore/qcameralens.h> +#include <Qt3DRender/qcameralens.h> #include <QtWidgets/QApplication> #include <QtWidgets/QWidget> @@ -59,7 +59,6 @@ #include <Qt3DRender/qtexture.h> #include <Qt3DRender/qrenderpass.h> #include <Qt3DRender/qsceneloader.h> -#include <Qt3DRender/qwindow.h> #include <Qt3DCore/qtransform.h> #include <Qt3DCore/qaspectengine.h> @@ -68,10 +67,13 @@ #include <Qt3DRender/qframegraph.h> #include <Qt3DRender/qforwardrenderer.h> +#include "qt3dwindow.h" +#include "qfirstpersoncameracontroller.h" + int main(int argc, char **argv) { QApplication app(argc, argv); - Qt3DRender::QWindow *view = new Qt3DRender::QWindow(); + Qt3DWindow *view = new Qt3DWindow(); QWidget *container = QWidget::createWindowContainer(view); QSize screenSize = view->screen()->size(); container->setMinimumSize(QSize(200, 100)); @@ -93,13 +95,16 @@ int main(int argc, char **argv) Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); // Camera - Qt3DCore::QCamera *cameraEntity = view->defaultCamera(); + Qt3DRender::QCamera *cameraEntity = view->camera(); cameraEntity->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f); cameraEntity->setPosition(QVector3D(0, 0, 20.0f)); cameraEntity->setUpVector(QVector3D(0, 1, 0)); cameraEntity->setViewCenter(QVector3D(0, 0, 0)); - input->setCamera(cameraEntity); + + // For camera controls + Qt3DInput::QFirstPersonCameraController *camController = new Qt3DInput::QFirstPersonCameraController(rootEntity); + camController->setCamera(cameraEntity); // FrameGraph Qt3DRender::QFrameGraph *frameGraph = new Qt3DRender::QFrameGraph(); diff --git a/examples/qt3d/bigscene-cpp/main.cpp b/examples/qt3d/bigscene-cpp/main.cpp index 6cd25a5b4..46e4acb0b 100644 --- a/examples/qt3d/bigscene-cpp/main.cpp +++ b/examples/qt3d/bigscene-cpp/main.cpp @@ -42,7 +42,7 @@ #include <QUrl> #include <QTimer> #include <Qt3DCore/QEntity> -#include <Qt3DCore/QCamera> +#include <Qt3DRender/QCamera> #include <Qt3DCore/QTransform> #include <Qt3DCore/qaspectengine.h> #include <Qt3DInput/QInputAspect> @@ -53,8 +53,9 @@ #include <Qt3DRender/QCameraSelector> #include <Qt3DRender/QPhongMaterial> #include <Qt3DRender/QForwardRenderer> -#include <Qt3DRender/QWindow> #include <qmath.h> +#include "qt3dwindow.h" +#include "qfirstpersoncameracontroller.h" using namespace Qt3DCore; using namespace Qt3DRender; @@ -63,19 +64,20 @@ int main(int ac, char **av) { QGuiApplication app(ac, av); - Qt3DRender::QWindow view; - Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect; - view.registerAspect(input); + Qt3DWindow view; QEntity *root = new QEntity(); // Camera - QCamera *cameraEntity = view.defaultCamera(); + QCamera *cameraEntity = view.camera(); cameraEntity->setObjectName(QStringLiteral("cameraEntity")); cameraEntity->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f); cameraEntity->setPosition(QVector3D(0, 250.0f, 50.0f)); cameraEntity->setUpVector(QVector3D(0, 1, 0)); cameraEntity->setViewCenter(QVector3D(0, 0, 0)); - input->setCamera(cameraEntity); + + // For camera controls + Qt3DInput::QFirstPersonCameraController *camController = new Qt3DInput::QFirstPersonCameraController(root); + camController->setCamera(cameraEntity); // FrameGraph QFrameGraph *frameGraph = new QFrameGraph(); diff --git a/examples/qt3d/cpp_example/main.cpp b/examples/qt3d/cpp_example/main.cpp index 955e0d593..9e7708abf 100644 --- a/examples/qt3d/cpp_example/main.cpp +++ b/examples/qt3d/cpp_example/main.cpp @@ -36,9 +36,9 @@ #include <QGuiApplication> -#include <Qt3DCore/qcamera.h> +#include <Qt3DRender/qcamera.h> #include <Qt3DCore/qentity.h> -#include <Qt3DCore/qcameralens.h> +#include <Qt3DRender/qcameralens.h> #include <Qt3DCore/qaspectengine.h> #include <Qt3DCore/qtransform.h> @@ -59,15 +59,14 @@ #include <Qt3DRender/qrenderaspect.h> #include <Qt3DRender/qframegraph.h> #include <Qt3DRender/qclearbuffer.h> -#include <Qt3DRender/qwindow.h> +#include "qt3dwindow.h" +#include "qfirstpersoncameracontroller.h" int main(int ac, char **av) { QGuiApplication app(ac, av); - Qt3DRender::QWindow view; - Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect; - view.registerAspect(input); + Qt3DWindow view; // Root entity Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); @@ -99,13 +98,16 @@ int main(int ac, char **av) sceneEntity->addComponent(scene); // Camera - Qt3DCore::QCamera *cameraEntity = view.defaultCamera(); + Qt3DRender::QCamera *cameraEntity = view.camera(); cameraEntity->setObjectName(QStringLiteral("cameraEntity")); cameraEntity->lens()->setPerspectiveProjection(60.0f, 16.0f/9.0f, 0.1f, 1000.0f); cameraEntity->setPosition(QVector3D(5, 0, 20.0f)); cameraEntity->setViewCenter(QVector3D(11, 0, 5)); cameraEntity->setUpVector(QVector3D(0, 1, 0)); - input->setCamera(cameraEntity); + + // For camera controls + Qt3DInput::QFirstPersonCameraController *camController = new Qt3DInput::QFirstPersonCameraController(rootEntity); + camController->setCamera(cameraEntity); // FrameGraph Qt3DRender::QFrameGraph *frameGraph = new Qt3DRender::QFrameGraph(); diff --git a/examples/qt3d/custom-mesh-cpp/main.cpp b/examples/qt3d/custom-mesh-cpp/main.cpp index 6bd75dff7..0b412f857 100644 --- a/examples/qt3d/custom-mesh-cpp/main.cpp +++ b/examples/qt3d/custom-mesh-cpp/main.cpp @@ -37,8 +37,8 @@ #include <QGuiApplication> #include <Qt3DCore/QEntity> -#include <Qt3DCore/QCamera> -#include <Qt3DCore/QCameraLens> +#include <Qt3DRender/QCamera> +#include <Qt3DRender/QCameraLens> #include <Qt3DCore/QTransform> #include <Qt3DCore/QAspectEngine> @@ -54,29 +54,30 @@ #include <Qt3DRender/QGeometry> #include <Qt3DRender/QAttribute> #include <Qt3DRender/QBuffer> -#include <Qt3DRender/QWindow> #include <QPropertyAnimation> +#include "qt3dwindow.h" +#include "qfirstpersoncameracontroller.h" int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); - Qt3DRender::QWindow view; - - Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect; - view.registerAspect(input); + Qt3DWindow view; // Root entity Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); // Camera - Qt3DCore::QCamera *cameraEntity = view.defaultCamera(); + Qt3DRender::QCamera *cameraEntity = view.camera(); 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); + + // For camera controls + Qt3DInput::QFirstPersonCameraController *camController = new Qt3DInput::QFirstPersonCameraController(rootEntity); + camController->setCamera(cameraEntity); // FrameGraph Qt3DRender::QFrameGraph *frameGraph = new Qt3DRender::QFrameGraph(); diff --git a/examples/qt3d/cylinder-cpp/main.cpp b/examples/qt3d/cylinder-cpp/main.cpp index f45492926..bf7a35983 100644 --- a/examples/qt3d/cylinder-cpp/main.cpp +++ b/examples/qt3d/cylinder-cpp/main.cpp @@ -36,12 +36,10 @@ #include <QGuiApplication> -#include <Qt3DCore/qcamera.h> -#include <Qt3DCore/qentity.h> -#include <Qt3DCore/qcameralens.h> - #include <Qt3DInput/QInputAspect> +#include <Qt3DRender/qcamera.h> +#include <Qt3DRender/qcameralens.h> #include <Qt3DRender/qcylindermesh.h> #include <Qt3DRender/qmesh.h> #include <Qt3DRender/qtechnique.h> @@ -49,35 +47,38 @@ #include <Qt3DRender/qeffect.h> #include <Qt3DRender/qtexture.h> #include <Qt3DRender/qrenderpass.h> +#include <Qt3DRender/qrenderaspect.h> +#include <Qt3DRender/qframegraph.h> +#include <Qt3DRender/qforwardrenderer.h> +#include <Qt3DCore/qentity.h> #include <Qt3DCore/qtransform.h> #include <Qt3DCore/qaspectengine.h> -#include <Qt3DRender/qrenderaspect.h> -#include <Qt3DRender/qframegraph.h> -#include <Qt3DRender/qforwardrenderer.h> -#include <Qt3DRender/qwindow.h> +#include "qt3dwindow.h" +#include "qfirstpersoncameracontroller.h" int main(int argc, char **argv) { QGuiApplication app(argc, argv); - Qt3DRender::QWindow view; - Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect; - view.registerAspect(input); + Qt3DWindow view; // Root entity Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); // Camera - Qt3DCore::QCamera *cameraEntity = view.defaultCamera(); + Qt3DRender::QCamera *cameraEntity = view.camera(); cameraEntity->setObjectName(QStringLiteral("cameraEntity")); cameraEntity->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f); cameraEntity->setPosition(QVector3D(0, 0, 20.0f)); cameraEntity->setUpVector(QVector3D(0, 1, 0)); cameraEntity->setViewCenter(QVector3D(0, 0, 0)); - input->setCamera(cameraEntity); + + // For camera controls + Qt3DInput::QFirstPersonCameraController *camController = new Qt3DInput::QFirstPersonCameraController(rootEntity); + camController->setCamera(cameraEntity); // FrameGraph Qt3DRender::QFrameGraph *frameGraph = new Qt3DRender::QFrameGraph(); diff --git a/examples/qt3d/deferred-renderer-cpp/main.cpp b/examples/qt3d/deferred-renderer-cpp/main.cpp index b3df94b1a..b910b4920 100644 --- a/examples/qt3d/deferred-renderer-cpp/main.cpp +++ b/examples/qt3d/deferred-renderer-cpp/main.cpp @@ -36,20 +36,16 @@ #include <Qt3DCore/QEntity> -#include <Qt3DInput/QInputAspect> - -#include <Qt3DRender/QRenderAspect> #include <Qt3DRender/QFrameGraph> #include <Qt3DRender/QMaterial> #include <Qt3DRender/QSphereMesh> #include <Qt3DRender/QPlaneMesh> #include <Qt3DRender/QLayer> #include <Qt3DRender/QParameter> -#include <Qt3DCore/QCamera> -#include <Qt3DCore/QCameraLens> +#include <Qt3DRender/QCamera> +#include <Qt3DRender/QCameraLens> #include <Qt3DCore/QTransform> #include <Qt3DRender/QPointLight> -#include <Qt3DRender/QWindow> #include <Qt3DCore/qaspectengine.h> #include <QGuiApplication> @@ -59,14 +55,15 @@ #include "finaleffect.h" #include "sceneeffect.h" #include "pointlightblock.h" +#include "qt3dwindow.h" +#include "qfirstpersoncameracontroller.h" + int main(int ac, char **av) { QGuiApplication app(ac, av); - Qt3DRender::QWindow view; - Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect(); - view.registerAspect(input); + Qt3DWindow view; // Root entity Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); @@ -99,18 +96,20 @@ int main(int ac, char **av) rootEntity->addComponent(light1); // Scene Camera - Qt3DCore::QCamera *camera = view.defaultCamera(); + Qt3DRender::QCamera *camera = view.camera(); camera->setFieldOfView(45.0f); camera->setNearPlane(0.01f); camera->setFarPlane(1000.0f); - camera->setProjectionType(Qt3DCore::QCameraLens::PerspectiveProjection); + camera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection); camera->setPosition(QVector3D(10.0f, 10.0f, -25.0f)); camera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f)); camera->setViewCenter(QVector3D(0.0f, 0.0f, 10.0f)); - input->setCamera(camera); + // For camera controls + Qt3DInput::QFirstPersonCameraController *camController = new Qt3DInput::QFirstPersonCameraController(rootEntity); + camController->setCamera(camera); // FrameGraph Qt3DRender::QFrameGraph *frameGraph = new Qt3DRender::QFrameGraph(); diff --git a/examples/qt3d/dynamicscene-cpp/main.cpp b/examples/qt3d/dynamicscene-cpp/main.cpp index ea7a86330..95e53be85 100644 --- a/examples/qt3d/dynamicscene-cpp/main.cpp +++ b/examples/qt3d/dynamicscene-cpp/main.cpp @@ -37,37 +37,37 @@ #include <QGuiApplication> #include <Qt3DCore/QAspectEngine> -#include <Qt3DCore/QCamera> +#include <Qt3DRender/QCamera> #include <Qt3DInput/QInputAspect> #include <Qt3DRender/QRenderAspect> #include <Qt3DRender/QFrameGraph> #include <Qt3DRender/QForwardRenderer> -#include <Qt3DRender/QWindow> #include "forwardrenderer.h" #include "examplescene.h" +#include "qt3dwindow.h" +#include "qfirstpersoncameracontroller.h" int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); - Qt3DRender::QWindow view; - Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect; - view.registerAspect(input); + Qt3DWindow view; ExampleScene *sceneRoot = new ExampleScene(); // Scene Camera - Qt3DCore::QCamera *basicCamera = view.defaultCamera(); - basicCamera->setProjectionType(Qt3DCore::QCameraLens::PerspectiveProjection); + Qt3DRender::QCamera *basicCamera = view.camera(); + basicCamera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection); basicCamera->setAspectRatio(view.width() / view.height()); basicCamera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f)); basicCamera->setViewCenter(QVector3D(0.0f, 3.5f, 0.0f)); basicCamera->setPosition(QVector3D(0.0f, 3.5f, 25.0f)); // For camera controls - input->setCamera(basicCamera); + Qt3DInput::QFirstPersonCameraController *camController = new Qt3DInput::QFirstPersonCameraController(sceneRoot); + camController->setCamera(basicCamera); view.setRootEntity(sceneRoot); view.show(); diff --git a/examples/qt3d/examples-common/qfirstpersoncameracontroller.cpp b/examples/qt3d/examples-common/qfirstpersoncameracontroller.cpp index 46ae0c115..10b0d7ec7 100644 --- a/examples/qt3d/examples-common/qfirstpersoncameracontroller.cpp +++ b/examples/qt3d/examples-common/qfirstpersoncameracontroller.cpp @@ -36,7 +36,7 @@ #include "qfirstpersoncameracontroller_p.h" #include "qfirstpersoncameracontroller.h" -#include <Qt3DCore/QCamera> +#include <Qt3DRender/QCamera> #include <Qt3DInput/QAxis> #include <Qt3DInput/QAxisInput> #include <Qt3DInput/QAction> @@ -226,7 +226,7 @@ QFirstPersonCameraController::~QFirstPersonCameraController() { } -Qt3DCore::QCamera *QFirstPersonCameraController::camera() const +Qt3DRender::QCamera *QFirstPersonCameraController::camera() const { Q_D(const QFirstPersonCameraController); return d->m_camera; @@ -244,7 +244,7 @@ float QFirstPersonCameraController::lookSpeed() const return d->m_lookSpeed; } -void QFirstPersonCameraController::setCamera(Qt3DCore::QCamera *camera) +void QFirstPersonCameraController::setCamera(Qt3DRender::QCamera *camera) { Q_D(QFirstPersonCameraController); if (d->m_camera != camera) { diff --git a/examples/qt3d/examples-common/qfirstpersoncameracontroller.h b/examples/qt3d/examples-common/qfirstpersoncameracontroller.h index b1755d7d4..6f8d21ebf 100644 --- a/examples/qt3d/examples-common/qfirstpersoncameracontroller.h +++ b/examples/qt3d/examples-common/qfirstpersoncameracontroller.h @@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE -namespace Qt3DCore { +namespace Qt3DRender { class QCamera; } @@ -52,7 +52,7 @@ class QFirstPersonCameraControllerPrivate; class QFirstPersonCameraController : public Qt3DCore::QEntity { Q_OBJECT - Q_PROPERTY(Qt3DCore::QCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged) + Q_PROPERTY(Qt3DRender::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) @@ -60,11 +60,11 @@ public: explicit QFirstPersonCameraController(Qt3DCore::QNode *parent = Q_NULLPTR); ~QFirstPersonCameraController(); - Qt3DCore::QCamera *camera() const; + Qt3DRender::QCamera *camera() const; float linearSpeed() const; float lookSpeed() const; - void setCamera(Qt3DCore::QCamera *camera); + void setCamera(Qt3DRender::QCamera *camera); void setLinearSpeed(float linearSpeed); void setLookSpeed(float lookSpeed); diff --git a/examples/qt3d/examples-common/qfirstpersoncameracontroller_p.h b/examples/qt3d/examples-common/qfirstpersoncameracontroller_p.h index 985b9f536..d5ac58d56 100644 --- a/examples/qt3d/examples-common/qfirstpersoncameracontroller_p.h +++ b/examples/qt3d/examples-common/qfirstpersoncameracontroller_p.h @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE -namespace Qt3DCore { +namespace Qt3DRender { class QCamera; } @@ -69,7 +69,7 @@ public: void init(); - Qt3DCore::QCamera *m_camera; + Qt3DRender::QCamera *m_camera; QAction *m_leftMouseButtonAction; QAction *m_fineMotionAction; QAxis *m_rxAxis; diff --git a/examples/qt3d/examples-common/qt3dwindow.cpp b/examples/qt3d/examples-common/qt3dwindow.cpp index 9575424a8..e46b052a7 100644 --- a/examples/qt3d/examples-common/qt3dwindow.cpp +++ b/examples/qt3d/examples-common/qt3dwindow.cpp @@ -43,7 +43,7 @@ #include <Qt3DLogic/qlogicaspect.h> #include <Qt3DCore/qaspectengine.h> -#include <Qt3DCore/qcamera.h> +#include <Qt3DRender/qcamera.h> #include <Qt3DCore/qentity.h> #include <QtGui/qopenglcontext.h> @@ -57,7 +57,7 @@ Qt3DWindow::Qt3DWindow(QScreen *screen) , m_inputAspect(new Qt3DInput::QInputAspect) , m_logicAspect(new Qt3DLogic::QLogicAspect) , m_frameGraph(nullptr) - , m_defaultCamera(new Qt3DCore::QCamera) + , m_defaultCamera(new Qt3DRender::QCamera) , m_root(new Qt3DCore::QEntity) , m_userRoot(nullptr) , m_initialized(false) @@ -89,7 +89,7 @@ Qt3DWindow::Qt3DWindow(QWindow *parent) , m_inputAspect(new Qt3DInput::QInputAspect) , m_logicAspect(new Qt3DLogic::QLogicAspect) , m_frameGraph(nullptr) - , m_defaultCamera(new Qt3DCore::QCamera) + , m_defaultCamera(new Qt3DRender::QCamera) , m_root(new Qt3DCore::QEntity) , m_userRoot(nullptr) , m_initialized(false) @@ -135,7 +135,12 @@ void Qt3DWindow::setRootEntity(Qt3DCore::QEntity *root) m_userRoot = root; } -Qt3DCore::QCamera *Qt3DWindow::camera() const +void Qt3DWindow::setFrameGraph(Qt3DRender::QFrameGraph *frameGraph) +{ + m_frameGraph = frameGraph; +} + +Qt3DRender::QCamera *Qt3DWindow::camera() const { return m_defaultCamera; } @@ -162,9 +167,6 @@ void Qt3DWindow::showEvent(QShowEvent *e) m_root->addComponent(m_frameGraph); m_aspectEngine->setRootEntity(m_root); - // TODO: Get rid of this too - m_inputAspect->setCamera(m_defaultCamera); - m_initialized = true; } diff --git a/examples/qt3d/examples-common/qt3dwindow.h b/examples/qt3d/examples-common/qt3dwindow.h index b42e3d81c..df527acd6 100644 --- a/examples/qt3d/examples-common/qt3dwindow.h +++ b/examples/qt3d/examples-common/qt3dwindow.h @@ -43,11 +43,12 @@ QT_BEGIN_NAMESPACE namespace Qt3DCore { class QAspectEngine; -class QCamera; +class QAbstractAspect; class QEntity; } namespace Qt3DRender { +class QCamera; class QFrameGraph; class QRenderAspect; } @@ -72,8 +73,9 @@ public: void registerAspect(const QString &name); void setRootEntity(Qt3DCore::QEntity *root); + void setFrameGraph(Qt3DRender::QFrameGraph *frameGraph); - Qt3DCore::QCamera *camera() const; + Qt3DRender::QCamera *camera() const; public Q_SLOTS: @@ -93,7 +95,7 @@ private: // Renderer configuration Qt3DRender::QFrameGraph *m_frameGraph; - Qt3DCore::QCamera *m_defaultCamera; + Qt3DRender::QCamera *m_defaultCamera; // Input configuration diff --git a/examples/qt3d/materials-cpp/main.cpp b/examples/qt3d/materials-cpp/main.cpp index f8b8afc66..245ff255c 100644 --- a/examples/qt3d/materials-cpp/main.cpp +++ b/examples/qt3d/materials-cpp/main.cpp @@ -38,7 +38,7 @@ #include <Qt3DCore/QEntity> #include <Qt3DCore/QAspectEngine> -#include <Qt3DCore/QCamera> +#include <Qt3DRender/QCamera> #include <Qt3DInput/QInputAspect> @@ -48,33 +48,33 @@ #include <Qt3DRender/QForwardRenderer> #include <Qt3DRender/QFrameGraph> #include <Qt3DRender/QTextureImage> -#include <Qt3DRender/QWindow> #include "planeentity.h" #include "rotatingtrefoilknot.h" #include "barrel.h" #include "houseplant.h" +#include "qt3dwindow.h" +#include "qfirstpersoncameracontroller.h" int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); - Qt3DRender::QWindow view; - Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect; - view.registerAspect(input); + Qt3DWindow view; // Scene Root Qt3DCore::QEntity *sceneRoot = new Qt3DCore::QEntity(); // Scene Camera - Qt3DCore::QCamera *basicCamera = view.defaultCamera(); - basicCamera->setProjectionType(Qt3DCore::QCameraLens::PerspectiveProjection); + Qt3DRender::QCamera *basicCamera = view.camera(); + basicCamera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection); basicCamera->setAspectRatio(view.width() / view.height()); basicCamera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f)); basicCamera->setViewCenter(QVector3D(0.0f, 3.5f, 0.0f)); basicCamera->setPosition(QVector3D(0.0f, 3.5f, 25.0f)); // For camera controls - input->setCamera(basicCamera); + Qt3DInput::QFirstPersonCameraController *camController = new Qt3DInput::QFirstPersonCameraController(sceneRoot); + camController->setCamera(basicCamera); // Scene floor PlaneEntity *planeEntity = new PlaneEntity(sceneRoot); diff --git a/examples/qt3d/simple-cpp/main.cpp b/examples/qt3d/simple-cpp/main.cpp index 990fd36bb..438c4b849 100644 --- a/examples/qt3d/simple-cpp/main.cpp +++ b/examples/qt3d/simple-cpp/main.cpp @@ -37,8 +37,8 @@ #include <QGuiApplication> #include <Qt3DCore/QEntity> -#include <Qt3DCore/QCamera> -#include <Qt3DCore/QCameraLens> +#include <Qt3DRender/QCamera> +#include <Qt3DRender/QCameraLens> #include <Qt3DCore/QTransform> #include <Qt3DCore/QAspectEngine> @@ -56,6 +56,7 @@ #include "qt3dwindow.h" #include "orbittransformcontroller.h" +#include "qfirstpersoncameracontroller.h" Qt3DCore::QEntity *createScene() { @@ -112,12 +113,17 @@ int main(int argc, char* argv[]) QGuiApplication app(argc, argv); Qt3DWindow view; + Qt3DCore::QEntity *scene = createScene(); + // Camera - Qt3DCore::QCamera *camera = view.camera(); + Qt3DRender::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(); + // For camera controls + Qt3DInput::QFirstPersonCameraController *camController = new Qt3DInput::QFirstPersonCameraController(scene); + camController->setCamera(camera); + view.setRootEntity(scene); view.show(); diff --git a/src/core/core-components/core-components.pri b/src/core/core-components/core-components.pri deleted file mode 100644 index 737c6802e..000000000 --- a/src/core/core-components/core-components.pri +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS += \ - $$PWD/qcamera_p.h \ - $$PWD/qcamera.h \ - $$PWD/qcameralens.h \ - $$PWD/qcameralens_p.h - -SOURCES += \ - $$PWD/qcamera.cpp \ - $$PWD/qcameralens.cpp - -INCLUDEPATH += $$PWD diff --git a/src/core/core.pri b/src/core/core.pri index 45bd7a692..d257a2519 100644 --- a/src/core/core.pri +++ b/src/core/core.pri @@ -6,8 +6,6 @@ include (./aspects/aspects.pri) include (./jobs/jobs.pri) # Nodes include (./nodes/nodes.pri) -# Qml Components -include (./core-components/core-components.pri) #Transformations include (./transforms/transforms.pri) # Resources Management diff --git a/src/input/backend/backend.pri b/src/input/backend/backend.pri index a1fcedd0e..5f7f7b51b 100644 --- a/src/input/backend/backend.pri +++ b/src/input/backend/backend.pri @@ -1,5 +1,4 @@ HEADERS += \ - $$PWD/cameracontroller_p.h \ $$PWD/keyboardcontroller_p.h \ $$PWD/keyboardinput_p.h \ $$PWD/inputhandler_p.h \ @@ -32,7 +31,6 @@ HEADERS += \ $$PWD/inputsequence_p.h SOURCES += \ - $$PWD/cameracontroller.cpp \ $$PWD/keyboardcontroller.cpp \ $$PWD/keyboardinput.cpp \ $$PWD/inputhandler.cpp \ diff --git a/src/input/backend/cameracontroller.cpp b/src/input/backend/cameracontroller.cpp deleted file mode 100644 index 7001a9020..000000000 --- a/src/input/backend/cameracontroller.cpp +++ /dev/null @@ -1,365 +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 "cameracontroller_p.h" - -#include <QMouseEvent> -#include <QKeyEvent> -#include <QTimer> - -#include <qcamera.h> -#include <qcameralens.h> -#include <qentity.h> - -QT_BEGIN_NAMESPACE - -using namespace Qt3DCore; - -namespace Qt3DInput { -namespace Input { - -CameraController::CameraController(QObject *parent) : - QObject(parent), - m_camera( 0 ), - m_vx( 0.0f ), - m_vy( 0.0f ), - m_vz( 0.0f ), - m_viewCenterFixed( false ), - m_panAngle( 0.0f ), - m_tiltAngle( 0.0f ), - m_leftButtonPressed( false ), - m_orbitMode( false ), - m_linearSpeed( 40.0f ), - m_time( 0.0f ), - m_orbitRate( -0.3f ), - m_lookRate( 0.1f ), - m_translateFast( false ), - m_multisampleEnabled( true ), - m_controlMode( FirstPerson ), - m_firstPersonUp( QVector3D( 0.0f, 1.0f, 0.0f ) ), - m_updateTimer(new QTimer(this)) -{ - m_updateTimer->setInterval(16); - connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(onUpdate())); -} - -/*! - * CameraController expects to find a Camera entity. - * That means if you have built you Camera yourself using - * an Entity, a CameraLens and a Transform instead of using the - * ready made Camera element, it won't work. - */ -void CameraController::setCamera( Qt3DCore::QCamera* cam ) -{ - m_camera = cam; - m_cameraEntity = cam; - - if (m_camera) - m_updateTimer->start(); - else - m_updateTimer->stop(); -} - -Qt3DCore::QCamera *CameraController::camera() const -{ - return m_camera; -} - -void CameraController::setLinearSpeed( float speed ) -{ - if ( qFuzzyCompare( m_linearSpeed, speed ) ) - return; - m_linearSpeed = speed; - emit linearSpeedChanged(speed); -} - -float CameraController::linearSpeed() const -{ - return m_linearSpeed; -} - -float CameraController::orbitRate() const -{ - return m_orbitRate; -} - -void CameraController::setOrbitRate( float rate ) -{ - if ( qFuzzyCompare( m_orbitRate, rate ) ) - return; - m_orbitRate = rate; - emit orbitRateChanged(rate); -} - -float CameraController::lookRate() const -{ - return m_lookRate; -} - -void CameraController::setLookRate( float rate ) -{ - if ( qFuzzyCompare( m_lookRate, rate ) ) - return; - m_lookRate = rate; - emit lookRateChanged(rate); -} - -void CameraController::update(double dt) -{ - if ( !m_camera ) - return; - - if (m_translateFast) - dt *= 10; - - // Update the camera position and orientation - QCamera::CameraTranslationOption option = m_viewCenterFixed - ? QCamera::DontTranslateViewCenter - : QCamera::TranslateViewCenter; - m_camera->translate(dt * QVector3D(m_vx, m_vy, m_vz), option); - - if (!qFuzzyIsNull(m_panAngle)) { - m_camera->pan(m_panAngle); - m_panAngle = 0.0f; - } - - if (!qFuzzyIsNull(m_tiltAngle)) { - m_camera->tilt(m_tiltAngle); - m_tiltAngle = 0.0f; - } -} - -bool CameraController::keyPressEvent( QT_PREPEND_NAMESPACE(QKeyEvent*) e ) -{ - m_translateFast = e->modifiers().testFlag(Qt::AltModifier); - m_viewCenterFixed = e->modifiers().testFlag(Qt::ShiftModifier); - - switch ( e->key() ) - { - case Qt::Key_Right: - m_vx = m_linearSpeed; - break; - - case Qt::Key_Left: - m_vx = -m_linearSpeed; - break; - - case Qt::Key_Up: - m_vz = m_linearSpeed; - break; - - case Qt::Key_Down: - m_vz = -m_linearSpeed; - break; - - case Qt::Key_PageUp: - m_vy = m_linearSpeed; - break; - - case Qt::Key_PageDown: - m_vy = -m_linearSpeed; - break; - - case Qt::Key_A: - toggleMSAA(); - break; - - default: - return false; - } - - return true; -} - -bool CameraController::keyReleaseEvent( QT_PREPEND_NAMESPACE(QKeyEvent*) e ) -{ - switch ( e->key() ) - { - case Qt::Key_Right: - case Qt::Key_Left: - m_vx = 0.0; - break; - - case Qt::Key_Up: - case Qt::Key_Down: - m_vz = 0.0; - break; - - case Qt::Key_PageUp: - case Qt::Key_PageDown: - m_vy = 0.0; - break; - - default: - return false; - } - - return true; -} - -void CameraController::mousePressEvent( QT_PREPEND_NAMESPACE(QMouseEvent*) e ) -{ - if ( e->button() == Qt::LeftButton ) - { - m_leftButtonPressed = true; - m_pos = m_prevPos = e->pos(); - } - else if ( e->button() == Qt::RightButton ) - { - m_orbitMode = true; - m_pos = m_prevPos = e->pos(); - } -} - -void CameraController::mouseReleaseEvent( QT_PREPEND_NAMESPACE(QMouseEvent*) e ) -{ - if ( e->button() == Qt::LeftButton ) - { - m_leftButtonPressed = false; - } - else if ( e->button() == Qt::RightButton ) - { - m_orbitMode = false; - } -} - -void CameraController::mouseMoveEvent( QT_PREPEND_NAMESPACE(QMouseEvent*) e ) -{ - if (!m_camera ) - return; - - if (!m_leftButtonPressed && !m_orbitMode) - return; - - m_pos = e->pos(); - float dx = m_pos.x() - m_prevPos.x(); - float dy = -(m_pos.y() - m_prevPos.y()); - m_prevPos = m_pos; - - if (m_leftButtonPressed) { - switch (m_controlMode) { - case FreeLook: - m_camera->pan(dx * m_lookRate); - break; - - case FirstPerson: - m_camera->pan(dx * m_lookRate, m_firstPersonUp); - break; - } - - m_camera->tilt(dy * m_lookRate); - } else if (m_orbitMode) { - switch (m_controlMode) { - case FreeLook: - m_camera->panAboutViewCenter(dx * m_orbitRate); - break; - - case FirstPerson: - m_camera->panAboutViewCenter(dx * m_orbitRate, m_firstPersonUp); - break; - } - - m_camera->tiltAboutViewCenter(dy * m_orbitRate); - } -} - -bool CameraController::isMultisampleEnabled() const -{ - return m_multisampleEnabled; -} - -void CameraController::toggleMSAA() -{ - m_multisampleEnabled = !m_multisampleEnabled; - emit multisampleEnabledChanged(m_multisampleEnabled); -} - -void CameraController::setControlMode(ControlMode controlMode) -{ - if (controlMode != m_controlMode) { - m_controlMode = controlMode; - emit controlModeChanged(controlMode); - } -} - -CameraController::ControlMode CameraController::controlMode() const -{ - return m_controlMode; -} - -void CameraController::setFirstPersonUpVector(const QVector3D &up) -{ - if (m_firstPersonUp != up) { - m_firstPersonUp = up; - emit firstPersonUpVectorChanged(up); - } -} - -QVector3D CameraController::firstPersonUpVector() const -{ - return m_firstPersonUp; -} - -bool CameraController::eventFilter(QObject *receiver, QEvent *event) -{ - switch (event->type()) { - case QEvent::MouseButtonPress: - mousePressEvent(static_cast<QT_PREPEND_NAMESPACE(QMouseEvent*)>(event)); - return true; - case QEvent::MouseButtonRelease: - mouseReleaseEvent(static_cast<QT_PREPEND_NAMESPACE(QMouseEvent*)>(event)); - return true; - case QEvent::MouseMove: - mouseMoveEvent(static_cast<QT_PREPEND_NAMESPACE(QMouseEvent*)>(event)); - return true; - case QEvent::KeyPress: - return keyPressEvent(static_cast<QT_PREPEND_NAMESPACE(QKeyEvent)*>(event)); - case QEvent::KeyRelease: - return keyReleaseEvent(static_cast<QT_PREPEND_NAMESPACE(QKeyEvent)*>(event)); - default: - return QObject::eventFilter(receiver, event); - } -} - -void CameraController::onUpdate() -{ - update(1.0 / 60.0); -} - -} // namespace Input -} // namespace Qt3DInput - -QT_END_NAMESPACE diff --git a/src/input/backend/cameracontroller_p.h b/src/input/backend/cameracontroller_p.h deleted file mode 100644 index a539aa586..000000000 --- a/src/input/backend/cameracontroller_p.h +++ /dev/null @@ -1,175 +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 CAMERA_CONTROLLER_H -#define CAMERA_CONTROLLER_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QObject> - -#include <QPoint> -#include <QtGui/qvector3d.h> - -QT_BEGIN_NAMESPACE - -class QMouseEvent; -class QWheelEvent; -class QKeyEvent; -class QTimer; - -namespace Qt3DCore { -class QCamera; -class QEntity; -} - -namespace Qt3DInput { -namespace Input { - -class CameraController : public QObject -{ - Q_OBJECT - - Q_PROPERTY( float linearSpeed READ linearSpeed WRITE setLinearSpeed NOTIFY linearSpeedChanged ) - Q_PROPERTY( float orbitRate READ orbitRate WRITE setOrbitRate NOTIFY orbitRateChanged ) - Q_PROPERTY( float lookRate READ lookRate WRITE setLookRate NOTIFY lookRateChanged ) - Q_PROPERTY( bool multisampleEnabled READ isMultisampleEnabled NOTIFY multisampleEnabledChanged ) - - Q_PROPERTY( ControlMode controlMode READ controlMode WRITE setControlMode NOTIFY controlModeChanged ) - Q_PROPERTY( QVector3D firstPersonUpVector READ firstPersonUpVector WRITE setFirstPersonUpVector NOTIFY firstPersonUpVectorChanged ) - -public: - explicit CameraController(QObject *parent = 0); - - void setCamera( Qt3DCore::QCamera* cam ); - Qt3DCore::QCamera *camera() const; - - void setLinearSpeed( float speed ); - float linearSpeed() const; - - float orbitRate() const; - void setOrbitRate( float rate ); - - float lookRate() const; - void setLookRate( float rate ); - - void mousePressEvent( QMouseEvent* aEvent ); - void mouseReleaseEvent( QMouseEvent* aEvent ); - void mouseMoveEvent( QMouseEvent* aEvent ); - - bool keyPressEvent( QKeyEvent* aEvent ); - bool keyReleaseEvent( QKeyEvent* aEvent ); - - void update( double t ); - - bool isMultisampleEnabled() const; - - enum ControlMode { - FreeLook, - FirstPerson - }; - Q_ENUM(ControlMode) - - void setControlMode( ControlMode controlMode ); - ControlMode controlMode() const; - - void setFirstPersonUpVector( const QVector3D &up ); - QVector3D firstPersonUpVector() const; - -public Q_SLOTS: - void toggleMSAA(); - -protected: - bool eventFilter(QObject *receiver, QEvent *event) Q_DECL_OVERRIDE; - -Q_SIGNALS: - void linearSpeedChanged(float speed); - void orbitRateChanged(float rate); - void lookRateChanged(float rate); - - void multisampleEnabledChanged(bool enabled); - - void controlModeChanged(ControlMode controlMode); - void firstPersonUpVectorChanged(const QVector3D &up); - -private Q_SLOTS: - void onUpdate(); - -private: - Qt3DCore::QCamera* m_camera; - Qt3DCore::QEntity* m_cameraEntity; - - float m_vx; - float m_vy; - float m_vz; - bool m_viewCenterFixed; - float m_panAngle; - float m_tiltAngle; - - bool m_leftButtonPressed; - QPoint m_prevPos; - QPoint m_pos; - bool m_orbitMode; - - float m_linearSpeed; - float m_time; - float m_orbitRate; - float m_lookRate; - - bool m_translateFast; - bool m_multisampleEnabled; - - ControlMode m_controlMode; - QVector3D m_firstPersonUp; - - QTimer *m_updateTimer; -}; - -} // namespace Input -} // namespace Qt3DInput - -QT_END_NAMESPACE - -#endif // of CAMERA_CONTROLLER_H diff --git a/src/input/backend/updatehandlerjob.cpp b/src/input/backend/updatehandlerjob.cpp index 08b2633cb..3f9dec326 100644 --- a/src/input/backend/updatehandlerjob.cpp +++ b/src/input/backend/updatehandlerjob.cpp @@ -86,8 +86,10 @@ void UpdateHandlerJob::run() // If so -> add to notification payload LogicalDevice *logicalDevice = m_handler->logicalDeviceManager()->data(m_logicalDeviceHandle); - updateActions(logicalDevice); - updateAxes(logicalDevice); + if (logicalDevice) { + updateActions(logicalDevice); + updateAxes(logicalDevice); + } } void UpdateHandlerJob::updateAxes(LogicalDevice *device) diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp index 942ac9250..b1889be66 100644 --- a/src/input/frontend/qinputaspect.cpp +++ b/src/input/frontend/qinputaspect.cpp @@ -36,7 +36,6 @@ #include "qinputaspect.h" #include "qinputaspect_p.h" -#include "cameracontroller_p.h" #include "inputhandler_p.h" #include "keyboardcontroller_p.h" #include "keyboardinput_p.h" @@ -95,7 +94,6 @@ namespace Qt3DInput { QInputAspectPrivate::QInputAspectPrivate() : QAbstractAspectPrivate() , m_inputHandler(new Input::InputHandler()) - , m_cameraController(new Input::CameraController()) , m_keyboardMouseIntegration(new Input::KeyboardMouseGenericDeviceIntegration(m_inputHandler.data())) { } @@ -149,12 +147,6 @@ void QInputAspect::loadInputDevicePlugins() } } -Qt3DCore::QCamera *QInputAspect::camera() const -{ - Q_D(const QInputAspect); - return d->m_cameraController->camera(); -} - // Note: caller is responsible for ownership QAbstractPhysicalDevice *QInputAspect::createPhysicalDevice(const QString &name) { @@ -167,12 +159,6 @@ QAbstractPhysicalDevice *QInputAspect::createPhysicalDevice(const QString &name) return device; } -void QInputAspect::setCamera(Qt3DCore::QCamera *camera) -{ - Q_D(QInputAspect); - d->m_cameraController->setCamera(camera); -} - QVector<QAspectJobPtr> QInputAspect::jobsToExecute(qint64 time) { Q_UNUSED(time); @@ -219,7 +205,6 @@ void QInputAspect::onInitialize(const QVariantMap &) { Q_D(QInputAspect); Qt3DCore::QEventFilterService *eventService = d->services()->eventFilterService(); - eventService->registerEventFilter(d->m_cameraController.data(), 128); d->m_inputHandler->registerEventFilters(eventService); } diff --git a/src/input/frontend/qinputaspect.h b/src/input/frontend/qinputaspect.h index 7a5b298af..91d8e25d9 100644 --- a/src/input/frontend/qinputaspect.h +++ b/src/input/frontend/qinputaspect.h @@ -42,10 +42,6 @@ QT_BEGIN_NAMESPACE -namespace Qt3DCore { -class QCamera; -} - namespace Qt3DInput { class QAbstractPhysicalDevice; @@ -55,18 +51,11 @@ class QInputDeviceIntegration; class QT3DINPUTSHARED_EXPORT QInputAspect : public Qt3DCore::QAbstractAspect { Q_OBJECT - Q_PROPERTY(Qt3DCore::QCamera* camera READ camera WRITE setCamera) public: explicit QInputAspect(QObject *parent = 0); - - Qt3DCore::QCamera *camera() const; QAbstractPhysicalDevice *createPhysicalDevice(const QString &name); - QVector<Qt3DCore::QAspectJobPtr> jobsToExecute(qint64 time) Q_DECL_OVERRIDE; -public Q_SLOTS: - void setCamera(Qt3DCore::QCamera *camera); - private: void onInitialize(const QVariantMap &data) Q_DECL_OVERRIDE; void onCleanup() Q_DECL_OVERRIDE; diff --git a/src/input/frontend/qinputaspect_p.h b/src/input/frontend/qinputaspect_p.h index 4a21cb253..b7a5117ee 100644 --- a/src/input/frontend/qinputaspect_p.h +++ b/src/input/frontend/qinputaspect_p.h @@ -57,7 +57,6 @@ namespace Qt3DInput { class QInputAspect; namespace Input { -class CameraController; class InputHandler; class KeyboardMouseGenericDeviceIntegration; } @@ -69,7 +68,6 @@ public: Q_DECLARE_PUBLIC(QInputAspect) QScopedPointer<Input::InputHandler> m_inputHandler; - QScopedPointer<Input::CameraController> m_cameraController; QScopedPointer<Input::KeyboardMouseGenericDeviceIntegration> m_keyboardMouseIntegration; }; diff --git a/src/plugins/sceneparsers/assimp/assimpparser.cpp b/src/plugins/sceneparsers/assimp/assimpparser.cpp index 040fc3a8a..31f81fa3d 100644 --- a/src/plugins/sceneparsers/assimp/assimpparser.cpp +++ b/src/plugins/sceneparsers/assimp/assimpparser.cpp @@ -38,7 +38,7 @@ #include <Qt3DCore/qentity.h> #include <Qt3DCore/qtransform.h> -#include <Qt3DCore/qcameralens.h> +#include <Qt3DRender/qcameralens.h> #include <Qt3DRender/qparameter.h> #include <Qt3DRender/qeffect.h> #include <Qt3DRender/qmesh.h> diff --git a/src/plugins/sceneparsers/gltf/gltfparser.cpp b/src/plugins/sceneparsers/gltf/gltfparser.cpp index 6bfca2b55..a37fd9c0b 100644 --- a/src/plugins/sceneparsers/gltf/gltfparser.cpp +++ b/src/plugins/sceneparsers/gltf/gltfparser.cpp @@ -44,7 +44,7 @@ #include <QtGui/QVector2D> -#include <Qt3DCore/QCameraLens> +#include <Qt3DRender/QCameraLens> #include <Qt3DCore/QEntity> #include <Qt3DCore/QTransform> diff --git a/src/plugins/sceneparsers/gltf/gltfparser.h b/src/plugins/sceneparsers/gltf/gltfparser.h index be8bcaa50..544aff41c 100644 --- a/src/plugins/sceneparsers/gltf/gltfparser.h +++ b/src/plugins/sceneparsers/gltf/gltfparser.h @@ -61,13 +61,13 @@ QT_BEGIN_NAMESPACE class QFile; namespace Qt3DCore { -class QCamera; -class QCameraLens; class QEntity; } namespace Qt3DRender { +class QCamera; +class QCameraLens; class QMaterial; class QShaderProgram; class QEffect; @@ -142,7 +142,7 @@ private: Qt3DCore::QEntity *defaultScene(); QMaterial *material(const QString &id); - Qt3DCore::QCameraLens *camera(const QString &id) const; + QCameraLens *camera(const QString &id) const; void parse(); void cleanup(); diff --git a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp index 04e7eab1e..c8b1a64e0 100644 --- a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp +++ b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp @@ -35,8 +35,6 @@ ****************************************************************************/ #include "qt3dquick3dcoreplugin.h" -#include <Qt3DCore/qcameralens.h> -#include <Qt3DCore/qcamera.h> #include <Qt3DCore/qtransform.h> #include <private/quick3dentity_p.h> #include <private/quick3dentityloader_p.h> @@ -64,8 +62,6 @@ void Qt3DQuick3DCorePlugin::registerTypes(const char *uri) // Ideally we want to make Node an uncreatable type // We would need qmlRegisterUncreatableExtendedType for that qmlRegisterExtendedUncreatableType<Qt3DCore::QNode, Qt3DCore::Quick::Quick3DNode>(uri, 2, 0, "Node", QStringLiteral("Node is a base class")); - Qt3DCore::Quick::registerExtendedType<Qt3DCore::QCamera, Qt3DCore::Quick::Quick3DNode>("QCamera", "Qt3D.Core/Camera", uri, 2, 0, "Camera"); - qmlRegisterType<Qt3DCore::QCameraLens>(uri, 2, 0, "CameraLens"); } QT_END_NAMESPACE diff --git a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp index 09172c89e..48f458396 100644 --- a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp +++ b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp @@ -106,6 +106,8 @@ #include <Qt3DRender/qlighting.h> #include <Qt3DRender/qdispatchcompute.h> #include <Qt3DRender/qcomputejob.h> +#include <Qt3DRender/qcameralens.h> +#include <Qt3DRender/qcamera.h> #include <Qt3DQuickRender/private/quick3dtechnique_p.h> #include <Qt3DQuickRender/private/quick3dmaterial_p.h> #include <Qt3DQuickRender/private/quick3dtechniquefilter_p.h> @@ -191,6 +193,10 @@ void Qt3DQuick3DRenderPlugin::registerTypes(const char *uri) qmlRegisterType<Qt3DRender::Render::Quick::Quick3DShaderDataArray>(uri, 2, 0, "ShaderDataArray"); qmlRegisterType<Qt3DRender::Render::Quick::Quick3DShaderData>(uri, 2, 0, "ShaderData"); + // Camera + qmlRegisterType<Qt3DRender::QCamera>(uri, 2, 0, "Camera"); + qmlRegisterType<Qt3DRender::QCameraLens>(uri, 2, 0, "CameraLens"); + // Textures qmlRegisterType<Qt3DRender::QTextureWrapMode>(uri, 2, 0, "WrapMode");//, QStringLiteral("QTextureWrapMode cannot be created from QML")); qmlRegisterUncreatableType<Qt3DRender::QAbstractTextureProvider>(uri, 2, 0, "Texture", QStringLiteral("Texture should be created from one of the subclasses")); diff --git a/src/render/backend/cameralens.cpp b/src/render/backend/cameralens.cpp index 3d039f298..34ba8f399 100644 --- a/src/render/backend/cameralens.cpp +++ b/src/render/backend/cameralens.cpp @@ -38,7 +38,7 @@ #include <Qt3DRender/private/renderlogging_p.h> #include <Qt3DCore/qtransform.h> -#include <Qt3DCore/qcameralens.h> +#include <Qt3DRender/qcameralens.h> #include <Qt3DCore/qentity.h> #include <Qt3DCore/qscenepropertychange.h> diff --git a/src/render/backend/entity.cpp b/src/render/backend/entity.cpp index e1fc32160..36e7654b3 100644 --- a/src/render/backend/entity.cpp +++ b/src/render/backend/entity.cpp @@ -50,7 +50,7 @@ #include <Qt3DRender/qcomputejob.h> #include <Qt3DRender/private/geometryrenderermanager_p.h> -#include <Qt3DCore/qcameralens.h> +#include <Qt3DRender/qcameralens.h> #include <Qt3DCore/qentity.h> #include <Qt3DCore/qscenepropertychange.h> #include <Qt3DCore/qtransform.h> diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp index aa511fc70..81bf16a18 100644 --- a/src/render/backend/renderer.cpp +++ b/src/render/backend/renderer.cpp @@ -77,7 +77,7 @@ #include <Qt3DRender/private/geometryrenderermanager_p.h> #include <Qt3DRender/private/openglvertexarrayobject_p.h> -#include <Qt3DCore/qcameralens.h> +#include <Qt3DRender/qcameralens.h> #include <Qt3DCore/private/qeventfilterservice_p.h> #include <Qt3DCore/private/qabstractaspectjobmanager_p.h> diff --git a/src/core/core-components/qcamera.cpp b/src/render/frontend/qcamera.cpp index c83371189..e2aa2f4e1 100644 --- a/src/core/core-components/qcamera.cpp +++ b/src/render/frontend/qcamera.cpp @@ -39,34 +39,34 @@ QT_BEGIN_NAMESPACE -namespace Qt3DCore { +namespace Qt3DRender { /*! - \class Qt3DCore::QCameraPrivate + \class Qt3DRender::QCameraPrivate \internal */ QCameraPrivate::QCameraPrivate() - : QEntityPrivate() + : Qt3DCore::QEntityPrivate() , m_position(0.0f, 0.0f, 0.0f) , m_viewCenter(0.0f, 0.0f, -100.0f) , m_upVector(0.0f, 1.0f, 0.0f) , m_cameraToCenter(m_viewCenter - m_position) , m_viewMatrixDirty(false) , m_lens(new QCameraLens()) - , m_transform(new QTransform()) + , m_transform(new Qt3DCore::QTransform()) { } /*! \qmltype Camera - \instantiates Qt3DCore::QCamera + \instantiates Qt3DRender::QCamera \inherits Entity \inqmlmodule Qt3D.Core \since 5.5 */ -QCamera::QCamera(QNode *parent) - : QEntity(*new QCameraPrivate, parent) +QCamera::QCamera(Qt3DCore::QNode *parent) + : Qt3DCore::QEntity(*new QCameraPrivate, parent) { QObject::connect(d_func()->m_lens, SIGNAL(projectionTypeChanged(QCameraLens::ProjectionType)), this, SIGNAL(projectionTypeChanged(QCameraLens::ProjectionType))); QObject::connect(d_func()->m_lens, SIGNAL(nearPlaneChanged(float)), this, SIGNAL(nearPlaneChanged(float))); @@ -89,8 +89,8 @@ QCamera::~QCamera() } /*! \internal */ -QCamera::QCamera(QCameraPrivate &dd, QNode *parent) - : QEntity(dd, parent) +QCamera::QCamera(QCameraPrivate &dd, Qt3DCore::QNode *parent) + : Qt3DCore::QEntity(dd, parent) { QObject::connect(d_func()->m_lens, SIGNAL(projectionTypeChanged(QCameraLens::ProjectionType)), this, SIGNAL(projectionTypeChanged(QCameraLens::ProjectionType))); QObject::connect(d_func()->m_lens, SIGNAL(nearPlaneChanged(float)), this, SIGNAL(nearPlaneChanged(float))); @@ -113,7 +113,7 @@ QCameraLens *QCamera::lens() const return d->m_lens; } -QTransform *QCamera::transform() const +Qt3DCore::QTransform *QCamera::transform() const { Q_D(const QCamera); return d->m_transform; @@ -481,6 +481,6 @@ QMatrix4x4 QCamera::viewMatrix() const return d->m_transform->matrix(); } -} // Qt3D +} // Qt3DRender QT_END_NAMESPACE diff --git a/src/core/core-components/qcamera.h b/src/render/frontend/qcamera.h index f09281c50..737b7415a 100644 --- a/src/core/core-components/qcamera.h +++ b/src/render/frontend/qcamera.h @@ -34,11 +34,12 @@ ** ****************************************************************************/ -#ifndef QT3DCORE_CAMERA_H -#define QT3DCORE_CAMERA_H +#ifndef QT3DRENDER_CAMERA_H +#define QT3DRENDER_CAMERA_H #include <Qt3DCore/qentity.h> -#include <Qt3DCore/qcameralens.h> +#include <Qt3DRender/qt3drender_global.h> +#include <Qt3DRender/qcameralens.h> #include <QMatrix4x4> #include <QQuaternion> #include <QVector3D> @@ -46,16 +47,19 @@ QT_BEGIN_NAMESPACE namespace Qt3DCore { - -class QLookAtTransform; +class QEntity; class QTransform; +} + +namespace Qt3DRender { class QCameraPrivate; -class QT3DCORESHARED_EXPORT QCamera : public QEntity + +class QT3DRENDERSHARED_EXPORT QCamera : public Qt3DCore::QEntity { Q_OBJECT // CameraLens - Q_PROPERTY(Qt3DCore::QCameraLens::ProjectionType projectionType READ projectionType WRITE setProjectionType NOTIFY projectionTypeChanged) + Q_PROPERTY(Qt3DRender::QCameraLens::ProjectionType projectionType READ projectionType WRITE setProjectionType NOTIFY projectionTypeChanged) Q_PROPERTY(float nearPlane READ nearPlane WRITE setNearPlane NOTIFY nearPlaneChanged) Q_PROPERTY(float farPlane READ farPlane WRITE setFarPlane NOTIFY farPlaneChanged) Q_PROPERTY(float fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY fieldOfViewChanged) @@ -83,7 +87,7 @@ public: Q_ENUM(CameraTranslationOption) QCameraLens *lens() const; - QTransform *transform() const; + Qt3DCore::QTransform *transform() const; QQuaternion tiltRotation(float angle) const; QQuaternion panRotation(float angle) const; @@ -162,8 +166,8 @@ protected: QCamera(QCameraPrivate &dd, QNode *parent = 0); }; -} // namespace Qt3DCore +} // namespace Qt3DRender QT_END_NAMESPACE -#endif // QT3DCORE_CAMERA_H +#endif // QT3DRENDER_CAMERA_H diff --git a/src/core/core-components/qcamera_p.h b/src/render/frontend/qcamera_p.h index c64b4a5ab..5ecb1a047 100644 --- a/src/core/core-components/qcamera_p.h +++ b/src/render/frontend/qcamera_p.h @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#ifndef QT3DCORE_CAMERA_P_H -#define QT3DCORE_CAMERA_P_H +#ifndef QT3DRENDER_CAMERA_P_H +#define QT3DRENDER_CAMERA_P_H // // W A R N I N G @@ -48,15 +48,15 @@ // We mean it. // -#include <Qt3DCore/qcameralens.h> +#include <Qt3DRender/qcameralens.h> #include <Qt3DCore/qtransform.h> #include <private/qentity_p.h> QT_BEGIN_NAMESPACE -namespace Qt3DCore { +namespace Qt3DRender { -class QCameraPrivate : public QEntityPrivate +class QCameraPrivate : public Qt3DCore::QEntityPrivate { public: QCameraPrivate(); @@ -79,11 +79,11 @@ public: // Components QCameraLens *m_lens; - QTransform *m_transform; + Qt3DCore::QTransform *m_transform; }; -} // namespace Qt3DCore +} // namespace Qt3DRender QT_END_NAMESPACE -#endif // QT3DCORE_CAMERA_P_H +#endif // QT3DRENDER_CAMERA_P_H diff --git a/src/core/core-components/qcameralens.cpp b/src/render/frontend/qcameralens.cpp index d544d8767..3eb9619ec 100644 --- a/src/core/core-components/qcameralens.cpp +++ b/src/render/frontend/qcameralens.cpp @@ -39,14 +39,14 @@ QT_BEGIN_NAMESPACE -namespace Qt3DCore { +namespace Qt3DRender { /*! - \class Qt3DCore::QCameraLensPrivate + \class Qt3DRender::QCameraLensPrivate \internal */ QCameraLensPrivate::QCameraLensPrivate() - : QComponentPrivate() + : Qt3DCore::QComponentPrivate() , m_projectionType(QCameraLens::OrthographicProjection) , m_nearPlane(0.1f) , m_farPlane(1024.0f) @@ -60,7 +60,7 @@ QCameraLensPrivate::QCameraLensPrivate() } QCameraLens::QCameraLens(QNode *parent) - : QComponent(*new QCameraLensPrivate, parent) + : Qt3DCore::QComponent(*new QCameraLensPrivate, parent) { Q_D(QCameraLens); d->updateProjectionMatrix(); @@ -87,10 +87,10 @@ void QCameraLens::copy(const QNode *ref) d_func()->m_projectionMatrix = lens->d_func()->m_projectionMatrix; } -/*! \class Qt3DCore::QCameraLens +/*! \class Qt3DRender::QCameraLens * \inmodule Qt3DCore * - * \brief Qt3DCore::QCameraLens specifies the projection matrix that will be used to + * \brief Qt3DRender::QCameraLens specifies the projection matrix that will be used to * define a Camera for a 3D scene. * * \since 5.5 @@ -105,8 +105,8 @@ QCameraLens::QCameraLens(QCameraLensPrivate &dd, QNode *parent) /*! * Sets the lens' projection type \a projectionType. * - * \note Qt3DCore::QCameraLens::Frustum and - * Qt3DCore::QCameraLens::PerspectiveProjection are two different ways of + * \note Qt3DRender::QCameraLens::Frustum and + * Qt3DRender::QCameraLens::PerspectiveProjection are two different ways of * specifying the same projection. */ void QCameraLens::setProjectionType(QCameraLens::ProjectionType projectionType) @@ -239,7 +239,7 @@ float QCameraLens::farPlane() const * a projection matrix update. * * \note this has no effect if the projection type is not - * Qt3DCore::QCameraLens::PerspectiveProjection. + * Qt3DRender::QCameraLens::PerspectiveProjection. */ void QCameraLens::setFieldOfView(float fieldOfView) { @@ -255,7 +255,7 @@ void QCameraLens::setFieldOfView(float fieldOfView) * Returns the projection's field of view in degrees. * * \note: The return value may be undefined if the projection type is not - * Qt3DCore::QCameraLens::PerspectiveProjection. + * Qt3DRender::QCameraLens::PerspectiveProjection. */ float QCameraLens::fieldOfView() const { @@ -268,7 +268,7 @@ float QCameraLens::fieldOfView() const * matrix update. * * \note this has no effect if the projection type is not - * Qt3DCore::QCameraLens::PerspectiveProjection. + * Qt3DRender::QCameraLens::PerspectiveProjection. */ void QCameraLens::setAspectRatio(float aspectRatio) { @@ -284,7 +284,7 @@ void QCameraLens::setAspectRatio(float aspectRatio) * Returns the projection's aspect ratio. * * \note: The return value may be undefined if the projection type is not - * Qt3DCore::QCameraLens::PerspectiveProjection. + * Qt3DRender::QCameraLens::PerspectiveProjection. */ float QCameraLens::aspectRatio() const { @@ -297,7 +297,7 @@ float QCameraLens::aspectRatio() const * triggers a projection matrix update. * * \note this has no effect if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. + * Qt3DRender::QCameraLens::PerspectiveProjection. */ void QCameraLens::setLeft(float left) { @@ -313,7 +313,7 @@ void QCameraLens::setLeft(float left) * Returns the lower left window coordinate of the projection. * * \note The return value may be undefined if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. + * Qt3DRender::QCameraLens::PerspectiveProjection. */ float QCameraLens::left() const { @@ -326,7 +326,7 @@ float QCameraLens::left() const * a projection matrix update. * * \note this has no effect if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. + * Qt3DRender::QCameraLens::PerspectiveProjection. */ void QCameraLens::setRight(float right) { @@ -342,7 +342,7 @@ void QCameraLens::setRight(float right) * Returns the upper right window coordinate of the projection. * * \note The return value may be undefined if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. + * Qt3DRender::QCameraLens::PerspectiveProjection. */ float QCameraLens::right() const { @@ -355,7 +355,7 @@ float QCameraLens::right() const * projection matrix update. * * \note this has no effect if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. + * Qt3DRender::QCameraLens::PerspectiveProjection. */ void QCameraLens::setBottom(float bottom) { @@ -371,7 +371,7 @@ void QCameraLens::setBottom(float bottom) * Returns the bottom window coordinate of the projection. * * \note The return value may be undefined if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. + * Qt3DRender::QCameraLens::PerspectiveProjection. */ float QCameraLens::bottom() const { @@ -384,7 +384,7 @@ float QCameraLens::bottom() const * projection matrix update. * * \note this has no effect if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. + * Qt3DRender::QCameraLens::PerspectiveProjection. */ void QCameraLens::setTop(float top) { @@ -400,7 +400,7 @@ void QCameraLens::setTop(float top) * Returns the bottom window coordinate of the projection. * * \note The return value may be undefined if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. + * Qt3DRender::QCameraLens::PerspectiveProjection. */ float QCameraLens::top() const { @@ -417,11 +417,11 @@ QMatrix4x4 QCameraLens::projectionMatrix() const return d->m_projectionMatrix; } -} // Qt3D +} // Qt3DRender /*! \qmltype CameraLens - \instantiates Qt3DCore::QCameraLens + \instantiates Qt3DRender::QCameraLens \inqmlmodule Qt3D.Core \inherits Component3D \since 5.5 diff --git a/src/core/core-components/qcameralens.h b/src/render/frontend/qcameralens.h index 120148e29..6663bfb5c 100644 --- a/src/core/core-components/qcameralens.h +++ b/src/render/frontend/qcameralens.h @@ -34,11 +34,11 @@ ** ****************************************************************************/ -#ifndef QT3DCORE_CAMERALENS_H -#define QT3DCORE_CAMERALENS_H +#ifndef QT3DRENDER_CAMERALENS_H +#define QT3DRENDER_CAMERALENS_H #include <Qt3DCore/qcomponent.h> -#include <Qt3DCore/qt3dcore_global.h> +#include <Qt3DRender/qt3drender_global.h> #include <QMatrix4x4> #include <QQuaternion> @@ -46,11 +46,11 @@ QT_BEGIN_NAMESPACE -namespace Qt3DCore { +namespace Qt3DRender { class QCameraLensPrivate; -class QT3DCORESHARED_EXPORT QCameraLens : public QComponent +class QT3DRENDERSHARED_EXPORT QCameraLens : public Qt3DCore::QComponent { Q_OBJECT Q_PROPERTY(ProjectionType projectionType READ projectionType WRITE setProjectionType NOTIFY projectionTypeChanged) @@ -130,8 +130,8 @@ private: QT3D_CLONEABLE(QCameraLens) }; -} // Qt3D +} // Qt3DRender QT_END_NAMESPACE -#endif // CAMERALENS_H +#endif // QT3DRENDER_CAMERALENS_H diff --git a/src/core/core-components/qcameralens_p.h b/src/render/frontend/qcameralens_p.h index 02cc292bb..f201f75e3 100644 --- a/src/core/core-components/qcameralens_p.h +++ b/src/render/frontend/qcameralens_p.h @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#ifndef QT3DCORE_CAMERALENS_P_H -#define QT3DCORE_CAMERALENS_P_H +#ifndef QT3DRENDER_CAMERALENS_P_H +#define QT3DRENDER_CAMERALENS_P_H // // W A R N I N G @@ -57,9 +57,9 @@ QT_BEGIN_NAMESPACE -namespace Qt3DCore { +namespace Qt3DRender { -class QCameraLensPrivate : public QComponentPrivate +class QCameraLensPrivate : public Qt3DCore::QComponentPrivate { public: QCameraLensPrivate(); @@ -122,8 +122,8 @@ private: } }; -} // namespace Qt3DCore +} // namespace Qt3DRender QT_END_NAMESPACE -#endif // QT3DCORE_CAMERALENS_P_H +#endif // QT3DRENDER_CAMERALENS_P_H diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp index 7ca1170c4..15fbe4384 100644 --- a/src/render/frontend/qrenderaspect.cpp +++ b/src/render/frontend/qrenderaspect.cpp @@ -63,7 +63,7 @@ #include <Qt3DRender/qshaderdata.h> #include <Qt3DRender/qstateset.h> #include <Qt3DRender/qnodraw.h> -#include <Qt3DCore/qcameralens.h> +#include <Qt3DRender/qcameralens.h> #include <Qt3DRender/qattribute.h> #include <Qt3DRender/qbuffer.h> #include <Qt3DRender/qgeometry.h> @@ -248,7 +248,7 @@ void QRenderAspect::registerBackendTypes() registerBackendType<QShaderProgram>(QBackendNodeFunctorPtr(new Render::NodeFunctor<Render::Shader, Render::ShaderManager>(d->m_nodeManagers->shaderManager()))); registerBackendType<QEffect>(QBackendNodeFunctorPtr(new Render::NodeFunctor<Render::Effect, Render::EffectManager>(d->m_nodeManagers->effectManager()))); registerBackendType<QAnnotation>(QBackendNodeFunctorPtr(new Render::NodeFunctor<Render::Annotation, Render::CriterionManager>(d->m_nodeManagers->criterionManager()))); - registerBackendType<Qt3DCore::QCameraLens>(QBackendNodeFunctorPtr(new Render::NodeFunctor<Render::CameraLens, Render::CameraManager>(d->m_nodeManagers->cameraManager()))); + registerBackendType<Qt3DRender::QCameraLens>(QBackendNodeFunctorPtr(new Render::NodeFunctor<Render::CameraLens, Render::CameraManager>(d->m_nodeManagers->cameraManager()))); registerBackendType<QLayer>(QBackendNodeFunctorPtr(new Render::NodeFunctor<Render::Layer, Render::LayerManager>(d->m_nodeManagers->layerManager()))); registerBackendType<QRenderPass>(QBackendNodeFunctorPtr(new Render::NodeFunctor<Render::RenderPass, Render::RenderPassManager>(d->m_nodeManagers->renderPassManager()))); registerBackendType<QAbstractSceneLoader>(QBackendNodeFunctorPtr(new Render::RenderSceneFunctor(d->m_nodeManagers->sceneManager()))); diff --git a/src/render/frontend/qwindow.cpp b/src/render/frontend/qwindow.cpp deleted file mode 100644 index 1d7889cdb..000000000 --- a/src/render/frontend/qwindow.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindow.h" -#include "qwindow_p.h" - -#include <Qt3DCore/qaspectengine.h> -#include <Qt3DCore/qentity.h> -#include <Qt3DCore/qcamera.h> -#include <Qt3DRender/qframegraph.h> -#include <Qt3DRender/qrenderaspect.h> -#include <Qt3DRender/qforwardrenderer.h> -#include <QOpenGLContext> - -QT_BEGIN_NAMESPACE - -using namespace Qt3DCore; - -namespace Qt3DRender { - -QWindowPrivate::QWindowPrivate() - : ::QWindowPrivate() - , m_initialized(false) - , m_root(new QEntity()) - , m_userRoot(Q_NULLPTR) - , m_defaultCamera(new QCamera()) - , m_frameGraph(Q_NULLPTR) - , m_engine(new QAspectEngine()) - , m_renderAspect(new QRenderAspect()) -{ - m_engine->registerAspect(m_renderAspect); - - // TO DO: Find a nice way to set the camera on the controller which is in - // the input aspect -} - -QWindow::QWindow(::QWindow *parent) - : ::QWindow(*new QWindowPrivate(), parent) -{ - 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(); -} - -QWindow::QWindow(QWindowPrivate &dd, ::QWindow *parent) - : ::QWindow(dd, parent) -{ - 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(); -} - -void QWindow::resizeEvent(QResizeEvent *) -{ - Q_D(QWindow); - d->m_defaultCamera->setAspectRatio(float(width()) / float(height())); -} - -QWindow::~QWindow() -{ -} - -void QWindow::setFrameGraph(QFrameGraph *frameGraph) -{ - Q_ASSERT(!isVisible()); - Q_D(QWindow); - d->m_frameGraph = frameGraph; -} - -QFrameGraph *QWindow::frameGraph() const -{ - Q_D(const QWindow); - return d->m_frameGraph; -} - -Qt3DCore::QCamera *QWindow::defaultCamera() -{ - Q_D(const QWindow); - return d->m_defaultCamera; -} - -void QWindow::registerAspect(Qt3DCore::QAbstractAspect *aspect) -{ - Q_ASSERT(!isVisible()); - Q_D(QWindow); - d->m_engine->registerAspect(aspect); -} - -void QWindow::registerAspect(const QString &name) -{ - Q_ASSERT(!isVisible()); - Q_D(QWindow); - d->m_engine->registerAspect(name); -} - -void QWindow::setRootEntity(Qt3DCore::QEntity *root) -{ - Q_ASSERT(!isVisible()); - Q_D(QWindow); - d->m_userRoot = root; -} - -void QWindow::showEvent(QShowEvent *event) -{ - Q_D(QWindow); - - if (!d->m_initialized) { - if (d->m_userRoot != Q_NULLPTR) - d->m_userRoot->setParent(d->m_root); - - if (d->m_frameGraph == Q_NULLPTR) { - d->m_frameGraph = new QFrameGraph(); - QForwardRenderer *forwardRenderer = new QForwardRenderer(); - forwardRenderer->setCamera(d->m_defaultCamera); - d->m_frameGraph->setActiveFrameGraph(forwardRenderer); - } - - QVariantMap data; - data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(this))); - data.insert(QStringLiteral("eventSource"), QVariant::fromValue(this)); - d->m_engine->setData(data); - - d->m_root->addComponent(d->m_frameGraph); - d->m_engine->setRootEntity(d->m_root); - d->m_initialized = true; - } - - ::QWindow::showEvent(event); -} - -} // namespace Qt3DRender - -QT_END_NAMESPACE diff --git a/src/render/frontend/qwindow.h b/src/render/frontend/qwindow.h deleted file mode 100644 index 2a904de5e..000000000 --- a/src/render/frontend/qwindow.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_QWINDOW_H -#define QT3DRENDER_QWINDOW_H - -#include <QtGui/qwindow.h> -#include <Qt3DRender/qt3drender_global.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DCore { -class QAbstractAspect; -class QCamera; -class QEntity; -} - -namespace Qt3DRender { - -class QWindowPrivate; -class QFrameGraph; - -class QT3DRENDERSHARED_EXPORT QWindow : public ::QWindow -{ -public: - explicit QWindow(::QWindow *parent = Q_NULLPTR); - ~QWindow(); - - void setFrameGraph(QFrameGraph *frameGraph); - QFrameGraph *frameGraph() const; - Qt3DCore::QCamera *defaultCamera(); - - void registerAspect(Qt3DCore::QAbstractAspect *aspect); - void registerAspect(const QString &name); - - void setRootEntity(Qt3DCore::QEntity *root); - -protected: - QWindow(QWindowPrivate &dd, ::QWindow *parent = Q_NULLPTR); - void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; - -private: - Q_DECLARE_PRIVATE(QWindow) -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // QT3DRENDER_QWINDOW_H diff --git a/src/render/frontend/qwindow_p.h b/src/render/frontend/qwindow_p.h deleted file mode 100644 index b824bc787..000000000 --- a/src/render/frontend/qwindow_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DRENDER_QWINDOW_P_H -#define QT3DRENDER_QWINDOW_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtGui/private/qwindow_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DCore { -class QAspectEngine; -class QCamera; -class QEntity; -} - -namespace Qt3DRender { - -class QWindow; -class QFrameGraph; -class QRenderAspect; - -class QWindowPrivate : public ::QWindowPrivate -{ -public: - QWindowPrivate(); - - Q_DECLARE_PUBLIC(QWindow) - bool m_initialized; - Qt3DCore::QEntity *m_root; - Qt3DCore::QEntity * m_userRoot; - Qt3DCore::QCamera *m_defaultCamera; - QFrameGraph *m_frameGraph; - QScopedPointer<Qt3DCore::QAspectEngine> m_engine; - QRenderAspect *m_renderAspect; -}; - -} // namespace Qt3DRender - -QT_END_NAMESPACE - - -#endif // QT3DRENDER_QWINDOW_P_H - diff --git a/src/render/frontend/render-frontend.pri b/src/render/frontend/render-frontend.pri index 06dd7e3f5..01bf3e3f2 100644 --- a/src/render/frontend/render-frontend.pri +++ b/src/render/frontend/render-frontend.pri @@ -11,12 +11,14 @@ HEADERS += \ $$PWD/qrenderattachment_p.h \ $$PWD/qrendertarget.h \ $$PWD/qrendertarget_p.h \ - $$PWD/qwindow.h \ - $$PWD/qwindow_p.h \ $$PWD/sphere_p.h \ $$PWD/qboundingvolumedebug.h \ $$PWD/qcomputejob.h \ - $$PWD/qcomputejob_p.h + $$PWD/qcomputejob_p.h \ + $$PWD/qcamera_p.h \ + $$PWD/qcamera.h \ + $$PWD/qcameralens.h \ + $$PWD/qcameralens_p.h SOURCES += \ $$PWD/qabstractfunctor.cpp \ @@ -26,6 +28,7 @@ SOURCES += \ $$PWD/qlayer.cpp \ $$PWD/qrenderattachment.cpp \ $$PWD/qrendertarget.cpp \ - $$PWD/qwindow.cpp \ $$PWD/qboundingvolumedebug.cpp \ - $$PWD/qcomputejob.cpp + $$PWD/qcomputejob.cpp \ + $$PWD/qcamera.cpp \ + $$PWD/qcameralens.cpp diff --git a/tests/auto/render/entity/tst_entity.cpp b/tests/auto/render/entity/tst_entity.cpp index a6e713bc8..d32f3f393 100644 --- a/tests/auto/render/entity/tst_entity.cpp +++ b/tests/auto/render/entity/tst_entity.cpp @@ -37,7 +37,7 @@ #include <QtTest/QtTest> #include <Qt3DRender/private/entity_p.h> -#include <Qt3DCore/QCameraLens> +#include <Qt3DRender/QCameraLens> #include <Qt3DCore/QScenePropertyChange> #include <Qt3DCore/QTransform> diff --git a/tests/auto/render/raycasting/tst_raycasting.cpp b/tests/auto/render/raycasting/tst_raycasting.cpp index ad26d8011..5057c5655 100644 --- a/tests/auto/render/raycasting/tst_raycasting.cpp +++ b/tests/auto/render/raycasting/tst_raycasting.cpp @@ -42,7 +42,7 @@ #include <Qt3DRender/private/pickboundingvolumejob_p.h> #include <Qt3DRender/private/qboundingvolumeprovider_p.h> #include <Qt3DCore/qray3d.h> -#include <Qt3DCore/qcamera.h> +#include <Qt3DRender/qcamera.h> using namespace Qt3DCore; using namespace Qt3DRender; @@ -318,7 +318,7 @@ Sphere *tst_RayCasting::volumeAt(int index) void tst_RayCasting::mousePicking() { // GIVEN - Qt3DCore::QCamera camera; + Qt3DRender::QCamera camera; camera.setProjectionType(QCameraLens::PerspectiveProjection); camera.setFieldOfView(45.0f); camera.setAspectRatio(800.0/600.0f); diff --git a/tests/auto/render/triangleboundingvolume/tst_triangleboundingvolume.cpp b/tests/auto/render/triangleboundingvolume/tst_triangleboundingvolume.cpp index 5d6cd7711..d8457c947 100644 --- a/tests/auto/render/triangleboundingvolume/tst_triangleboundingvolume.cpp +++ b/tests/auto/render/triangleboundingvolume/tst_triangleboundingvolume.cpp @@ -39,8 +39,8 @@ #include <Qt3DRender/private/triangleboundingvolume_p.h> #include <Qt3DRender/private/qraycastingservice_p.h> #include <Qt3DCore/qray3d.h> -#include <Qt3DCore/qcameralens.h> -#include <Qt3DCore/qcamera.h> +#include <Qt3DRender/qcameralens.h> +#include <Qt3DRender/qcamera.h> #include <Qt3DRender/private/qboundingvolume_p.h> class tst_TriangleBoundingVolume : public QObject @@ -109,8 +109,8 @@ private Q_SLOTS: a, b, c); - Qt3DCore::QCamera camera; - camera.setProjectionType(Qt3DCore::QCameraLens::PerspectiveProjection); + Qt3DRender::QCamera camera; + camera.setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection); camera.setFieldOfView(45.0f); camera.setAspectRatio(800.0/600.0f); camera.setNearPlane(0.1f); diff --git a/tests/benchmarks/render/jobs/tst_bench_jobs.cpp b/tests/benchmarks/render/jobs/tst_bench_jobs.cpp index 73b864687..2ba06e0fb 100644 --- a/tests/benchmarks/render/jobs/tst_bench_jobs.cpp +++ b/tests/benchmarks/render/jobs/tst_bench_jobs.cpp @@ -37,7 +37,6 @@ #include <QtTest/QtTest> #include <QMatrix4x4> #include <Qt3DCore/QEntity> -#include <Qt3DCore/QCamera> #include <Qt3DCore/QTransform> #include <Qt3DRender/QMaterial> #include <Qt3DRender/QFrameGraph> @@ -47,6 +46,7 @@ #include <Qt3DRender/private/managers_p.h> #include <Qt3DCore/private/qresourcemanager_p.h> +#include <Qt3DRender/qcamera.h> #include <Qt3DRender/qrenderaspect.h> #include <Qt3DRender/private/qrenderaspect_p.h> #include <Qt3DRender/private/renderer_p.h> @@ -167,7 +167,7 @@ Qt3DCore::QEntity *buildBigScene() Qt3DCore::QEntity *root = new Qt3DCore::QEntity(); // Camera - Qt3DCore::QCamera *cameraEntity = new Qt3DCore::QCamera(root); + Qt3DRender::QCamera *cameraEntity = new Qt3DRender::QCamera(root); cameraEntity->setObjectName(QStringLiteral("cameraEntity")); cameraEntity->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f); cameraEntity->setPosition(QVector3D(0, -250.0f, -50.0f)); |