| 1 | // Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #include <QGuiApplication> |
| 5 | |
| 6 | #include <Qt3DCore/QAspectEngine> |
| 7 | #include <Qt3DRender/QCamera> |
| 8 | |
| 9 | #include <Qt3DInput/QInputAspect> |
| 10 | |
| 11 | #include <Qt3DRender/QRenderAspect> |
| 12 | #include <Qt3DExtras/QForwardRenderer> |
| 13 | |
| 14 | #include "examplescene.h" |
| 15 | #include <Qt3DExtras/qt3dwindow.h> |
| 16 | #include <Qt3DExtras/qfirstpersoncameracontroller.h> |
| 17 | |
| 18 | int main(int argc, char* argv[]) |
| 19 | { |
| 20 | QGuiApplication app(argc, argv); |
| 21 | Qt3DExtras::Qt3DWindow view; |
| 22 | |
| 23 | ExampleScene *sceneRoot = new ExampleScene(); |
| 24 | |
| 25 | // Scene Camera |
| 26 | Qt3DRender::QCamera *basicCamera = view.camera(); |
| 27 | basicCamera->setProjectionType(Qt3DRender::QCameraLens::PerspectiveProjection); |
| 28 | basicCamera->setAspectRatio(view.width() / view.height()); |
| 29 | basicCamera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f)); |
| 30 | basicCamera->setViewCenter(QVector3D(0.0f, 3.5f, 0.0f)); |
| 31 | basicCamera->setPosition(QVector3D(0.0f, 3.5f, 25.0f)); |
| 32 | |
| 33 | // For camera controls |
| 34 | Qt3DExtras::QFirstPersonCameraController *camController = new Qt3DExtras::QFirstPersonCameraController(sceneRoot); |
| 35 | camController->setCamera(basicCamera); |
| 36 | |
| 37 | view.setRootEntity(sceneRoot); |
| 38 | view.show(); |
| 39 | |
| 40 | return app.exec(); |
| 41 | } |