From c2f6f37699296557c5d79ae750e0ce91647de2ee Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 23 Jan 2015 16:22:00 +0100 Subject: 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 --- src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp | 3 + .../imports/render/qt3dquick3drendererplugin.cpp | 13 +++ src/quick3d/quick3drenderer/items/items.pri | 6 +- .../quick3drenderer/items/quick3dgeometry.cpp | 92 ++++++++++++++++++++++ .../quick3drenderer/items/quick3dgeometry.h | 79 +++++++++++++++++++ 5 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 src/quick3d/quick3drenderer/items/quick3dgeometry.cpp create mode 100644 src/quick3d/quick3drenderer/items/quick3dgeometry.h (limited to 'src/quick3d') 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 #include #include +#include #include #include #include @@ -75,6 +76,8 @@ void Qt3DQuick3DCorePlugin::registerTypes(const char *uri) qmlRegisterType(uri, 2, 0, "Rotate"); qmlRegisterType(uri, 2, 0, "LookAt"); qmlRegisterType(uri, 2, 0, "Scale"); + + qmlRegisterUncreatableType(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 #include #include +#include +#include +#include +#include #include #include #include @@ -108,6 +112,7 @@ #include #include #include +#include static void initResources() { @@ -190,6 +195,14 @@ void Qt3DQuick3DRendererPlugin::registerTypes(const char *uri) qmlRegisterUncreatableType(uri, 2, 0, "QAbstractTextureImage", QStringLiteral("QAbstractTextureImage is abstract")); qmlRegisterType(uri, 2, 0, "TextureImage"); + // Geometry + qmlRegisterUncreatableType(uri, 2, 0, "QAbstractAttribute", QStringLiteral("QAbstractAttribute is abstract")); + qmlRegisterUncreatableType(uri, 2, 0, "QAbstractBuffer", QStringLiteral("QAbstractBuffer is abstract")); + qmlRegisterType(uri, 2, 0, "Attribute"); + qmlRegisterType(uri, 2, 0, "Buffer"); + qmlRegisterExtendedType(uri, 2, 0, "Geometry"); + qmlRegisterType(uri, 2, 0, "GeometryRenderer"); + // Meshes qmlRegisterUncreatableType(uri, 2, 0, "QAbstractMesh", QStringLiteral("QAbstractMesh is abstract")); qmlRegisterType(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 Quick3DGeometry::attributeList() +{ + return QQmlListProperty(this, 0, + &Quick3DGeometry::appendAttribute, + &Quick3DGeometry::attributesCount, + &Quick3DGeometry::attributeAt, + &Quick3DGeometry::clearAttributes); +} + +void Quick3DGeometry::appendAttribute(QQmlListProperty *list, QAbstractAttribute *attribute) +{ + Quick3DGeometry *geometry = static_cast(list->object); + geometry->parentGeometry()->addAttribute(attribute); +} + +QAbstractAttribute *Quick3DGeometry::attributeAt(QQmlListProperty *list, int index) +{ + Quick3DGeometry *geometry = static_cast(list->object); + return geometry->parentGeometry()->attributes().at(index); +} + +int Quick3DGeometry::attributesCount(QQmlListProperty *list) +{ + Quick3DGeometry *geometry = static_cast(list->object); + return geometry->parentGeometry()->attributes().count(); +} + +void Quick3DGeometry::clearAttributes(QQmlListProperty *list) +{ + Quick3DGeometry *geometry = static_cast(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 +#include +#include + +QT_BEGIN_NAMESPACE + +namespace Qt3D { + +namespace Render { + +namespace Quick { + +class QT3DQUICKRENDERERSHARED_EXPORT Quick3DGeometry : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty attributes READ attributeList) + Q_CLASSINFO("DefaultProperty", "attributeProviders") + +public: + explicit Quick3DGeometry(QObject *parent = 0); + inline QGeometry *parentGeometry() const { return qobject_cast(parent()); } + + QQmlListProperty attributeList(); + +private: + static void appendAttribute(QQmlListProperty *list, QAbstractAttribute *provider); + static QAbstractAttribute *attributeAt(QQmlListProperty *list, int index); + static int attributesCount(QQmlListProperty *list); + static void clearAttributes(QQmlListProperty *list); +}; + +} // Quick + +} // Render + +} // Qt3D + +QT_END_NAMESPACE + +#endif // QT3D_QUICK3DGEOMETRY_H -- cgit v1.2.3