diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-01-23 16:22:00 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-08-07 00:11:31 +0000 |
commit | c2f6f37699296557c5d79ae750e0ce91647de2ee (patch) | |
tree | 6c140186656c46d5e8584d48772f70e78d04806c /src/quick3d | |
parent | ce69c98f6954ef2c8806bc44a457a58e4202d751 (diff) |
New Buffer API Frontend Classes
- Switch QAbstractAttribute and QAbstractBuffer to QNode subclasses
- Get rid of all shared pointer when dealing with these (needed to expose to
QML and use the QObject ownership)
- Introduce QGeometryRender, QGeometry, QAttributeProvider,
QAttributeAggregator.
A QMesh component now is:
a QGeometryRenderer which specifies its QGeometry.
The QGeometry refererences n attributes. Each attribute references a QAbstractBuffer.
Change-Id: I49a10c11a605e5fe7c180af86a404f622e763f48
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/quick3d')
5 files changed, 191 insertions, 2 deletions
diff --git a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp index 23ef7cb92..9cfcab31c 100644 --- a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp +++ b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp @@ -43,6 +43,7 @@ #include <Qt3DCore/qmatrixtransform.h> #include <Qt3DCore/qtranslatetransform.h> #include <Qt3DCore/qrotatetransform.h> +#include <Qt3DCore/qabstractattribute.h> #include <Qt3DQuick/quick3dentity.h> #include <Qt3DQuick/quick3dentityloader.h> #include <Qt3DQuick/quick3dtransform.h> @@ -75,6 +76,8 @@ void Qt3DQuick3DCorePlugin::registerTypes(const char *uri) qmlRegisterType<Qt3D::QRotateTransform>(uri, 2, 0, "Rotate"); qmlRegisterType<Qt3D::QLookAtTransform>(uri, 2, 0, "LookAt"); qmlRegisterType<Qt3D::QScaleTransform>(uri, 2, 0, "Scale"); + + qmlRegisterUncreatableType<Qt3D::QAbstractAttribute>(uri, 2, 0, "AbstractAttribute", QStringLiteral("QAbstractAttribute is abstract")); } QT_END_NAMESPACE diff --git a/src/quick3d/imports/render/qt3dquick3drendererplugin.cpp b/src/quick3d/imports/render/qt3dquick3drendererplugin.cpp index d9c2dff3a..bb3fd8bd2 100644 --- a/src/quick3d/imports/render/qt3dquick3drendererplugin.cpp +++ b/src/quick3d/imports/render/qt3dquick3drendererplugin.cpp @@ -91,6 +91,10 @@ #include <Qt3DRenderer/qstencilop.h> #include <Qt3DRenderer/qstencilopseparate.h> #include <Qt3DRenderer/qstencilmask.h> +#include <Qt3DRenderer/qattribute.h> +#include <Qt3DRenderer/qbuffer.h> +#include <Qt3DRenderer/qgeometry.h> +#include <Qt3DRenderer/qgeometryrenderer.h> #include <Qt3DQuickRenderer/quick3dtechnique.h> #include <Qt3DQuickRenderer/quick3dmaterial.h> #include <Qt3DQuickRenderer/quick3dtechniquefilter.h> @@ -108,6 +112,7 @@ #include <Qt3DQuickRenderer/quick3dshaderdataarray.h> #include <Qt3DQuickRenderer/quick3dstateset.h> #include <Qt3DQuickRenderer/quick3drendertargetselector.h> +#include <Qt3DQuickRenderer/quick3dgeometry.h> static void initResources() { @@ -190,6 +195,14 @@ void Qt3DQuick3DRendererPlugin::registerTypes(const char *uri) qmlRegisterUncreatableType<Qt3D::QAbstractTextureImage>(uri, 2, 0, "QAbstractTextureImage", QStringLiteral("QAbstractTextureImage is abstract")); qmlRegisterType<Qt3D::QTextureImage>(uri, 2, 0, "TextureImage"); + // Geometry + qmlRegisterUncreatableType<Qt3D::QAbstractAttribute>(uri, 2, 0, "QAbstractAttribute", QStringLiteral("QAbstractAttribute is abstract")); + qmlRegisterUncreatableType<Qt3D::QAbstractBuffer>(uri, 2, 0, "QAbstractBuffer", QStringLiteral("QAbstractBuffer is abstract")); + qmlRegisterType<Qt3D::QAttribute>(uri, 2, 0, "Attribute"); + qmlRegisterType<Qt3D::QBuffer>(uri, 2, 0, "Buffer"); + qmlRegisterExtendedType<Qt3D::QGeometry, Qt3D::Render::Quick::Quick3DGeometry>(uri, 2, 0, "Geometry"); + qmlRegisterType<Qt3D::QGeometryRenderer>(uri, 2, 0, "GeometryRenderer"); + // Meshes qmlRegisterUncreatableType<Qt3D::QAbstractMesh>(uri, 2, 0, "QAbstractMesh", QStringLiteral("QAbstractMesh is abstract")); qmlRegisterType<Qt3D::QMesh>(uri, 2, 0, "Mesh"); diff --git a/src/quick3d/quick3drenderer/items/items.pri b/src/quick3d/quick3drenderer/items/items.pri index 35fa140d3..8c31f6f38 100644 --- a/src/quick3d/quick3drenderer/items/items.pri +++ b/src/quick3d/quick3drenderer/items/items.pri @@ -16,7 +16,8 @@ HEADERS += \ $$PWD/quick3dshaderdata.h \ $$PWD/quick3dshaderdataarray.h \ $$PWD/quick3dstateset.h \ - $$PWD/quick3drendertargetselector.h + $$PWD/quick3drendertargetselector.h \ + $$PWD/quick3dgeometry.h SOURCES += \ $$PWD/quick3drenderpassfilter.cpp \ @@ -35,6 +36,7 @@ SOURCES += \ $$PWD/quick3dshaderdata.cpp \ $$PWD/quick3dshaderdataarray.cpp \ $$PWD/quick3dstateset.cpp \ - $$PWD/quick3drendertargetselector.cpp + $$PWD/quick3drendertargetselector.cpp \ + $$PWD/quick3dgeometry.cpp INCLUDEPATH += $$PWD diff --git a/src/quick3d/quick3drenderer/items/quick3dgeometry.cpp b/src/quick3d/quick3drenderer/items/quick3dgeometry.cpp new file mode 100644 index 000000000..125b8d7a9 --- /dev/null +++ b/src/quick3d/quick3drenderer/items/quick3dgeometry.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: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 "quick3dgeometry.h" + +QT_BEGIN_NAMESPACE + +namespace Qt3D { + +namespace Render { + +namespace Quick { + +Quick3DGeometry::Quick3DGeometry(QObject *parent) + : QObject(parent) +{ +} + +QQmlListProperty<QAbstractAttribute> Quick3DGeometry::attributeList() +{ + return QQmlListProperty<QAbstractAttribute>(this, 0, + &Quick3DGeometry::appendAttribute, + &Quick3DGeometry::attributesCount, + &Quick3DGeometry::attributeAt, + &Quick3DGeometry::clearAttributes); +} + +void Quick3DGeometry::appendAttribute(QQmlListProperty<QAbstractAttribute> *list, QAbstractAttribute *attribute) +{ + Quick3DGeometry *geometry = static_cast<Quick3DGeometry *>(list->object); + geometry->parentGeometry()->addAttribute(attribute); +} + +QAbstractAttribute *Quick3DGeometry::attributeAt(QQmlListProperty<QAbstractAttribute> *list, int index) +{ + Quick3DGeometry *geometry = static_cast<Quick3DGeometry *>(list->object); + return geometry->parentGeometry()->attributes().at(index); +} + +int Quick3DGeometry::attributesCount(QQmlListProperty<QAbstractAttribute> *list) +{ + Quick3DGeometry *geometry = static_cast<Quick3DGeometry *>(list->object); + return geometry->parentGeometry()->attributes().count(); +} + +void Quick3DGeometry::clearAttributes(QQmlListProperty<QAbstractAttribute> *list) +{ + Quick3DGeometry *geometry = static_cast<Quick3DGeometry *>(list->object); + Q_FOREACH (QAbstractAttribute *attribute, geometry->parentGeometry()->attributes()) + geometry->parentGeometry()->removeAttribute(attribute); +} + +} // Quick + +} // Render + +} // Qt3D + +QT_END_NAMESPACE diff --git a/src/quick3d/quick3drenderer/items/quick3dgeometry.h b/src/quick3d/quick3drenderer/items/quick3dgeometry.h new file mode 100644 index 000000000..940e89dad --- /dev/null +++ b/src/quick3d/quick3drenderer/items/quick3dgeometry.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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 QT3D_QUICK3DGEOMETRY_H +#define QT3D_QUICK3DGEOMETRY_H + +#include <Qt3DQuickRenderer/qt3dquickrenderer_global.h> +#include <QQmlListProperty> +#include <Qt3DRenderer/QGeometry> + +QT_BEGIN_NAMESPACE + +namespace Qt3D { + +namespace Render { + +namespace Quick { + +class QT3DQUICKRENDERERSHARED_EXPORT Quick3DGeometry : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty<QAbstractAttribute> attributes READ attributeList) + Q_CLASSINFO("DefaultProperty", "attributeProviders") + +public: + explicit Quick3DGeometry(QObject *parent = 0); + inline QGeometry *parentGeometry() const { return qobject_cast<QGeometry *>(parent()); } + + QQmlListProperty<QAbstractAttribute> attributeList(); + +private: + static void appendAttribute(QQmlListProperty<QAbstractAttribute> *list, QAbstractAttribute *provider); + static QAbstractAttribute *attributeAt(QQmlListProperty<QAbstractAttribute> *list, int index); + static int attributesCount(QQmlListProperty<QAbstractAttribute> *list); + static void clearAttributes(QQmlListProperty<QAbstractAttribute> *list); +}; + +} // Quick + +} // Render + +} // Qt3D + +QT_END_NAMESPACE + +#endif // QT3D_QUICK3DGEOMETRY_H |