diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2015-01-21 17:57:10 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-01-25 08:59:40 +0100 |
commit | 67da84d5f7e37b7280e251526aba55a36e8681a8 (patch) | |
tree | c6cdc38ca919627165b6ab91ba14d8fdc7ba7cc2 /src/quick3d | |
parent | 49d36cb4f4c539b0bda3db3b0770545c23489f9e (diff) |
Allow to control the aspects used by a Scene3D
Change-Id: I5fb20950cb5f829ab6beb42c1f9d97b6ae94c884
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/quick3d')
-rw-r--r-- | src/quick3d/imports/scene3d/importsscene3d.pro | 2 | ||||
-rw-r--r-- | src/quick3d/imports/scene3d/scene3ditem.cpp | 26 | ||||
-rw-r--r-- | src/quick3d/imports/scene3d/scene3ditem.h | 5 |
3 files changed, 30 insertions, 3 deletions
diff --git a/src/quick3d/imports/scene3d/importsscene3d.pro b/src/quick3d/imports/scene3d/importsscene3d.pro index 074f60810..cd8402320 100644 --- a/src/quick3d/imports/scene3d/importsscene3d.pro +++ b/src/quick3d/imports/scene3d/importsscene3d.pro @@ -2,7 +2,7 @@ CXX_MODULE = qml TARGET = qtquickscene3dplugin TARGETPATH = QtQuick/Scene3D -QT += qml quick 3dcore 3drenderer 3dinput +QT += qml quick 3dcore 3drenderer HEADERS += \ qtquickscene3dplugin.h \ diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp index ce182414c..b03796fc9 100644 --- a/src/quick3d/imports/scene3d/scene3ditem.cpp +++ b/src/quick3d/imports/scene3d/scene3ditem.cpp @@ -42,7 +42,6 @@ #include "scene3ditem.h" #include <Qt3DCore/QAspectEngine> -#include <Qt3DInput/QInputAspect> #include <Qt3DRenderer/QRenderAspect> #include <QOpenGLContext> @@ -140,15 +139,38 @@ Scene3DItem::Scene3DItem(QQuickItem *parent) setAcceptHoverEvents(true); m_aspectEngine->registerAspect(m_renderAspect); - m_aspectEngine->registerAspect(new Qt3D::QInputAspect); m_aspectEngine->initialize(); } +QStringList Scene3DItem::aspects() const +{ + return m_aspects; +} + Qt3D::QEntity *Scene3DItem::entity() const { return m_entity; } +void Scene3DItem::setAspects(const QStringList &aspects) +{ + if (!m_aspects.isEmpty()) { + qWarning() << "Aspects already set on the Scene3D, ignoring"; + return; + } + + m_aspects = aspects; + + Q_FOREACH (const QString &aspect, m_aspects) { + if (aspect == QStringLiteral("render")) // This one is hardwired anyway + continue; + + m_aspectEngine->registerAspect(aspect); + } + + emit aspectsChanged(); +} + void Scene3DItem::setEntity(Qt3D::QEntity *entity) { if (entity == m_entity) diff --git a/src/quick3d/imports/scene3d/scene3ditem.h b/src/quick3d/imports/scene3d/scene3ditem.h index 7ebb23e27..7e0a666b9 100644 --- a/src/quick3d/imports/scene3d/scene3ditem.h +++ b/src/quick3d/imports/scene3d/scene3ditem.h @@ -57,16 +57,20 @@ class Scene3DItem : public QQuickFramebufferObject { Q_OBJECT Q_PROPERTY(Qt3D::QEntity* entity READ entity WRITE setEntity NOTIFY entityChanged) + Q_PROPERTY(QStringList aspects READ aspects WRITE setAspects NOTIFY aspectsChanged) Q_CLASSINFO("DefaultProperty", "entity") public: explicit Scene3DItem(QQuickItem *parent = 0); + QStringList aspects() const; Qt3D::QEntity *entity() const; public Q_SLOTS: + void setAspects(const QStringList &aspects); void setEntity(Qt3D::QEntity *entity); Q_SIGNALS: + void aspectsChanged(); void entityChanged(); private Q_SLOTS: @@ -76,6 +80,7 @@ private: Renderer *createRenderer() const Q_DECL_OVERRIDE; QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *nodeData) Q_DECL_OVERRIDE; + QStringList m_aspects; Qt3D::QEntity *m_entity; Qt3D::QAspectEngine *m_aspectEngine; |