summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-01-05 12:22:57 +0100
committerSean Harmer <sean.harmer@kdab.com>2015-01-10 20:58:19 +0100
commit69123a4ca74cbc37a5c3eab1ee3c0ba14faa9062 (patch)
treec0cae61ba091f7d7e43efa697ef05a34a8a2ae28
parent15b78caa27a198567d06e4e42ae5f01203b29a1b (diff)
dynamicscene-cpp example
Demonstrate and ensure that dynamic element adding/removing from the scene is working. Change-Id: I83819fe813c3910c9a8e4460ef7147fc56421c74 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--examples/dynamicscene-cpp/boxentity.cpp113
-rw-r--r--examples/dynamicscene-cpp/boxentity.h89
-rw-r--r--examples/dynamicscene-cpp/dynamicscene-cpp.pro16
-rw-r--r--examples/dynamicscene-cpp/examplescene.cpp92
-rw-r--r--examples/dynamicscene-cpp/examplescene.h71
-rw-r--r--examples/dynamicscene-cpp/forwardrenderer.cpp61
-rw-r--r--examples/dynamicscene-cpp/forwardrenderer.h63
-rw-r--r--examples/dynamicscene-cpp/main.cpp87
-rw-r--r--examples/examples.pro3
9 files changed, 594 insertions, 1 deletions
diff --git a/examples/dynamicscene-cpp/boxentity.cpp b/examples/dynamicscene-cpp/boxentity.cpp
new file mode 100644
index 000000000..02afc14cf
--- /dev/null
+++ b/examples/dynamicscene-cpp/boxentity.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "boxentity.h"
+
+#include <qmath.h>
+
+BoxEntity::BoxEntity(QNode *parent)
+ : Qt3D::QEntity(parent)
+ , m_transform(new Qt3D::QTransform())
+ , m_translate(new Qt3D::QTranslateTransform())
+ , m_mesh(new Qt3D::QCuboidMesh())
+ , m_material(new Qt3D::QPhongMaterial())
+ , m_angle(0.0f)
+ , m_radius(1.0f)
+{
+ m_transform->addTransform(m_translate);
+
+ connect(m_material, SIGNAL(diffuseChanged()), this, SIGNAL(diffuseColorChanged()));
+ m_material->setAmbient(Qt::gray);
+ m_material->setSpecular(Qt::white);
+ m_material->setShininess(150.0f);
+
+ addComponent(m_transform);
+ addComponent(m_mesh);
+ addComponent(m_material);
+}
+
+void BoxEntity::setDiffuseColor(const QColor &diffuseColor)
+{
+ m_material->setDiffuse(diffuseColor);
+}
+
+void BoxEntity::setAngle(float arg)
+{
+ if (m_angle == arg)
+ return;
+
+ m_angle = arg;
+ emit angleChanged();
+ updateTransformation();
+}
+
+void BoxEntity::setRadius(float arg)
+{
+ if (m_radius == arg)
+ return;
+
+ m_radius = arg;
+ emit radiusChanged();
+ updateTransformation();
+}
+
+QColor BoxEntity::diffuseColor()
+{
+ return m_material->diffuse();
+}
+
+float BoxEntity::angle() const
+{
+ return m_angle;
+}
+
+float BoxEntity::radius() const
+{
+ return m_radius;
+}
+
+void BoxEntity::updateTransformation()
+{
+ m_translate->setTranslation(QVector3D(cosf(m_angle) * m_radius,
+ 1.0f,
+ sinf(m_angle) * m_radius));
+}
+
diff --git a/examples/dynamicscene-cpp/boxentity.h b/examples/dynamicscene-cpp/boxentity.h
new file mode 100644
index 000000000..bc936e19e
--- /dev/null
+++ b/examples/dynamicscene-cpp/boxentity.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BOXENTITY_H
+#define BOXENTITY_H
+
+#include <Qt3DCore/QEntity>
+#include <Qt3DCore/QTransform>
+#include <Qt3DCore/QTranslateTransform>
+#include <Qt3DCore/QScaleTransform>
+#include <Qt3DRenderer/QCuboidMesh>
+#include <Qt3DRenderer/QPhongMaterial>
+
+class BoxEntity : public Qt3D::QEntity
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QColor diffuseColor READ diffuseColor WRITE setDiffuseColor NOTIFY diffuseColorChanged)
+ Q_PROPERTY(float angle READ angle WRITE setAngle NOTIFY angleChanged)
+ Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged)
+
+public:
+ BoxEntity(QNode *parent = 0);
+
+ QColor diffuseColor();
+ float angle() const;
+ float radius() const;
+
+public Q_SLOTS:
+ void setDiffuseColor(const QColor &diffuseColor);
+ void setAngle(float arg);
+ void setRadius(float arg);
+
+Q_SIGNALS:
+ void diffuseColorChanged();
+ void angleChanged();
+ void radiusChanged();
+
+private:
+ void updateTransformation();
+
+ Qt3D::QTransform *m_transform;
+ Qt3D::QTranslateTransform *m_translate;
+ Qt3D::QScaleTransform *m_scale;
+ Qt3D::QCuboidMesh *m_mesh;
+ Qt3D::QPhongMaterial *m_material;
+ float m_angle;
+ float m_radius;
+};
+
+#endif // BOXENTITY_H
diff --git a/examples/dynamicscene-cpp/dynamicscene-cpp.pro b/examples/dynamicscene-cpp/dynamicscene-cpp.pro
new file mode 100644
index 000000000..b67888946
--- /dev/null
+++ b/examples/dynamicscene-cpp/dynamicscene-cpp.pro
@@ -0,0 +1,16 @@
+TEMPLATE = app
+
+QT += 3dcore 3drenderer
+
+include("../exampleresources/exampleresources.pri")
+
+SOURCES += \
+ main.cpp \
+ examplescene.cpp \
+ forwardrenderer.cpp \
+ boxentity.cpp
+
+HEADERS += \
+ examplescene.h \
+ forwardrenderer.h \
+ boxentity.h
diff --git a/examples/dynamicscene-cpp/examplescene.cpp b/examples/dynamicscene-cpp/examplescene.cpp
new file mode 100644
index 000000000..e7b406875
--- /dev/null
+++ b/examples/dynamicscene-cpp/examplescene.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "examplescene.h"
+#include "boxentity.h"
+
+#include <QTimer>
+#include <qmath.h>
+
+ExampleScene::ExampleScene(Qt3D::QNode *parent)
+ : Qt3D::QEntity(parent)
+ , m_timer(new QTimer(this))
+ , m_even(true)
+{
+ buildScene();
+
+ QObject::connect(m_timer, SIGNAL(timeout()), SLOT(updateScene()));
+ m_timer->setInterval(500);
+ m_timer->start();
+}
+
+ExampleScene::~ExampleScene()
+{
+ qDeleteAll(m_entities);
+}
+
+void ExampleScene::updateScene()
+{
+ int i = 0;
+ Q_FOREACH (BoxEntity *entity, m_entities) {
+ if (i % 2 == 0)
+ entity->setParent(m_even ? Q_NULLPTR : this);
+ else
+ entity->setParent(m_even ? this : Q_NULLPTR);
+ ++i;
+ }
+ m_even = !m_even;
+}
+
+void ExampleScene::buildScene()
+{
+ int count = 20;
+ const float radius = 5.0f;
+
+ for (int i = 0; i < count; ++i) {
+ BoxEntity *entity = new BoxEntity;
+ const float angle = M_PI * 2.0f * float(i) / count;
+ entity->setAngle(angle);
+ entity->setRadius(radius);
+ entity->setDiffuseColor(QColor(fabs(cosf(angle)) * 255, 204, 75));
+ m_entities.append(entity);
+ }
+}
+
diff --git a/examples/dynamicscene-cpp/examplescene.h b/examples/dynamicscene-cpp/examplescene.h
new file mode 100644
index 000000000..4b3fbdc79
--- /dev/null
+++ b/examples/dynamicscene-cpp/examplescene.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef EXAMPLESCENE_H
+#define EXAMPLESCENE_H
+
+#include <Qt3DCore/QEntity>
+
+class BoxEntity;
+
+QT_BEGIN_NAMESPACE
+class QTimer;
+QT_END_NAMESPACE
+
+class ExampleScene : public Qt3D::QEntity
+{
+ Q_OBJECT
+
+public:
+ explicit ExampleScene(Qt3D::QNode *parent = 0);
+ ~ExampleScene();
+
+private Q_SLOTS:
+ void updateScene();
+ void buildScene();
+
+private:
+ QVector<BoxEntity *> m_entities;
+ QTimer *m_timer;
+ bool m_even;
+};
+
+#endif // EXAMPLESCENE_H
diff --git a/examples/dynamicscene-cpp/forwardrenderer.cpp b/examples/dynamicscene-cpp/forwardrenderer.cpp
new file mode 100644
index 000000000..ebd8f7cdc
--- /dev/null
+++ b/examples/dynamicscene-cpp/forwardrenderer.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "forwardrenderer.h"
+
+ForwardRenderer::ForwardRenderer(Qt3D::QNode *parent)
+ : Qt3D::QFrameGraph(parent)
+ , m_viewport(new Qt3D::QViewport())
+ , m_cameraSelector(new Qt3D::QCameraSelector())
+ , m_clearBuffer(new Qt3D::QClearBuffer())
+{
+ m_viewport->setRect(QRectF(0.0f, 0.0f, 1.0f, 1.0f));
+ m_viewport->setClearColor(Qt::white);
+ m_clearBuffer->setBuffers(Qt3D::QClearBuffer::ColorDepthBuffer);
+ m_cameraSelector->setParent(m_viewport);
+ m_clearBuffer->setParent(m_cameraSelector);
+ setActiveFrameGraph(m_viewport);
+}
+
+void ForwardRenderer::setCamera(Qt3D::QEntity *camera)
+{
+ m_cameraSelector->setCamera(camera);
+}
diff --git a/examples/dynamicscene-cpp/forwardrenderer.h b/examples/dynamicscene-cpp/forwardrenderer.h
new file mode 100644
index 000000000..795e964e6
--- /dev/null
+++ b/examples/dynamicscene-cpp/forwardrenderer.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FORWARDRENDERER_H
+#define FORWARDRENDERER_H
+
+#include <Qt3DRenderer/QFrameGraph>
+#include <Qt3DRenderer/QViewport>
+#include <Qt3DRenderer/QCameraSelector>
+#include <Qt3DRenderer/QClearBuffer>
+
+class ForwardRenderer : public Qt3D::QFrameGraph
+{
+public:
+ ForwardRenderer(Qt3D::QNode *parent);
+
+ void setCamera(Qt3D::QEntity *camera);
+
+private:
+ Qt3D::QViewport *m_viewport;
+ Qt3D::QCameraSelector *m_cameraSelector;
+ Qt3D::QClearBuffer *m_clearBuffer;
+};
+
+#endif // FORWARDRENDERER_H
diff --git a/examples/dynamicscene-cpp/main.cpp b/examples/dynamicscene-cpp/main.cpp
new file mode 100644
index 000000000..7bc3a22ae
--- /dev/null
+++ b/examples/dynamicscene-cpp/main.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+
+#include <Qt3DCore/QAspectEngine>
+#include <Qt3DCore/QCamera>
+#include <Qt3DCore/Window>
+
+#include <Qt3DRenderer/QRenderAspect>
+
+#include "forwardrenderer.h"
+#include "examplescene.h"
+
+int main(int argc, char* argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ Qt3D::Window view;
+ Qt3D::QAspectEngine engine;
+ engine.registerAspect(new Qt3D::QRenderAspect());
+ engine.initialize();
+ QVariantMap data;
+ data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(&view)));
+ data.insert(QStringLiteral("window"), QVariant::fromValue(&view));
+ engine.setData(data);
+
+ ExampleScene *sceneRoot = new ExampleScene();
+
+ // Scene Camera
+ Qt3D::QCamera *basicCamera = new Qt3D::QCamera(sceneRoot);
+ basicCamera->setProjectionType(Qt3D::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
+ view.setCamera(basicCamera);
+
+ // Forward Renderer FrameGraph
+ ForwardRenderer *forwardRenderer = new ForwardRenderer(sceneRoot);
+ forwardRenderer->setCamera(basicCamera);
+ sceneRoot->addComponent(forwardRenderer);
+
+ engine.setRootEntity(sceneRoot);
+ view.show();
+
+ return app.exec();
+}
diff --git a/examples/examples.pro b/examples/examples.pro
index 359b38eab..cbd023e0a 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -24,7 +24,8 @@ SUBDIRS += \
keyboardinput-qml \
loader-qml \
wave \
- materials-cpp
+ materials-cpp \
+ dynamicscene-cpp
# TODO Port the old examples to new APIs
#SUBDIRS += qt3d