diff options
author | Mike Krus <mike.krus@kdab.com> | 2020-07-30 12:03:46 +0100 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2020-07-30 13:51:37 +0100 |
commit | 174cd487b4644a69853de9007b90cba989afe344 (patch) | |
tree | 03e331f2b0a51ec2c6518d352c4b7a759edebbed /src | |
parent | eb728b5501f0ffb61ca4916ff5975c496ab98970 (diff) |
Make sample meshes geometry renderers again
Introduce new geometry view class for each.
Change-Id: I8e9a8f3a078d4cc63f9656ae8142e39f05d755c7
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
30 files changed, 1950 insertions, 152 deletions
diff --git a/src/extras/CMakeLists.txt b/src/extras/CMakeLists.txt index ec53dd79f..ad3d98148 100644 --- a/src/extras/CMakeLists.txt +++ b/src/extras/CMakeLists.txt @@ -32,16 +32,22 @@ qt_add_module(3DExtras defaults/qt3dwindow.cpp defaults/qt3dwindow.h defaults/qt3dwindow_p.h defaults/qtexturematerial.cpp defaults/qtexturematerial.h defaults/qtexturematerial_p.h geometries/qconegeometry.cpp geometries/qconegeometry.h geometries/qconegeometry_p.h + geometries/qconegeometryview.cpp geometries/qconegeometryview.h geometries/qconemesh.cpp geometries/qconemesh.h geometries/qcuboidgeometry.cpp geometries/qcuboidgeometry.h geometries/qcuboidgeometry_p.h + geometries/qcuboidgeometryview.cpp geometries/qcuboidgeometryview.h geometries/qcuboidmesh.cpp geometries/qcuboidmesh.h geometries/qcylindergeometry.cpp geometries/qcylindergeometry.h geometries/qcylindergeometry_p.h + geometries/qcylindergeometryview.cpp geometries/qcylindergeometryview.h geometries/qcylindermesh.cpp geometries/qcylindermesh.h geometries/qplanegeometry.cpp geometries/qplanegeometry.h geometries/qplanegeometry_p.h + geometries/qplanegeometryview.cpp geometries/qplanegeometryview.h geometries/qplanemesh.cpp geometries/qplanemesh.h geometries/qspheregeometry.cpp geometries/qspheregeometry.h geometries/qspheregeometry_p.h + geometries/qspheregeometryview.cpp geometries/qspheregeometryview.h geometries/qspheremesh.cpp geometries/qspheremesh.h geometries/qtorusgeometry.cpp geometries/qtorusgeometry.h geometries/qtorusgeometry_p.h + geometries/qtorusgeometryview.cpp geometries/qtorusgeometryview.h geometries/qtorusmesh.cpp geometries/qtorusmesh.h qt3dextras_global.h text/areaallocator.cpp text/areaallocator_p.h diff --git a/src/extras/defaults/qskyboxentity.cpp b/src/extras/defaults/qskyboxentity.cpp index b12c0b304..163cf63a4 100644 --- a/src/extras/defaults/qskyboxentity.cpp +++ b/src/extras/defaults/qskyboxentity.cpp @@ -185,9 +185,7 @@ void QSkyboxEntityPrivate::init() m_skyboxTexture->addTextureImage(m_negYImage); m_skyboxTexture->addTextureImage(m_negZImage); - QGeometryRenderer *renderer = new QGeometryRenderer; - renderer->setView(m_mesh); - q_func()->addComponent(renderer); + q_func()->addComponent(m_mesh); q_func()->addComponent(m_material); } diff --git a/src/extras/geometries/geometries.pri b/src/extras/geometries/geometries.pri index 7a2932cb7..2e2efd24b 100644 --- a/src/extras/geometries/geometries.pri +++ b/src/extras/geometries/geometries.pri @@ -1,35 +1,47 @@ HEADERS += \ $$PWD/qconegeometry.h \ $$PWD/qconegeometry_p.h \ + $$PWD/qconegeometryview.h \ $$PWD/qconemesh.h \ $$PWD/qcuboidmesh.h \ $$PWD/qcylindergeometry.h \ $$PWD/qcylindergeometry_p.h \ + $$PWD/qcylindergeometryview.h \ $$PWD/qcylindermesh.h \ $$PWD/qplanemesh.h \ $$PWD/qspheremesh.h \ $$PWD/qtorusmesh.h \ $$PWD/qtorusgeometry.h \ $$PWD/qtorusgeometry_p.h \ + $$PWD/qtorusgeometryview.h \ $$PWD/qspheregeometry.h \ $$PWD/qspheregeometry_p.h \ + $$PWD/qspheregeometryview.h \ $$PWD/qcuboidgeometry.h \ $$PWD/qcuboidgeometry_p.h \ + $$PWD/qcuboidgeometryview.h \ $$PWD/qplanegeometry.h \ - $$PWD/qplanegeometry_p.h + $$PWD/qplanegeometry_p.h \ + $$PWD/qplanegeometryview.h SOURCES += \ $$PWD/qconegeometry.cpp \ + $$PWD/qconegeometryview.cpp \ $$PWD/qconemesh.cpp \ $$PWD/qcuboidmesh.cpp \ $$PWD/qcylindergeometry.cpp \ + $$PWD/qcylindergeometryview.cpp \ $$PWD/qcylindermesh.cpp \ $$PWD/qplanemesh.cpp \ $$PWD/qspheremesh.cpp \ $$PWD/qtorusmesh.cpp \ $$PWD/qtorusgeometry.cpp \ + $$PWD/qtorusgeometryview.cpp \ $$PWD/qspheregeometry.cpp \ + $$PWD/qspheregeometryview.cpp \ $$PWD/qcuboidgeometry.cpp \ - $$PWD/qplanegeometry.cpp + $$PWD/qcuboidgeometryview.cpp \ + $$PWD/qplanegeometry.cpp \ + $$PWD/qplanegeometryview.cpp INCLUDEPATH += $$PWD diff --git a/src/extras/geometries/qconegeometryview.cpp b/src/extras/geometries/qconegeometryview.cpp new file mode 100644 index 000000000..28707d043 --- /dev/null +++ b/src/extras/geometries/qconegeometryview.cpp @@ -0,0 +1,240 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qconegeometryview.h" + +#include <Qt3DExtras/qconegeometry.h> +#include <Qt3DCore/qbuffer.h> +#include <Qt3DCore/qattribute.h> +#include <QtGui/QVector3D> + +#include <qmath.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +/*! + * \qmltype ConeGeometryView + * \instantiates Qt3DExtras::QConeGeometryView + * \inqmlmodule Qt3D.Extras + * \brief A conical mesh. + */ + +/*! + * \qmlproperty int ConeGeometryView::rings + * + * Holds the number of rings in the mesh. + */ + +/*! + * \qmlproperty int ConeGeometryView::slices + * + * Holds the number of slices in the mesh. + */ + +/*! + * \qmlproperty bool ConeGeometryView::hasTopEndcap + * + * Determines if the cone top is capped or open. + */ + +/*! + * \qmlproperty bool ConeGeometryView::hasBottomEndcap + * + * Determines if the cone bottom is capped or open. + */ + +/*! + * \qmlproperty real ConeGeometryView::topRadius + * + * Holds the top radius of the cone. + */ + +/*! + * \qmlproperty real ConeGeometryView::bottomRadius + * + * Holds the bottom radius of the cone. + */ + +/*! + * \qmlproperty real ConeGeometryView::length + * + * Holds the length of the cone. + */ + +/*! + * \class Qt3DExtras::QConeGeometryView + \ingroup qt3d-extras-geometries + * \inheaderfile Qt3DExtras/QConeGeometryView + * \inmodule Qt3DExtras + * + * \inherits Qt3DRender::QGeometryRenderer + * + * \brief A conical mesh. + */ + +QConeGeometryView::QConeGeometryView(QNode *parent) + : Qt3DCore::QGeometryView(parent) +{ + QConeGeometry *geometry = new QConeGeometry(this); + QObject::connect(geometry, &QConeGeometry::hasTopEndcapChanged, this, &QConeGeometryView::hasTopEndcapChanged); + QObject::connect(geometry, &QConeGeometry::hasBottomEndcapChanged, this, &QConeGeometryView::hasBottomEndcapChanged); + QObject::connect(geometry, &QConeGeometry::topRadiusChanged, this, &QConeGeometryView::topRadiusChanged); + QObject::connect(geometry, &QConeGeometry::bottomRadiusChanged, this, &QConeGeometryView::bottomRadiusChanged); + QObject::connect(geometry, &QConeGeometry::ringsChanged, this, &QConeGeometryView::ringsChanged); + QObject::connect(geometry, &QConeGeometry::slicesChanged, this, &QConeGeometryView::slicesChanged); + QObject::connect(geometry, &QConeGeometry::lengthChanged, this, &QConeGeometryView::lengthChanged); + + QGeometryView::setGeometry(geometry); +} + +/*! \internal */ +QConeGeometryView::~QConeGeometryView() +{ +} + +void QConeGeometryView::setHasTopEndcap(bool hasTopEndcap) +{ + static_cast<QConeGeometry *>(geometry())->setHasTopEndcap(hasTopEndcap); +} + +void QConeGeometryView::setHasBottomEndcap(bool hasBottomEndcap) +{ + static_cast<QConeGeometry *>(geometry())->setHasBottomEndcap(hasBottomEndcap); +} + +void QConeGeometryView::setTopRadius(float topRadius) +{ + static_cast<QConeGeometry *>(geometry())->setTopRadius(topRadius); +} + +void QConeGeometryView::setBottomRadius(float bottomRadius) +{ + static_cast<QConeGeometry *>(geometry())->setBottomRadius(bottomRadius); +} + +void QConeGeometryView::setRings(int rings) +{ + static_cast<QConeGeometry *>(geometry())->setRings(rings); +} + +void QConeGeometryView::setSlices(int slices) +{ + static_cast<QConeGeometry *>(geometry())->setSlices(slices); +} + +void QConeGeometryView::setLength(float length) +{ + static_cast<QConeGeometry *>(geometry())->setLength(length); +} + +/*! + * \property QConeGeometryView::hasTopEndcap + * + * Determines if the cone top is capped or open. + */ +bool QConeGeometryView::hasTopEndcap() const +{ + return static_cast<QConeGeometry *>(geometry())->hasTopEndcap(); +} + +/*! + * \property QConeGeometryView::hasBottomEndcap + * + * Determines if the cone bottom is capped or open. + */ +bool QConeGeometryView::hasBottomEndcap() const +{ + return static_cast<QConeGeometry *>(geometry())->hasBottomEndcap(); +} + +/*! + * \property QConeGeometryView::topRadius + * + * Holds the top radius of the cone. + */ +float QConeGeometryView::topRadius() const +{ + return static_cast<QConeGeometry *>(geometry())->topRadius(); +} + +/*! + * \property QConeGeometryView::bottomRadius + * + * Holds the bottom radius of the cone. + */ +float QConeGeometryView::bottomRadius() const +{ + return static_cast<QConeGeometry *>(geometry())->bottomRadius(); +} + +/*! + * \property QConeGeometryView::rings + * + * Holds the number of rings in the mesh. + */ +int QConeGeometryView::rings() const +{ + return static_cast<QConeGeometry *>(geometry())->rings(); +} + +/*! + * \property QConeGeometryView::slices + * + * Holds the number of slices in the mesh. + */ +int QConeGeometryView::slices() const +{ + return static_cast<QConeGeometry *>(geometry())->slices(); +} + +/*! + * \property QConeGeometryView::length + * + * Holds the length of the cone. + */ +float QConeGeometryView::length() const +{ + return static_cast<QConeGeometry *>(geometry())->length(); +} + +} // namespace Qt3DExtras + +QT_END_NAMESPACE diff --git a/src/extras/geometries/qconegeometryview.h b/src/extras/geometries/qconegeometryview.h new file mode 100644 index 000000000..cdeb3703e --- /dev/null +++ b/src/extras/geometries/qconegeometryview.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_QCONEGEOMETRYVIEW_H +#define QT3DEXTRAS_QCONEGEOMETRYVIEW_H + +#include <Qt3DExtras/qt3dextras_global.h> +#include <Qt3DCore/qgeometryview.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +class Q_3DEXTRASSHARED_EXPORT QConeGeometryView : public Qt3DCore::QGeometryView +{ + Q_OBJECT + Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) + Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged) + Q_PROPERTY( bool hasTopEndcap READ hasTopEndcap WRITE setHasTopEndcap NOTIFY hasTopEndcapChanged ) + Q_PROPERTY( bool hasBottomEndcap READ hasBottomEndcap WRITE setHasBottomEndcap NOTIFY hasBottomEndcapChanged ) + Q_PROPERTY( float topRadius READ topRadius WRITE setTopRadius NOTIFY topRadiusChanged ) + Q_PROPERTY( float bottomRadius READ bottomRadius WRITE setBottomRadius NOTIFY bottomRadiusChanged ) + Q_PROPERTY(float length READ length WRITE setLength NOTIFY lengthChanged) +public: + explicit QConeGeometryView(Qt3DCore::QNode *parent = nullptr); + ~QConeGeometryView(); + + int rings() const; + int slices() const; + bool hasTopEndcap() const; + bool hasBottomEndcap() const; + float topRadius() const; + float bottomRadius() const; + float length() const; + +public Q_SLOTS: + void setHasTopEndcap( bool hasTopEndcap ); + void setHasBottomEndcap( bool hasBottomEndcap ); + void setTopRadius( float topRadius ); + void setBottomRadius( float bottomRadius ); + void setRings( int rings ); + void setSlices( int slices ); + void setLength( float length ); + +Q_SIGNALS: + void hasTopEndcapChanged( bool hasTopEndcap ); + void hasBottomEndcapChanged( bool hasBottomEndcap ); + void topRadiusChanged( float topRadius ); + void bottomRadiusChanged( float bottomRadius ); + void ringsChanged( int rings ); + void slicesChanged( int slices ); + void lengthChanged( float length ); + +private: + // As this is a default provided geometry renderer, no one should be able + // to modify the QGeometryRenderer's properties + + void setInstanceCount(int instanceCount); + void setVertexCount(int vertexCount); + void setIndexOffset(int indexOffset); + void setFirstInstance(int firstInstance); + void setRestartIndexValue(int index); + void setPrimitiveRestartEnabled(bool enabled); + void setGeometry(Qt3DCore::QGeometry *geometry); + void setPrimitiveType(PrimitiveType primitiveType); +}; + +} // namespace Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_QCONEGEOMETRYVIEW_H diff --git a/src/extras/geometries/qconemesh.cpp b/src/extras/geometries/qconemesh.cpp index 4a8ab05c8..5f4ebd369 100644 --- a/src/extras/geometries/qconemesh.cpp +++ b/src/extras/geometries/qconemesh.cpp @@ -37,13 +37,9 @@ ** ****************************************************************************/ -#ifndef _USE_MATH_DEFINES -# define _USE_MATH_DEFINES // For MSVC -#endif +#include "qconemesh.h" -#include "qconegeometry.h" - -#include <Qt3DExtras/qconemesh.h> +#include <Qt3DExtras/qconegeometryview.h> #include <Qt3DCore/qbuffer.h> #include <Qt3DCore/qattribute.h> #include <QtGui/QVector3D> @@ -115,18 +111,18 @@ namespace Qt3DExtras { */ QConeMesh::QConeMesh(QNode *parent) - : Qt3DCore::QGeometryView(parent) + : Qt3DRender::QGeometryRenderer(parent) { - QConeGeometry *geometry = new QConeGeometry(this); - QObject::connect(geometry, &QConeGeometry::hasTopEndcapChanged, this, &QConeMesh::hasTopEndcapChanged); - QObject::connect(geometry, &QConeGeometry::hasBottomEndcapChanged, this, &QConeMesh::hasBottomEndcapChanged); - QObject::connect(geometry, &QConeGeometry::topRadiusChanged, this, &QConeMesh::topRadiusChanged); - QObject::connect(geometry, &QConeGeometry::bottomRadiusChanged, this, &QConeMesh::bottomRadiusChanged); - QObject::connect(geometry, &QConeGeometry::ringsChanged, this, &QConeMesh::ringsChanged); - QObject::connect(geometry, &QConeGeometry::slicesChanged, this, &QConeMesh::slicesChanged); - QObject::connect(geometry, &QConeGeometry::lengthChanged, this, &QConeMesh::lengthChanged); + QConeGeometryView *geometry = new QConeGeometryView(this); + QObject::connect(geometry, &QConeGeometryView::hasTopEndcapChanged, this, &QConeMesh::hasTopEndcapChanged); + QObject::connect(geometry, &QConeGeometryView::hasBottomEndcapChanged, this, &QConeMesh::hasBottomEndcapChanged); + QObject::connect(geometry, &QConeGeometryView::topRadiusChanged, this, &QConeMesh::topRadiusChanged); + QObject::connect(geometry, &QConeGeometryView::bottomRadiusChanged, this, &QConeMesh::bottomRadiusChanged); + QObject::connect(geometry, &QConeGeometryView::ringsChanged, this, &QConeMesh::ringsChanged); + QObject::connect(geometry, &QConeGeometryView::slicesChanged, this, &QConeMesh::slicesChanged); + QObject::connect(geometry, &QConeGeometryView::lengthChanged, this, &QConeMesh::lengthChanged); - QGeometryView::setGeometry(geometry); + setView(geometry); } /*! \internal */ @@ -136,37 +132,37 @@ QConeMesh::~QConeMesh() void QConeMesh::setHasTopEndcap(bool hasTopEndcap) { - static_cast<QConeGeometry *>(geometry())->setHasTopEndcap(hasTopEndcap); + static_cast<QConeGeometryView *>(view())->setHasTopEndcap(hasTopEndcap); } void QConeMesh::setHasBottomEndcap(bool hasBottomEndcap) { - static_cast<QConeGeometry *>(geometry())->setHasBottomEndcap(hasBottomEndcap); + static_cast<QConeGeometryView *>(view())->setHasBottomEndcap(hasBottomEndcap); } void QConeMesh::setTopRadius(float topRadius) { - static_cast<QConeGeometry *>(geometry())->setTopRadius(topRadius); + static_cast<QConeGeometryView *>(view())->setTopRadius(topRadius); } void QConeMesh::setBottomRadius(float bottomRadius) { - static_cast<QConeGeometry *>(geometry())->setBottomRadius(bottomRadius); + static_cast<QConeGeometryView *>(view())->setBottomRadius(bottomRadius); } void QConeMesh::setRings(int rings) { - static_cast<QConeGeometry *>(geometry())->setRings(rings); + static_cast<QConeGeometryView *>(view())->setRings(rings); } void QConeMesh::setSlices(int slices) { - static_cast<QConeGeometry *>(geometry())->setSlices(slices); + static_cast<QConeGeometryView *>(view())->setSlices(slices); } void QConeMesh::setLength(float length) { - static_cast<QConeGeometry *>(geometry())->setLength(length); + static_cast<QConeGeometryView *>(view())->setLength(length); } /*! @@ -176,7 +172,7 @@ void QConeMesh::setLength(float length) */ bool QConeMesh::hasTopEndcap() const { - return static_cast<QConeGeometry *>(geometry())->hasTopEndcap(); + return static_cast<QConeGeometryView *>(view())->hasTopEndcap(); } /*! @@ -186,7 +182,7 @@ bool QConeMesh::hasTopEndcap() const */ bool QConeMesh::hasBottomEndcap() const { - return static_cast<QConeGeometry *>(geometry())->hasBottomEndcap(); + return static_cast<QConeGeometryView *>(view())->hasBottomEndcap(); } /*! @@ -196,7 +192,7 @@ bool QConeMesh::hasBottomEndcap() const */ float QConeMesh::topRadius() const { - return static_cast<QConeGeometry *>(geometry())->topRadius(); + return static_cast<QConeGeometryView *>(view())->topRadius(); } /*! @@ -206,7 +202,7 @@ float QConeMesh::topRadius() const */ float QConeMesh::bottomRadius() const { - return static_cast<QConeGeometry *>(geometry())->bottomRadius(); + return static_cast<QConeGeometryView *>(view())->bottomRadius(); } /*! @@ -216,7 +212,7 @@ float QConeMesh::bottomRadius() const */ int QConeMesh::rings() const { - return static_cast<QConeGeometry *>(geometry())->rings(); + return static_cast<QConeGeometryView *>(view())->rings(); } /*! @@ -226,7 +222,7 @@ int QConeMesh::rings() const */ int QConeMesh::slices() const { - return static_cast<QConeGeometry *>(geometry())->slices(); + return static_cast<QConeGeometryView *>(view())->slices(); } /*! @@ -236,7 +232,7 @@ int QConeMesh::slices() const */ float QConeMesh::length() const { - return static_cast<QConeGeometry *>(geometry())->length(); + return static_cast<QConeGeometryView *>(view())->length(); } } // namespace Qt3DExtras diff --git a/src/extras/geometries/qconemesh.h b/src/extras/geometries/qconemesh.h index ac7a7bf16..57fe0c0fc 100644 --- a/src/extras/geometries/qconemesh.h +++ b/src/extras/geometries/qconemesh.h @@ -41,13 +41,13 @@ #define QT3DEXTRAS_QCONEMESH_H #include <Qt3DExtras/qt3dextras_global.h> -#include <Qt3DCore/qgeometryview.h> +#include <Qt3DRender/qgeometryrenderer.h> QT_BEGIN_NAMESPACE namespace Qt3DExtras { -class Q_3DEXTRASSHARED_EXPORT QConeMesh : public Qt3DCore::QGeometryView +class Q_3DEXTRASSHARED_EXPORT QConeMesh : public Qt3DRender::QGeometryRenderer { Q_OBJECT Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) diff --git a/src/extras/geometries/qcuboidgeometryview.cpp b/src/extras/geometries/qcuboidgeometryview.cpp new file mode 100644 index 000000000..ee0977b71 --- /dev/null +++ b/src/extras/geometries/qcuboidgeometryview.cpp @@ -0,0 +1,227 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcuboidgeometryview.h" + +#include <Qt3DExtras/qcuboidgeometry.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +/*! + * \qmltype CuboidGeometryView + * \instantiates Qt3DExtras::QCuboidGeometryView + * \inqmlmodule Qt3D.Extras + * \brief A cuboid mesh. + */ + +/*! + * \qmlproperty real CuboidGeometryView::xExtent + * + * Holds the x extent of the mesh. + */ + +/*! + * \qmlproperty real CuboidGeometryView::yExtent + * + * Holds the y extent of the mesh. + */ + +/*! + * \qmlproperty real CuboidGeometryView::zExtent + * + * Holds the z extent of the mesh. + */ + +/*! + * \qmlproperty size CuboidGeometryView::yzMeshResolution + * + * Holds the y-z resolution of the mesh. + * The width and height values of this property specify the number of vertices generated for + * the y-z faces of the mesh. + */ + +/*! + * \qmlproperty size CuboidGeometryView::xzMeshResolution + * + * Holds the x-z resolution of the mesh. + * The width and height values of this property specify the number of vertices generated for + * the x-z faces of the mesh. + */ + +/*! + * \qmlproperty size CuboidGeometryView::xyMeshResolution + * + * Holds the x-y resolution of the mesh. + * The width and height values of this property specify the number of vertices generated for + * the x-y faces of the mesh. + */ + +/*! + * \class Qt3DExtras::QCuboidGeometryView + \ingroup qt3d-extras-geometries + * \inheaderfile Qt3DExtras/QCuboidGeometryView + * \inmodule Qt3DExtras + * + * \inherits Qt3DCore::QGeometryView + * + * \brief A cuboid mesh. + */ + +/*! + * Constructs a new QCuboidGeometryView with \a parent. + */ +QCuboidGeometryView::QCuboidGeometryView(QNode *parent) + : Qt3DCore::QGeometryView(parent) +{ + QCuboidGeometry *geometry = new QCuboidGeometry(this); + QObject::connect(geometry, &QCuboidGeometry::xExtentChanged, this, &QCuboidGeometryView::xExtentChanged); + QObject::connect(geometry, &QCuboidGeometry::yExtentChanged, this, &QCuboidGeometryView::yExtentChanged); + QObject::connect(geometry, &QCuboidGeometry::zExtentChanged, this, &QCuboidGeometryView::zExtentChanged); + QObject::connect(geometry, &QCuboidGeometry::xyMeshResolutionChanged, this, &QCuboidGeometryView::xyMeshResolutionChanged); + QObject::connect(geometry, &QCuboidGeometry::xzMeshResolutionChanged, this, &QCuboidGeometryView::xzMeshResolutionChanged); + QObject::connect(geometry, &QCuboidGeometry::yzMeshResolutionChanged, this, &QCuboidGeometryView::yzMeshResolutionChanged); + QGeometryView::setGeometry(geometry); +} + +/*! \internal */ +QCuboidGeometryView::~QCuboidGeometryView() +{ +} + +void QCuboidGeometryView::setXExtent(float xExtent) +{ + static_cast<QCuboidGeometry *>(geometry())->setXExtent(xExtent); +} + +/*! + * \property QCuboidGeometryView::xExtent + * + * Holds the x extent of the mesh. + */ +float QCuboidGeometryView::xExtent() const +{ + return static_cast<QCuboidGeometry *>(geometry())->xExtent(); +} + +void QCuboidGeometryView::setYExtent(float yExtent) +{ + static_cast<QCuboidGeometry *>(geometry())->setYExtent(yExtent); +} + +/*! + * \property QCuboidGeometryView::yExtent + * + * Holds the y extent of the mesh. + */ +float QCuboidGeometryView::yExtent() const +{ + return static_cast<QCuboidGeometry *>(geometry())->yExtent(); +} + +void QCuboidGeometryView::setZExtent(float zExtent) +{ + static_cast<QCuboidGeometry *>(geometry())->setZExtent(zExtent); +} + +/*! + * \property QCuboidGeometryView::zExtent + * + * Holds the z extent of the mesh. + */ +float QCuboidGeometryView::zExtent() const +{ + return static_cast<QCuboidGeometry *>(geometry())->zExtent(); +} + +void QCuboidGeometryView::setYZMeshResolution(const QSize &resolution) +{ + static_cast<QCuboidGeometry *>(geometry())->setYZMeshResolution(resolution); +} + +/*! + * \property QCuboidGeometryView::yzMeshResolution + * + * Holds the y-z resolution of the mesh. + * The width and height values of this property specify the number of vertices generated for + * the y-z faces of the mesh. + */ +QSize QCuboidGeometryView::yzMeshResolution() const +{ + return static_cast<QCuboidGeometry *>(geometry())->yzMeshResolution(); +} + +void QCuboidGeometryView::setXZMeshResolution(const QSize &resolution) +{ + static_cast<QCuboidGeometry *>(geometry())->setXZMeshResolution(resolution); +} + +/*! + * \property QCuboidGeometryView::xzMeshResolution + * + * Holds the x-z resolution of the mesh. + * The width and height values of this property specify the number of vertices generated for + * the x-z faces of the mesh. + */ +QSize QCuboidGeometryView::xzMeshResolution() const +{ + return static_cast<QCuboidGeometry *>(geometry())->xzMeshResolution(); +} + +void QCuboidGeometryView::setXYMeshResolution(const QSize &resolution) +{ + static_cast<QCuboidGeometry *>(geometry())->setXYMeshResolution(resolution); +} + +/*! + * \property QCuboidGeometryView::xyMeshResolution + * + * Holds the x-y resolution of the mesh. + * The width and height values of this property specify the number of vertices generated for + * the x-y faces of the mesh. + */ +QSize QCuboidGeometryView::xyMeshResolution() const +{ + return static_cast<QCuboidGeometry *>(geometry())->xyMeshResolution(); +} + +} // namespace Qt3DExtras + +QT_END_NAMESPACE diff --git a/src/extras/geometries/qcuboidgeometryview.h b/src/extras/geometries/qcuboidgeometryview.h new file mode 100644 index 000000000..2925c6dd6 --- /dev/null +++ b/src/extras/geometries/qcuboidgeometryview.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_CUBOIDGEOMETRYVIEW_H +#define QT3DEXTRAS_CUBOIDGEOMETRYVIEW_H + +#include <Qt3DExtras/qt3dextras_global.h> +#include <Qt3DCore/qgeometryview.h> +#include <QtCore/QSize> + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +class Q_3DEXTRASSHARED_EXPORT QCuboidGeometryView : public Qt3DCore::QGeometryView +{ + Q_OBJECT + + Q_PROPERTY(float xExtent READ xExtent WRITE setXExtent NOTIFY xExtentChanged) + Q_PROPERTY(float yExtent READ yExtent WRITE setYExtent NOTIFY yExtentChanged) + Q_PROPERTY(float zExtent READ zExtent WRITE setZExtent NOTIFY zExtentChanged) + Q_PROPERTY(QSize yzMeshResolution READ yzMeshResolution WRITE setYZMeshResolution NOTIFY yzMeshResolutionChanged) + Q_PROPERTY(QSize xzMeshResolution READ xzMeshResolution WRITE setXZMeshResolution NOTIFY xzMeshResolutionChanged) + Q_PROPERTY(QSize xyMeshResolution READ xyMeshResolution WRITE setXYMeshResolution NOTIFY xyMeshResolutionChanged) + +public: + explicit QCuboidGeometryView(Qt3DCore::QNode *parent = nullptr); + ~QCuboidGeometryView(); + + float xExtent() const; + float yExtent() const; + float zExtent() const; + QSize yzMeshResolution() const; + QSize xzMeshResolution() const; + QSize xyMeshResolution() const; + +public Q_SLOTS: + void setXExtent(float xExtent); + void setYExtent(float yExtent); + void setZExtent(float zExtent); + void setYZMeshResolution(const QSize &resolution); + void setXZMeshResolution(const QSize &resolution); + void setXYMeshResolution(const QSize &resolution); + +Q_SIGNALS: + void xExtentChanged(float xExtent); + void yExtentChanged(float yExtent); + void zExtentChanged(float zExtent); + + void yzMeshResolutionChanged(const QSize &yzMeshResolution); + void xzMeshResolutionChanged(const QSize &xzMeshResolution); + void xyMeshResolutionChanged(const QSize &xyMeshResolution); + +private: + // As this is a default provided geometry renderer, no one should be able + // to modify the QGeometryRenderer's properties + + void setInstanceCount(int instanceCount); + void setVertexCount(int vertexCount); + void setIndexOffset(int indexOffset); + void setFirstInstance(int firstInstance); + void setRestartIndexValue(int index); + void setPrimitiveRestartEnabled(bool enabled); + void setGeometry(Qt3DCore::QGeometry *geometry); + void setPrimitiveType(PrimitiveType primitiveType); +}; + +} // namespace Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_CUBOIDGEOMETRYVIEW_H diff --git a/src/extras/geometries/qcuboidmesh.cpp b/src/extras/geometries/qcuboidmesh.cpp index 8637f7a57..5440ef0ba 100644 --- a/src/extras/geometries/qcuboidmesh.cpp +++ b/src/extras/geometries/qcuboidmesh.cpp @@ -39,7 +39,7 @@ #include "qcuboidmesh.h" -#include <Qt3DExtras/qcuboidgeometry.h> +#include <Qt3DExtras/qcuboidgeometryview.h> QT_BEGIN_NAMESPACE @@ -109,16 +109,16 @@ namespace Qt3DExtras { * Constructs a new QCuboidMesh with \a parent. */ QCuboidMesh::QCuboidMesh(QNode *parent) - : Qt3DCore::QGeometryView(parent) + : Qt3DRender::QGeometryRenderer(parent) { - QCuboidGeometry *geometry = new QCuboidGeometry(this); - QObject::connect(geometry, &QCuboidGeometry::xExtentChanged, this, &QCuboidMesh::xExtentChanged); - QObject::connect(geometry, &QCuboidGeometry::yExtentChanged, this, &QCuboidMesh::yExtentChanged); - QObject::connect(geometry, &QCuboidGeometry::zExtentChanged, this, &QCuboidMesh::zExtentChanged); - QObject::connect(geometry, &QCuboidGeometry::xyMeshResolutionChanged, this, &QCuboidMesh::xyMeshResolutionChanged); - QObject::connect(geometry, &QCuboidGeometry::xzMeshResolutionChanged, this, &QCuboidMesh::xzMeshResolutionChanged); - QObject::connect(geometry, &QCuboidGeometry::yzMeshResolutionChanged, this, &QCuboidMesh::yzMeshResolutionChanged); - QGeometryView::setGeometry(geometry); + QCuboidGeometryView *geometry = new QCuboidGeometryView(this); + QObject::connect(geometry, &QCuboidGeometryView::xExtentChanged, this, &QCuboidMesh::xExtentChanged); + QObject::connect(geometry, &QCuboidGeometryView::yExtentChanged, this, &QCuboidMesh::yExtentChanged); + QObject::connect(geometry, &QCuboidGeometryView::zExtentChanged, this, &QCuboidMesh::zExtentChanged); + QObject::connect(geometry, &QCuboidGeometryView::xyMeshResolutionChanged, this, &QCuboidMesh::xyMeshResolutionChanged); + QObject::connect(geometry, &QCuboidGeometryView::xzMeshResolutionChanged, this, &QCuboidMesh::xzMeshResolutionChanged); + QObject::connect(geometry, &QCuboidGeometryView::yzMeshResolutionChanged, this, &QCuboidMesh::yzMeshResolutionChanged); + setView(geometry); } /*! \internal */ @@ -128,7 +128,7 @@ QCuboidMesh::~QCuboidMesh() void QCuboidMesh::setXExtent(float xExtent) { - static_cast<QCuboidGeometry *>(geometry())->setXExtent(xExtent); + static_cast<QCuboidGeometryView *>(view())->setXExtent(xExtent); } /*! @@ -138,12 +138,12 @@ void QCuboidMesh::setXExtent(float xExtent) */ float QCuboidMesh::xExtent() const { - return static_cast<QCuboidGeometry *>(geometry())->xExtent(); + return static_cast<QCuboidGeometryView *>(view())->xExtent(); } void QCuboidMesh::setYExtent(float yExtent) { - static_cast<QCuboidGeometry *>(geometry())->setYExtent(yExtent); + static_cast<QCuboidGeometryView *>(view())->setYExtent(yExtent); } /*! @@ -153,12 +153,12 @@ void QCuboidMesh::setYExtent(float yExtent) */ float QCuboidMesh::yExtent() const { - return static_cast<QCuboidGeometry *>(geometry())->yExtent(); + return static_cast<QCuboidGeometryView *>(view())->yExtent(); } void QCuboidMesh::setZExtent(float zExtent) { - static_cast<QCuboidGeometry *>(geometry())->setZExtent(zExtent); + static_cast<QCuboidGeometryView *>(view())->setZExtent(zExtent); } /*! @@ -168,12 +168,12 @@ void QCuboidMesh::setZExtent(float zExtent) */ float QCuboidMesh::zExtent() const { - return static_cast<QCuboidGeometry *>(geometry())->zExtent(); + return static_cast<QCuboidGeometryView *>(view())->zExtent(); } void QCuboidMesh::setYZMeshResolution(const QSize &resolution) { - static_cast<QCuboidGeometry *>(geometry())->setYZMeshResolution(resolution); + static_cast<QCuboidGeometryView *>(view())->setYZMeshResolution(resolution); } /*! @@ -185,12 +185,12 @@ void QCuboidMesh::setYZMeshResolution(const QSize &resolution) */ QSize QCuboidMesh::yzMeshResolution() const { - return static_cast<QCuboidGeometry *>(geometry())->yzMeshResolution(); + return static_cast<QCuboidGeometryView *>(view())->yzMeshResolution(); } void QCuboidMesh::setXZMeshResolution(const QSize &resolution) { - static_cast<QCuboidGeometry *>(geometry())->setXZMeshResolution(resolution); + static_cast<QCuboidGeometryView *>(view())->setXZMeshResolution(resolution); } /*! @@ -202,12 +202,12 @@ void QCuboidMesh::setXZMeshResolution(const QSize &resolution) */ QSize QCuboidMesh::xzMeshResolution() const { - return static_cast<QCuboidGeometry *>(geometry())->xzMeshResolution(); + return static_cast<QCuboidGeometryView *>(view())->xzMeshResolution(); } void QCuboidMesh::setXYMeshResolution(const QSize &resolution) { - static_cast<QCuboidGeometry *>(geometry())->setXYMeshResolution(resolution); + static_cast<QCuboidGeometryView *>(view())->setXYMeshResolution(resolution); } /*! @@ -219,7 +219,7 @@ void QCuboidMesh::setXYMeshResolution(const QSize &resolution) */ QSize QCuboidMesh::xyMeshResolution() const { - return static_cast<QCuboidGeometry *>(geometry())->xyMeshResolution(); + return static_cast<QCuboidGeometryView *>(view())->xyMeshResolution(); } } // namespace Qt3DExtras diff --git a/src/extras/geometries/qcuboidmesh.h b/src/extras/geometries/qcuboidmesh.h index 480ffaae3..a945dbe2b 100644 --- a/src/extras/geometries/qcuboidmesh.h +++ b/src/extras/geometries/qcuboidmesh.h @@ -41,14 +41,14 @@ #define QT3DEXTRAS_CUBOIDMESH_H #include <Qt3DExtras/qt3dextras_global.h> -#include <Qt3DCore/qgeometryview.h> +#include <Qt3DRender/qgeometryrenderer.h> #include <QtCore/QSize> QT_BEGIN_NAMESPACE namespace Qt3DExtras { -class Q_3DEXTRASSHARED_EXPORT QCuboidMesh : public Qt3DCore::QGeometryView +class Q_3DEXTRASSHARED_EXPORT QCuboidMesh : public Qt3DRender::QGeometryRenderer { Q_OBJECT diff --git a/src/extras/geometries/qcylindergeometryview.cpp b/src/extras/geometries/qcylindergeometryview.cpp new file mode 100644 index 000000000..3a0fbfd81 --- /dev/null +++ b/src/extras/geometries/qcylindergeometryview.cpp @@ -0,0 +1,184 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef _USE_MATH_DEFINES +# define _USE_MATH_DEFINES // For MSVC +#endif + +#include "qcylindergeometryview.h" + +#include <Qt3DExtras/qcylindergeometry.h> +#include <Qt3DCore/qbuffer.h> +#include <Qt3DCore/qattribute.h> +#include <QtGui/QVector3D> + +#include <qmath.h> + +QT_BEGIN_NAMESPACE + +using namespace Qt3DCore; + +namespace Qt3DExtras { + +/*! + * \qmltype CylinderGeometryView + * \instantiates Qt3DExtras::QCylinderGeometryView + * \inqmlmodule Qt3D.Extras + * \brief A cylindrical mesh. + */ + +/*! + * \qmlproperty int CylinderMesh::rings + * + * Holds the number of rings in the mesh. + */ + +/*! + * \qmlproperty int CylinderMesh::slices + * + * Holds the number of slices in the mesh. + */ + +/*! + * \qmlproperty real CylinderMesh::radius + * + * Holds the radius of the cylinder. + */ + +/*! + * \qmlproperty real CylinderMesh::length + * + * Holds the length of the cylinder. + */ + +/*! + * \class Qt3DExtras::QCylinderGeometryView + \ingroup qt3d-extras-geometries + * \inheaderfile Qt3DExtras/QCylinderGeometryView + * \inmodule Qt3DExtras + * + * \inherits Qt3DRender::QGeometryRenderer + * + * \brief A cylindrical mesh. + */ + +/*! + * Constructs a new QCylinderGeometryView with \a parent. + */ +QCylinderGeometryView::QCylinderGeometryView(QNode *parent) + : Qt3DCore::QGeometryView(parent) +{ + QCylinderGeometry *geometry = new QCylinderGeometry(this); + QObject::connect(geometry, &QCylinderGeometry::radiusChanged, this, &QCylinderGeometryView::radiusChanged); + QObject::connect(geometry, &QCylinderGeometry::ringsChanged, this, &QCylinderGeometryView::ringsChanged); + QObject::connect(geometry, &QCylinderGeometry::slicesChanged, this, &QCylinderGeometryView::slicesChanged); + QObject::connect(geometry, &QCylinderGeometry::lengthChanged, this, &QCylinderGeometryView::lengthChanged); + + QGeometryView::setGeometry(geometry); +} + +/*! \internal */ +QCylinderGeometryView::~QCylinderGeometryView() +{ +} + +void QCylinderGeometryView::setRings(int rings) +{ + static_cast<QCylinderGeometry *>(geometry())->setRings(rings); +} + +void QCylinderGeometryView::setSlices(int slices) +{ + static_cast<QCylinderGeometry *>(geometry())->setSlices(slices); +} + +void QCylinderGeometryView::setRadius(float radius) +{ + static_cast<QCylinderGeometry *>(geometry())->setRadius(radius); +} + +void QCylinderGeometryView::setLength(float length) +{ + static_cast<QCylinderGeometry *>(geometry())->setLength(length); +} + +/*! + * \property QCylinderGeometryView::rings + * + * Holds the number of rings in the mesh. + */ +int QCylinderGeometryView::rings() const +{ + return static_cast<QCylinderGeometry *>(geometry())->rings(); +} + +/*! + * \property QCylinderGeometryView::slices + * + * Holds the number of slices in the mesh. + */ +int QCylinderGeometryView::slices() const +{ + return static_cast<QCylinderGeometry *>(geometry())->slices(); +} + +/*! + * \property QCylinderGeometryView::radius + * + * Holds the radius of the cylinder. + */ +float QCylinderGeometryView::radius() const +{ + return static_cast<QCylinderGeometry *>(geometry())->radius(); +} + +/*! + * \property QCylinderGeometryView::length + * + * Holds the length of the cylinder. + */ +float QCylinderGeometryView::length() const +{ + return static_cast<QCylinderGeometry *>(geometry())->length(); +} + +} // namespace Qt3DExtras + +QT_END_NAMESPACE diff --git a/src/extras/geometries/qcylindergeometryview.h b/src/extras/geometries/qcylindergeometryview.h new file mode 100644 index 000000000..4a90c54d4 --- /dev/null +++ b/src/extras/geometries/qcylindergeometryview.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_QCYLINDERGEOMETRYVIEW_H +#define QT3DEXTRAS_QCYLINDERGEOMETRYVIEW_H + +#include <Qt3DExtras/qt3dextras_global.h> +#include <Qt3DCore/qgeometryview.h> + +QT_BEGIN_NAMESPACE + + +namespace Qt3DExtras { + +class Q_3DEXTRASSHARED_EXPORT QCylinderGeometryView : public Qt3DCore::QGeometryView +{ + Q_OBJECT + Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) + Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged) + Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) + Q_PROPERTY(float length READ length WRITE setLength NOTIFY lengthChanged) +public: + explicit QCylinderGeometryView(Qt3DCore::QNode *parent = nullptr); + ~QCylinderGeometryView(); + + int rings() const; + int slices() const; + float radius() const; + float length() const; + +public Q_SLOTS: + void setRings(int rings); + void setSlices(int slices); + void setRadius(float radius); + void setLength(float length); + +Q_SIGNALS: + void radiusChanged(float radius); + void ringsChanged(int rings); + void slicesChanged(int slices); + void lengthChanged(float length); + +private: + // As this is a default provided geometry renderer, no one should be able + // to modify the QGeometryRenderer's properties + + void setInstanceCount(int instanceCount); + void setVertexCount(int vertexCount); + void setIndexOffset(int indexOffset); + void setFirstInstance(int firstInstance); + void setRestartIndexValue(int index); + void setPrimitiveRestartEnabled(bool enabled); + void setGeometry(Qt3DCore::QGeometry *geometry); + void setPrimitiveType(PrimitiveType primitiveType); +}; + +} // namespace Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_QCYLINDERGEOMETRYVIEW_H diff --git a/src/extras/geometries/qcylindermesh.cpp b/src/extras/geometries/qcylindermesh.cpp index 5aa3b90fd..2c2bb4d81 100644 --- a/src/extras/geometries/qcylindermesh.cpp +++ b/src/extras/geometries/qcylindermesh.cpp @@ -43,8 +43,8 @@ #endif #include "qcylindermesh.h" +#include "qcylindergeometryview.h" -#include <Qt3DExtras/qcylindergeometry.h> #include <Qt3DCore/qbuffer.h> #include <Qt3DCore/qattribute.h> #include <QtGui/QVector3D> @@ -103,15 +103,15 @@ namespace Qt3DExtras { * Constructs a new QCylinderMesh with \a parent. */ QCylinderMesh::QCylinderMesh(QNode *parent) - : Qt3DCore::QGeometryView(parent) + : Qt3DRender::QGeometryRenderer(parent) { - QCylinderGeometry *geometry = new QCylinderGeometry(this); - QObject::connect(geometry, &QCylinderGeometry::radiusChanged, this, &QCylinderMesh::radiusChanged); - QObject::connect(geometry, &QCylinderGeometry::ringsChanged, this, &QCylinderMesh::ringsChanged); - QObject::connect(geometry, &QCylinderGeometry::slicesChanged, this, &QCylinderMesh::slicesChanged); - QObject::connect(geometry, &QCylinderGeometry::lengthChanged, this, &QCylinderMesh::lengthChanged); + QCylinderGeometryView *geometry = new QCylinderGeometryView(this); + QObject::connect(geometry, &QCylinderGeometryView::radiusChanged, this, &QCylinderMesh::radiusChanged); + QObject::connect(geometry, &QCylinderGeometryView::ringsChanged, this, &QCylinderMesh::ringsChanged); + QObject::connect(geometry, &QCylinderGeometryView::slicesChanged, this, &QCylinderMesh::slicesChanged); + QObject::connect(geometry, &QCylinderGeometryView::lengthChanged, this, &QCylinderMesh::lengthChanged); - QGeometryView::setGeometry(geometry); + setView(geometry); } /*! \internal */ @@ -121,22 +121,22 @@ QCylinderMesh::~QCylinderMesh() void QCylinderMesh::setRings(int rings) { - static_cast<QCylinderGeometry *>(geometry())->setRings(rings); + static_cast<QCylinderGeometryView *>(view())->setRings(rings); } void QCylinderMesh::setSlices(int slices) { - static_cast<QCylinderGeometry *>(geometry())->setSlices(slices); + static_cast<QCylinderGeometryView *>(view())->setSlices(slices); } void QCylinderMesh::setRadius(float radius) { - static_cast<QCylinderGeometry *>(geometry())->setRadius(radius); + static_cast<QCylinderGeometryView *>(view())->setRadius(radius); } void QCylinderMesh::setLength(float length) { - static_cast<QCylinderGeometry *>(geometry())->setLength(length); + static_cast<QCylinderGeometryView *>(view())->setLength(length); } /*! @@ -146,7 +146,7 @@ void QCylinderMesh::setLength(float length) */ int QCylinderMesh::rings() const { - return static_cast<QCylinderGeometry *>(geometry())->rings(); + return static_cast<QCylinderGeometryView *>(view())->rings(); } /*! @@ -156,7 +156,7 @@ int QCylinderMesh::rings() const */ int QCylinderMesh::slices() const { - return static_cast<QCylinderGeometry *>(geometry())->slices(); + return static_cast<QCylinderGeometryView *>(view())->slices(); } /*! @@ -166,7 +166,7 @@ int QCylinderMesh::slices() const */ float QCylinderMesh::radius() const { - return static_cast<QCylinderGeometry *>(geometry())->radius(); + return static_cast<QCylinderGeometryView *>(view())->radius(); } /*! @@ -176,7 +176,7 @@ float QCylinderMesh::radius() const */ float QCylinderMesh::length() const { - return static_cast<QCylinderGeometry *>(geometry())->length(); + return static_cast<QCylinderGeometryView *>(view())->length(); } } // namespace Qt3DExtras diff --git a/src/extras/geometries/qcylindermesh.h b/src/extras/geometries/qcylindermesh.h index 0117e5597..f2c8fb01b 100644 --- a/src/extras/geometries/qcylindermesh.h +++ b/src/extras/geometries/qcylindermesh.h @@ -41,14 +41,14 @@ #define QT3DEXTRAS_QCYLINDERMESH_H #include <Qt3DExtras/qt3dextras_global.h> -#include <Qt3DCore/qgeometryview.h> +#include <Qt3DRender/qgeometryrenderer.h> QT_BEGIN_NAMESPACE namespace Qt3DExtras { -class Q_3DEXTRASSHARED_EXPORT QCylinderMesh : public Qt3DCore::QGeometryView +class Q_3DEXTRASSHARED_EXPORT QCylinderMesh : public Qt3DRender::QGeometryRenderer { Q_OBJECT Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) diff --git a/src/extras/geometries/qplanegeometryview.cpp b/src/extras/geometries/qplanegeometryview.cpp new file mode 100644 index 000000000..dd1544b3b --- /dev/null +++ b/src/extras/geometries/qplanegeometryview.cpp @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qplanegeometryview.h" + +#include <Qt3DExtras/qplanegeometry.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +/*! + * \qmltype PlaneGeometryView + * \instantiates Qt3DExtras::QPlaneGeometryView + * \inqmlmodule Qt3D.Extras + * \brief A square planar mesh. + */ + +/*! + * \qmlproperty real PlaneGeometryView::width + * + * Holds the plane width. + */ + +/*! + * \qmlproperty real PlaneGeometryView::height + * + * Holds the plane height. + */ + +/*! + * \qmlproperty size PlaneGeometryView::meshResolution + * + * Holds the plane resolution. + * The width and height values of this property specify the number of vertices generated for + * the mesh in the respective dimensions. + */ + +/*! + * \qmlproperty bool PlaneGeometryView::mirrored + * + * Controls if the UV coordinates of the plane should be flipped vertically. + */ + +/*! + * \class Qt3DExtras::QPlaneGeometryView + \ingroup qt3d-extras-geometries + * \inheaderfile Qt3DExtras/QPlaneGeometryView + * \inmodule Qt3DExtras + * + * \inherits Qt3DRender::QGeometryRenderer + * + * \brief A square planar mesh. + */ + +/*! + * Constructs a new QPlaneGeometryView with \a parent. + */ +QPlaneGeometryView::QPlaneGeometryView(QNode *parent) + : Qt3DCore::QGeometryView(parent) +{ + QPlaneGeometry *geometry = new QPlaneGeometry(this); + QObject::connect(geometry, &QPlaneGeometry::widthChanged, this, &QPlaneGeometryView::widthChanged); + QObject::connect(geometry, &QPlaneGeometry::heightChanged, this, &QPlaneGeometryView::heightChanged); + QObject::connect(geometry, &QPlaneGeometry::resolutionChanged, this, &QPlaneGeometryView::meshResolutionChanged); + QObject::connect(geometry, &QPlaneGeometry::mirroredChanged, this, &QPlaneGeometryView::mirroredChanged); + QGeometryView::setGeometry(geometry); +} + +/*! \internal */ +QPlaneGeometryView::~QPlaneGeometryView() +{ +} + +void QPlaneGeometryView::setWidth(float width) +{ + static_cast<QPlaneGeometry *>(geometry())->setWidth(width); +} + +/*! + * \property QPlaneGeometryView::width + * + * Holds the plane width. + */ +float QPlaneGeometryView::width() const +{ + return static_cast<QPlaneGeometry *>(geometry())->width(); +} + +void QPlaneGeometryView::setHeight(float height) +{ + static_cast<QPlaneGeometry *>(geometry())->setHeight(height); +} + +/*! + * \property QPlaneGeometryView::height + * + * Holds the plane height. + */ +float QPlaneGeometryView::height() const +{ + return static_cast<QPlaneGeometry *>(geometry())->height(); +} + +void QPlaneGeometryView::setMeshResolution(const QSize &resolution) +{ + static_cast<QPlaneGeometry *>(geometry())->setResolution(resolution); +} + +/*! + * \property QPlaneGeometryView::meshResolution + * + * Holds the plane resolution. + * The width and height values of this property specify the number of vertices generated for + * the mesh in the respective dimensions. + */ +QSize QPlaneGeometryView::meshResolution() const +{ + return static_cast<QPlaneGeometry *>(geometry())->resolution(); +} + +void QPlaneGeometryView::setMirrored(bool mirrored) +{ + static_cast<QPlaneGeometry *>(geometry())->setMirrored(mirrored); +} + +/*! + * \property QPlaneGeometryView::mirrored + * + * Controls if the UV coordinates of the plane should be flipped vertically. + */ +bool QPlaneGeometryView::mirrored() const +{ + return static_cast<QPlaneGeometry *>(geometry())->mirrored(); +} + +} // namespace Qt3DExtras + +QT_END_NAMESPACE diff --git a/src/extras/geometries/qplanegeometryview.h b/src/extras/geometries/qplanegeometryview.h new file mode 100644 index 000000000..a268ded3a --- /dev/null +++ b/src/extras/geometries/qplanegeometryview.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_QPLANEGEOMETRYVIEW_H +#define QT3DEXTRAS_QPLANEGEOMETRYVIEW_H + +#include <Qt3DExtras/qt3dextras_global.h> +#include <Qt3DCore/qgeometryview.h> +#include <QtCore/QSize> + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +class Q_3DEXTRASSHARED_EXPORT QPlaneGeometryView : public Qt3DCore::QGeometryView +{ + Q_OBJECT + Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged) + Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged) + Q_PROPERTY(QSize meshResolution READ meshResolution WRITE setMeshResolution NOTIFY meshResolutionChanged) + Q_PROPERTY(bool mirrored READ mirrored WRITE setMirrored NOTIFY mirroredChanged REVISION 9) + +public: + explicit QPlaneGeometryView(Qt3DCore::QNode *parent = nullptr); + ~QPlaneGeometryView(); + + float width() const; + float height() const; + QSize meshResolution() const; + bool mirrored() const; + +public Q_SLOTS: + void setWidth(float width); + void setHeight(float height); + void setMeshResolution(const QSize &resolution); + void setMirrored(bool mirrored); + +Q_SIGNALS: + void meshResolutionChanged(const QSize &meshResolution); + void widthChanged(float width); + void heightChanged(float height); + void mirroredChanged(bool mirrored); + +private: + // As this is a default provided geometry renderer, no one should be able + // to modify the QGeometryRenderer's properties + + void setInstanceCount(int instanceCount); + void setVertexCount(int vertexCount); + void setIndexOffset(int indexOffset); + void setFirstInstance(int firstInstance); + void setRestartIndexValue(int index); + void setPrimitiveRestartEnabled(bool enabled); + void setGeometry(Qt3DCore::QGeometry *geometry); + void setPrimitiveType(PrimitiveType primitiveType); +}; + +} // namespace Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_QPLANEGEOMETRYVIEW_H diff --git a/src/extras/geometries/qplanemesh.cpp b/src/extras/geometries/qplanemesh.cpp index 9dd5f70c5..ebcaa1d9c 100644 --- a/src/extras/geometries/qplanemesh.cpp +++ b/src/extras/geometries/qplanemesh.cpp @@ -39,7 +39,7 @@ #include "qplanemesh.h" -#include <Qt3DExtras/qplanegeometry.h> +#include <Qt3DExtras/qplanegeometryview.h> QT_BEGIN_NAMESPACE @@ -94,14 +94,14 @@ namespace Qt3DExtras { * Constructs a new QPlaneMesh with \a parent. */ QPlaneMesh::QPlaneMesh(QNode *parent) - : Qt3DCore::QGeometryView(parent) + : Qt3DRender::QGeometryRenderer(parent) { - QPlaneGeometry *geometry = new QPlaneGeometry(this); - QObject::connect(geometry, &QPlaneGeometry::widthChanged, this, &QPlaneMesh::widthChanged); - QObject::connect(geometry, &QPlaneGeometry::heightChanged, this, &QPlaneMesh::heightChanged); - QObject::connect(geometry, &QPlaneGeometry::resolutionChanged, this, &QPlaneMesh::meshResolutionChanged); - QObject::connect(geometry, &QPlaneGeometry::mirroredChanged, this, &QPlaneMesh::mirroredChanged); - QGeometryView::setGeometry(geometry); + QPlaneGeometryView *geometry = new QPlaneGeometryView(this); + QObject::connect(geometry, &QPlaneGeometryView::widthChanged, this, &QPlaneMesh::widthChanged); + QObject::connect(geometry, &QPlaneGeometryView::heightChanged, this, &QPlaneMesh::heightChanged); + QObject::connect(geometry, &QPlaneGeometryView::meshResolutionChanged, this, &QPlaneMesh::meshResolutionChanged); + QObject::connect(geometry, &QPlaneGeometryView::mirroredChanged, this, &QPlaneMesh::mirroredChanged); + setView(geometry); } /*! \internal */ @@ -111,7 +111,7 @@ QPlaneMesh::~QPlaneMesh() void QPlaneMesh::setWidth(float width) { - static_cast<QPlaneGeometry *>(geometry())->setWidth(width); + static_cast<QPlaneGeometryView *>(view())->setWidth(width); } /*! @@ -121,12 +121,12 @@ void QPlaneMesh::setWidth(float width) */ float QPlaneMesh::width() const { - return static_cast<QPlaneGeometry *>(geometry())->width(); + return static_cast<QPlaneGeometryView *>(view())->width(); } void QPlaneMesh::setHeight(float height) { - static_cast<QPlaneGeometry *>(geometry())->setHeight(height); + static_cast<QPlaneGeometryView *>(view())->setHeight(height); } /*! @@ -136,12 +136,12 @@ void QPlaneMesh::setHeight(float height) */ float QPlaneMesh::height() const { - return static_cast<QPlaneGeometry *>(geometry())->height(); + return static_cast<QPlaneGeometryView *>(view())->height(); } void QPlaneMesh::setMeshResolution(const QSize &resolution) { - static_cast<QPlaneGeometry *>(geometry())->setResolution(resolution); + static_cast<QPlaneGeometryView *>(view())->setMeshResolution(resolution); } /*! @@ -153,12 +153,12 @@ void QPlaneMesh::setMeshResolution(const QSize &resolution) */ QSize QPlaneMesh::meshResolution() const { - return static_cast<QPlaneGeometry *>(geometry())->resolution(); + return static_cast<QPlaneGeometryView *>(view())->meshResolution(); } void QPlaneMesh::setMirrored(bool mirrored) { - static_cast<QPlaneGeometry *>(geometry())->setMirrored(mirrored); + static_cast<QPlaneGeometryView *>(view())->setMirrored(mirrored); } /*! @@ -169,7 +169,7 @@ void QPlaneMesh::setMirrored(bool mirrored) */ bool QPlaneMesh::mirrored() const { - return static_cast<QPlaneGeometry *>(geometry())->mirrored(); + return static_cast<QPlaneGeometryView *>(view())->mirrored(); } } // namespace Qt3DExtras diff --git a/src/extras/geometries/qplanemesh.h b/src/extras/geometries/qplanemesh.h index fc71bd93a..923af8897 100644 --- a/src/extras/geometries/qplanemesh.h +++ b/src/extras/geometries/qplanemesh.h @@ -41,14 +41,14 @@ #define QT3DEXTRAS_QPLANEMESH_H #include <Qt3DExtras/qt3dextras_global.h> -#include <Qt3DCore/qgeometryview.h> +#include <Qt3DRender/qgeometryrenderer.h> #include <QtCore/QSize> QT_BEGIN_NAMESPACE namespace Qt3DExtras { -class Q_3DEXTRASSHARED_EXPORT QPlaneMesh : public Qt3DCore::QGeometryView +class Q_3DEXTRASSHARED_EXPORT QPlaneMesh : public Qt3DRender::QGeometryRenderer { Q_OBJECT Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged) diff --git a/src/extras/geometries/qspheregeometryview.cpp b/src/extras/geometries/qspheregeometryview.cpp new file mode 100644 index 000000000..6ac72ad82 --- /dev/null +++ b/src/extras/geometries/qspheregeometryview.cpp @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qspheregeometryview.h" + +#include <Qt3DExtras/qspheregeometry.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +/*! + * \qmltype SphereGeometryView + * \instantiates Qt3DExtras::QSphereGeometryView + * \inqmlmodule Qt3D.Extras + * \brief A spherical mesh. + */ + +/*! + * \qmlproperty int SphereGeometryView::rings + * + * Holds the number of rings in the mesh. + */ + +/*! + * \qmlproperty int SphereGeometryView::slices + * + * Holds the number of slices in the mesh. + */ + +/*! + * \qmlproperty real SphereGeometryView::radius + * + * Holds the radius of the sphere. + */ + +/*! + * \qmlproperty bool SphereGeometryView::generateTangents + * + * Holds the value of the automatic tangent vectors generation flag. + * Tangent vectors are orthogonal to normal vectors. + */ + +/*! + * \class Qt3DExtras::QSphereGeometryView + \ingroup qt3d-extras-geometries + * \inheaderfile Qt3DExtras/QSphereGeometryView + * \inmodule Qt3DExtras + * + * \inherits Qt3DCore::QGeometryView + * + * \brief A spherical mesh. + */ + +/*! + * Constructs a new QSphereGeometryView with \a parent. + */ +QSphereGeometryView::QSphereGeometryView(QNode *parent) + : Qt3DCore::QGeometryView(parent) +{ + QSphereGeometry *geometry = new QSphereGeometry(this); + QObject::connect(geometry, &QSphereGeometry::radiusChanged, this, &QSphereGeometryView::radiusChanged); + QObject::connect(geometry, &QSphereGeometry::ringsChanged, this, &QSphereGeometryView::ringsChanged); + QObject::connect(geometry, &QSphereGeometry::slicesChanged, this, &QSphereGeometryView::slicesChanged); + QObject::connect(geometry, &QSphereGeometry::generateTangentsChanged, this, &QSphereGeometryView::generateTangentsChanged); + QGeometryView::setGeometry(geometry); +} + +/*! \internal */ +QSphereGeometryView::~QSphereGeometryView() +{ +} + +void QSphereGeometryView::setRings(int rings) +{ + static_cast<QSphereGeometry *>(geometry())->setRings(rings); +} + +void QSphereGeometryView::setSlices(int slices) +{ + static_cast<QSphereGeometry *>(geometry())->setSlices(slices); +} + +void QSphereGeometryView::setRadius(float radius) +{ + static_cast<QSphereGeometry *>(geometry())->setRadius(radius); +} + +void QSphereGeometryView::setGenerateTangents(bool gen) +{ + static_cast<QSphereGeometry *>(geometry())->setGenerateTangents(gen); +} + +/*! + * \property QSphereGeometryView::generateTangents + * + * Holds the value of the automatic tangent vectors generation flag. + * Tangent vectors are orthogonal to normal vectors. + */ +bool QSphereGeometryView::generateTangents() const +{ + return static_cast<QSphereGeometry *>(geometry())->generateTangents(); +} + +/*! + * \property QSphereGeometryView::rings + * + * Holds the number of rings in the mesh. + */ +int QSphereGeometryView::rings() const +{ + return static_cast<QSphereGeometry *>(geometry())->rings(); +} + +/*! + * \property QSphereGeometryView::slices + * + * Holds the number of slices in the mesh. + */ +int QSphereGeometryView::slices() const +{ + return static_cast<QSphereGeometry *>(geometry())->slices(); +} + +/*! + * \property QSphereGeometryView::radius + * + * Holds the radius of the sphere. + */ +float QSphereGeometryView::radius() const +{ + return static_cast<QSphereGeometry *>(geometry())->radius(); +} + +} // Qt3DExtras + +QT_END_NAMESPACE diff --git a/src/extras/geometries/qspheregeometryview.h b/src/extras/geometries/qspheregeometryview.h new file mode 100644 index 000000000..b31fa941b --- /dev/null +++ b/src/extras/geometries/qspheregeometryview.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_QSPHEREGEOMETRYVIEW_H +#define QT3DEXTRAS_QSPHEREGEOMETRYVIEW_H + +#include <Qt3DExtras/qt3dextras_global.h> +#include <Qt3DCore/QGeometryView> + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +class QSphereMeshPrivate; + +class Q_3DEXTRASSHARED_EXPORT QSphereGeometryView : public Qt3DCore::QGeometryView +{ + Q_OBJECT + Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) + Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged) + Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) + Q_PROPERTY(bool generateTangents READ generateTangents WRITE setGenerateTangents NOTIFY generateTangentsChanged) + +public: + explicit QSphereGeometryView(Qt3DCore::QNode *parent = nullptr); + ~QSphereGeometryView(); + + int rings() const; + int slices() const; + float radius() const; + bool generateTangents() const; + +public Q_SLOTS: + void setRings(int rings); + void setSlices(int slices); + void setRadius(float radius); + void setGenerateTangents(bool gen); + +Q_SIGNALS: + void radiusChanged(float radius); + void ringsChanged(int rings); + void slicesChanged(int slices); + void generateTangentsChanged(bool generateTangents); + +private: + // As this is a default provided geometry renderer, no one should be able + // to modify the QGeometryRenderer's properties + + void setVertexCount(int vertexCount); + void setIndexOffset(int indexOffset); + void setFirstInstance(int firstInstance); + void setRestartIndexValue(int index); + void setPrimitiveRestartEnabled(bool enabled); + void setGeometry(Qt3DCore::QGeometry *geometry); + void setPrimitiveType(PrimitiveType primitiveType); +}; + +} // namespace Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_QSPHEREGEOMETRYVIEW_H diff --git a/src/extras/geometries/qspheremesh.cpp b/src/extras/geometries/qspheremesh.cpp index 13b8ecf5e..fa2b795c8 100644 --- a/src/extras/geometries/qspheremesh.cpp +++ b/src/extras/geometries/qspheremesh.cpp @@ -40,7 +40,7 @@ #include "qspheremesh.h" -#include <Qt3DExtras/qspheregeometry.h> +#include <Qt3DExtras/qspheregeometryview.h> QT_BEGIN_NAMESPACE @@ -93,14 +93,14 @@ namespace Qt3DExtras { * Constructs a new QSphereMesh with \a parent. */ QSphereMesh::QSphereMesh(QNode *parent) - : Qt3DCore::QGeometryView(parent) + : Qt3DRender::QGeometryRenderer(parent) { - QSphereGeometry *geometry = new QSphereGeometry(this); - QObject::connect(geometry, &QSphereGeometry::radiusChanged, this, &QSphereMesh::radiusChanged); - QObject::connect(geometry, &QSphereGeometry::ringsChanged, this, &QSphereMesh::ringsChanged); - QObject::connect(geometry, &QSphereGeometry::slicesChanged, this, &QSphereMesh::slicesChanged); - QObject::connect(geometry, &QSphereGeometry::generateTangentsChanged, this, &QSphereMesh::generateTangentsChanged); - QGeometryView::setGeometry(geometry); + QSphereGeometryView *geometry = new QSphereGeometryView(this); + QObject::connect(geometry, &QSphereGeometryView::radiusChanged, this, &QSphereMesh::radiusChanged); + QObject::connect(geometry, &QSphereGeometryView::ringsChanged, this, &QSphereMesh::ringsChanged); + QObject::connect(geometry, &QSphereGeometryView::slicesChanged, this, &QSphereMesh::slicesChanged); + QObject::connect(geometry, &QSphereGeometryView::generateTangentsChanged, this, &QSphereMesh::generateTangentsChanged); + setView(geometry); } /*! \internal */ @@ -110,22 +110,22 @@ QSphereMesh::~QSphereMesh() void QSphereMesh::setRings(int rings) { - static_cast<QSphereGeometry *>(geometry())->setRings(rings); + static_cast<QSphereGeometryView *>(view())->setRings(rings); } void QSphereMesh::setSlices(int slices) { - static_cast<QSphereGeometry *>(geometry())->setSlices(slices); + static_cast<QSphereGeometryView *>(view())->setSlices(slices); } void QSphereMesh::setRadius(float radius) { - static_cast<QSphereGeometry *>(geometry())->setRadius(radius); + static_cast<QSphereGeometryView *>(view())->setRadius(radius); } void QSphereMesh::setGenerateTangents(bool gen) { - static_cast<QSphereGeometry *>(geometry())->setGenerateTangents(gen); + static_cast<QSphereGeometryView *>(view())->setGenerateTangents(gen); } /*! @@ -136,7 +136,7 @@ void QSphereMesh::setGenerateTangents(bool gen) */ bool QSphereMesh::generateTangents() const { - return static_cast<QSphereGeometry *>(geometry())->generateTangents(); + return static_cast<QSphereGeometryView *>(view())->generateTangents(); } /*! @@ -146,7 +146,7 @@ bool QSphereMesh::generateTangents() const */ int QSphereMesh::rings() const { - return static_cast<QSphereGeometry *>(geometry())->rings(); + return static_cast<QSphereGeometryView *>(view())->rings(); } /*! @@ -156,7 +156,7 @@ int QSphereMesh::rings() const */ int QSphereMesh::slices() const { - return static_cast<QSphereGeometry *>(geometry())->slices(); + return static_cast<QSphereGeometryView *>(view())->slices(); } /*! @@ -166,7 +166,7 @@ int QSphereMesh::slices() const */ float QSphereMesh::radius() const { - return static_cast<QSphereGeometry *>(geometry())->radius(); + return static_cast<QSphereGeometryView *>(view())->radius(); } } // Qt3DExtras diff --git a/src/extras/geometries/qspheremesh.h b/src/extras/geometries/qspheremesh.h index 170f70215..998cd7c0e 100644 --- a/src/extras/geometries/qspheremesh.h +++ b/src/extras/geometries/qspheremesh.h @@ -41,7 +41,7 @@ #define QT3DEXTRAS_QSPHEREMESH_H #include <Qt3DExtras/qt3dextras_global.h> -#include <Qt3DCore/QGeometryView> +#include <Qt3DRender/qgeometryrenderer.h> QT_BEGIN_NAMESPACE @@ -49,7 +49,7 @@ namespace Qt3DExtras { class QSphereMeshPrivate; -class Q_3DEXTRASSHARED_EXPORT QSphereMesh : public Qt3DCore::QGeometryView +class Q_3DEXTRASSHARED_EXPORT QSphereMesh : public Qt3DRender::QGeometryRenderer { Q_OBJECT Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) diff --git a/src/extras/geometries/qtorusgeometryview.cpp b/src/extras/geometries/qtorusgeometryview.cpp new file mode 100644 index 000000000..958d17974 --- /dev/null +++ b/src/extras/geometries/qtorusgeometryview.cpp @@ -0,0 +1,177 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef _USE_MATH_DEFINES +# define _USE_MATH_DEFINES // For MSVC +#endif + +#include "qtorusgeometryview.h" + +#include <Qt3DExtras/qtorusgeometry.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +/*! + * \qmltype TorusGeometryView + * \instantiates Qt3DExtras::QTorusGeometryView + * \inqmlmodule Qt3D.Extras + * \brief A toroidal mesh. + */ + +/*! + * \qmlproperty int TorusGeometryView::rings + * + * Holds the number of rings in the mesh. + */ + +/*! + * \qmlproperty int TorusGeometryView::slices + * + * Holds the number of slices in the mesh. + */ + +/*! + * \qmlproperty real TorusGeometryView::radius + * + * Holds the outer radius of the torus. + */ + +/*! + * \qmlproperty real TorusGeometryView::minorRadius + * + * Holds the inner radius of the torus. + */ + +/*! + * \class Qt3DExtras::QTorusGeometryView + \ingroup qt3d-extras-geometries + * \inheaderfile Qt3DExtras/QTorusGeometryView + * \inmodule Qt3DExtras + * + * \inherits Qt3DCore::QGeometryView + * + * \brief A toroidal mesh. + */ + +/*! + * Constructs a new QTorusGeometryView with \a parent. + */ +QTorusGeometryView::QTorusGeometryView(QNode *parent) + : Qt3DCore::QGeometryView(parent) +{ + QTorusGeometry *geometry = new QTorusGeometry(this); + QObject::connect(geometry, &QTorusGeometry::radiusChanged, this, &QTorusGeometryView::radiusChanged); + QObject::connect(geometry, &QTorusGeometry::ringsChanged, this, &QTorusGeometryView::ringsChanged); + QObject::connect(geometry, &QTorusGeometry::slicesChanged, this, &QTorusGeometryView::slicesChanged); + QObject::connect(geometry, &QTorusGeometry::minorRadiusChanged, this, &QTorusGeometryView::minorRadiusChanged); + + QGeometryView::setGeometry(geometry); +} + +/*! \internal */ +QTorusGeometryView::~QTorusGeometryView() +{ +} + +void QTorusGeometryView::setRings(int rings) +{ + static_cast<QTorusGeometry *>(geometry())->setRings(rings); +} + +void QTorusGeometryView::setSlices(int slices) +{ + static_cast<QTorusGeometry *>(geometry())->setSlices(slices); +} + +void QTorusGeometryView::setRadius(float radius) +{ + static_cast<QTorusGeometry *>(geometry())->setRadius(radius); +} + +void QTorusGeometryView::setMinorRadius(float minorRadius) +{ + static_cast<QTorusGeometry *>(geometry())->setMinorRadius(minorRadius); +} + +/*! + * \property QTorusGeometryView::rings + * + * Holds the number of rings in the mesh. + */ +int QTorusGeometryView::rings() const +{ + return static_cast<QTorusGeometry *>(geometry())->rings(); +} + +/*! + * \property QTorusGeometryView::slices + * + * Holds the number of slices in the mesh. + */ +int QTorusGeometryView::slices() const +{ + return static_cast<QTorusGeometry *>(geometry())->slices(); +} + +/*! + * \property QTorusGeometryView::radius + * + * Holds the outer radius of the torus. + */ +float QTorusGeometryView::radius() const +{ + return static_cast<QTorusGeometry *>(geometry())->radius(); +} + +/*! + * \property QTorusGeometryView::minorRadius + * + * Holds the inner radius of the torus. + */ +float QTorusGeometryView::minorRadius() const +{ + return static_cast<QTorusGeometry *>(geometry())->minorRadius(); +} + +} // namespace Qt3DExtras + +QT_END_NAMESPACE diff --git a/src/extras/geometries/qtorusgeometryview.h b/src/extras/geometries/qtorusgeometryview.h new file mode 100644 index 000000000..c8c6fd5ad --- /dev/null +++ b/src/extras/geometries/qtorusgeometryview.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DEXTRAS_QTORUSGEOMETRYVIEW_H +#define QT3DEXTRAS_QTORUSGEOMETRYVIEW_H + +#include <Qt3DExtras/qt3dextras_global.h> +#include <Qt3DCore/qgeometryview.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +class Q_3DEXTRASSHARED_EXPORT QTorusGeometryView : public Qt3DCore::QGeometryView +{ + Q_OBJECT + Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) + Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged) + Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged) + Q_PROPERTY(float minorRadius READ minorRadius WRITE setMinorRadius NOTIFY minorRadiusChanged) +public: + explicit QTorusGeometryView(Qt3DCore::QNode *parent = nullptr); + ~QTorusGeometryView(); + + int rings() const; + int slices() const; + float radius() const; + float minorRadius() const; + +public Q_SLOTS: + void setRings(int rings); + void setSlices(int slices); + void setRadius(float radius); + void setMinorRadius(float minorRadius); + +Q_SIGNALS: + void radiusChanged(float radius); + void ringsChanged(int rings); + void slicesChanged(int slices); + void minorRadiusChanged(float minorRadius); + +private: + // As this is a default provided geometry renderer, no one should be able + // to modify the QGeometryRenderer's properties + + void setInstanceCount(int instanceCount); + void setVertexCount(int vertexCount); + void setIndexOffset(int indexOffset); + void setFirstInstance(int firstInstance); + void setRestartIndexValue(int index); + void setPrimitiveRestartEnabled(bool enabled); + void setGeometry(Qt3DCore::QGeometry *geometry); + void setPrimitiveType(PrimitiveType primitiveType); +}; + +} // namespace Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DEXTRAS_QTORUSGEOMETRYVIEW_H diff --git a/src/extras/geometries/qtorusmesh.cpp b/src/extras/geometries/qtorusmesh.cpp index b195ef631..ddcec3ece 100644 --- a/src/extras/geometries/qtorusmesh.cpp +++ b/src/extras/geometries/qtorusmesh.cpp @@ -43,6 +43,7 @@ #endif #include "qtorusmesh.h" +#include "qtorusgeometryview.h" #include <Qt3DExtras/qtorusgeometry.h> @@ -96,15 +97,15 @@ namespace Qt3DExtras { * Constructs a new QTorusMesh with \a parent. */ QTorusMesh::QTorusMesh(QNode *parent) - : Qt3DCore::QGeometryView(parent) + : Qt3DRender::QGeometryRenderer(parent) { - QTorusGeometry *geometry = new QTorusGeometry(this); - QObject::connect(geometry, &QTorusGeometry::radiusChanged, this, &QTorusMesh::radiusChanged); - QObject::connect(geometry, &QTorusGeometry::ringsChanged, this, &QTorusMesh::ringsChanged); - QObject::connect(geometry, &QTorusGeometry::slicesChanged, this, &QTorusMesh::slicesChanged); - QObject::connect(geometry, &QTorusGeometry::minorRadiusChanged, this, &QTorusMesh::minorRadiusChanged); + QTorusGeometryView *geometry = new QTorusGeometryView(this); + QObject::connect(geometry, &QTorusGeometryView::radiusChanged, this, &QTorusMesh::radiusChanged); + QObject::connect(geometry, &QTorusGeometryView::ringsChanged, this, &QTorusMesh::ringsChanged); + QObject::connect(geometry, &QTorusGeometryView::slicesChanged, this, &QTorusMesh::slicesChanged); + QObject::connect(geometry, &QTorusGeometryView::minorRadiusChanged, this, &QTorusMesh::minorRadiusChanged); - QGeometryView::setGeometry(geometry); + setView(geometry); } /*! \internal */ @@ -114,22 +115,22 @@ QTorusMesh::~QTorusMesh() void QTorusMesh::setRings(int rings) { - static_cast<QTorusGeometry *>(geometry())->setRings(rings); + static_cast<QTorusGeometryView *>(view())->setRings(rings); } void QTorusMesh::setSlices(int slices) { - static_cast<QTorusGeometry *>(geometry())->setSlices(slices); + static_cast<QTorusGeometryView *>(view())->setSlices(slices); } void QTorusMesh::setRadius(float radius) { - static_cast<QTorusGeometry *>(geometry())->setRadius(radius); + static_cast<QTorusGeometryView *>(view())->setRadius(radius); } void QTorusMesh::setMinorRadius(float minorRadius) { - static_cast<QTorusGeometry *>(geometry())->setMinorRadius(minorRadius); + static_cast<QTorusGeometryView *>(view())->setMinorRadius(minorRadius); } /*! @@ -139,7 +140,7 @@ void QTorusMesh::setMinorRadius(float minorRadius) */ int QTorusMesh::rings() const { - return static_cast<QTorusGeometry *>(geometry())->rings(); + return static_cast<QTorusGeometryView *>(view())->rings(); } /*! @@ -149,7 +150,7 @@ int QTorusMesh::rings() const */ int QTorusMesh::slices() const { - return static_cast<QTorusGeometry *>(geometry())->slices(); + return static_cast<QTorusGeometryView *>(view())->slices(); } /*! @@ -159,7 +160,7 @@ int QTorusMesh::slices() const */ float QTorusMesh::radius() const { - return static_cast<QTorusGeometry *>(geometry())->radius(); + return static_cast<QTorusGeometryView *>(view())->radius(); } /*! @@ -169,7 +170,7 @@ float QTorusMesh::radius() const */ float QTorusMesh::minorRadius() const { - return static_cast<QTorusGeometry *>(geometry())->minorRadius(); + return static_cast<QTorusGeometryView *>(view())->minorRadius(); } } // namespace Qt3DExtras diff --git a/src/extras/geometries/qtorusmesh.h b/src/extras/geometries/qtorusmesh.h index e36d94097..2fd9f0a23 100644 --- a/src/extras/geometries/qtorusmesh.h +++ b/src/extras/geometries/qtorusmesh.h @@ -41,13 +41,13 @@ #define QT3DEXTRAS_QTORUSMESH_H #include <Qt3DExtras/qt3dextras_global.h> -#include <Qt3DCore/qgeometryview.h> +#include <Qt3DRender/qgeometryrenderer.h> QT_BEGIN_NAMESPACE namespace Qt3DExtras { -class Q_3DEXTRASSHARED_EXPORT QTorusMesh : public Qt3DCore::QGeometryView +class Q_3DEXTRASSHARED_EXPORT QTorusMesh : public Qt3DRender::QGeometryRenderer { Q_OBJECT Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged) diff --git a/src/plugins/sceneparsers/gltf/gltfimporter.cpp b/src/plugins/sceneparsers/gltf/gltfimporter.cpp index bd87f7da8..a03afec59 100644 --- a/src/plugins/sceneparsers/gltf/gltfimporter.cpp +++ b/src/plugins/sceneparsers/gltf/gltfimporter.cpp @@ -1817,23 +1817,17 @@ void GLTFImporter::processJSONMesh(const QString &id, const QJsonObject &json) } else { QGeometryRenderer *mesh = nullptr; if (meshType == QStringLiteral("cone")) { - mesh = new QGeometryRenderer; - mesh->setView(new QConeMesh); + mesh = new QConeMesh; } else if (meshType == QStringLiteral("cuboid")) { - mesh = new QGeometryRenderer; - mesh->setView(new QCuboidMesh); + mesh = new QCuboidMesh; } else if (meshType == QStringLiteral("cylinder")) { - mesh = new QGeometryRenderer; - mesh->setView(new QCylinderMesh); + mesh = new QCylinderMesh; } else if (meshType == QStringLiteral("plane")) { - mesh = new QGeometryRenderer; - mesh->setView(new QPlaneMesh); + mesh = new QPlaneMesh; } else if (meshType == QStringLiteral("sphere")) { - mesh = new QGeometryRenderer; - mesh->setView(new QSphereMesh); + mesh = new QSphereMesh; } else if (meshType == QStringLiteral("torus")) { - mesh = new QGeometryRenderer; - mesh->setView(new QTorusMesh); + mesh = new QTorusMesh; } else { qCWarning(GLTFImporterLog, "Invalid mesh type: %ls for mesh: %ls", diff --git a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp index d7424831a..a8eb10116 100644 --- a/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp +++ b/src/plugins/sceneparsers/gltfexport/gltfexporter.cpp @@ -734,13 +734,10 @@ void GLTFExporter::parseMeshes() int meshCount = 0; for (auto it = m_meshMap.constBegin(); it != m_meshMap.constEnd(); ++it) { Node *node = it.key(); - QGeometryRenderer *renderer = it.value(); - QGeometryView *mesh = renderer->view(); - if (!mesh) - continue; + QGeometryRenderer *mesh = it.value(); MeshInfo meshInfo; - meshInfo.originalName = mesh->objectName().isEmpty() ? renderer->objectName() : mesh->objectName(); + meshInfo.originalName = mesh->objectName(); meshInfo.name = newMeshName(); meshInfo.materialName = m_materialInfo.value(m_materialMap.value(node)).name; @@ -767,7 +764,7 @@ void GLTFExporter::parseMeshes() } if (meshInfo.meshType != TypeNone) { - meshInfo.meshComponent = renderer; + meshInfo.meshComponent = mesh; cacheDefaultProperties(meshInfo.meshType); if (GLTFExporterLog().isDebugEnabled()) { @@ -976,7 +973,7 @@ void GLTFExporter::parseMeshes() } meshCount++; - m_meshInfo.insert(renderer, meshInfo); + m_meshInfo.insert(mesh, meshInfo); } qCDebug(GLTFExporterLog, "Total buffer size: %i", m_buffer.size()); @@ -1252,7 +1249,7 @@ bool GLTFExporter::saveScene() mesh["name"] = meshInfo.originalName; if (meshInfo.meshType != TypeNone) { QJsonObject properties; - exportGenericProperties(properties, meshInfo.meshType, meshInfo.meshComponent->view()); + exportGenericProperties(properties, meshInfo.meshType, meshInfo.meshComponent); mesh["type"] = meshInfo.meshTypeStr; mesh["properties"] = properties; mesh["material"] = meshInfo.materialName; diff --git a/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp index 515f9545c..a7bdd62db 100644 --- a/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp +++ b/src/quick3d/imports/extras/qt3dquick3dextrasplugin.cpp @@ -40,10 +40,13 @@ #include "qt3dquick3dextrasplugin.h" #include <Qt3DExtras/qconegeometry.h> +#include <Qt3DExtras/qconegeometryview.h> #include <Qt3DExtras/qconemesh.h> #include <Qt3DExtras/qcuboidgeometry.h> +#include <Qt3DExtras/qcuboidgeometryview.h> #include <Qt3DExtras/qcuboidmesh.h> #include <Qt3DExtras/qcylindergeometry.h> +#include <Qt3DExtras/qcylindergeometryview.h> #include <Qt3DExtras/qcylindermesh.h> #include <Qt3DExtras/qdiffusemapmaterial.h> #include <Qt3DExtras/qdiffusespecularmapmaterial.h> @@ -63,15 +66,18 @@ #include <Qt3DExtras/qphongalphamaterial.h> #include <Qt3DExtras/qphongmaterial.h> #include <Qt3DExtras/qplanegeometry.h> +#include <Qt3DExtras/qplanegeometryview.h> #include <Qt3DExtras/qplanemesh.h> #include <Qt3DExtras/qskyboxentity.h> #include <Qt3DExtras/qspheregeometry.h> +#include <Qt3DExtras/qspheregeometryview.h> #include <Qt3DExtras/qspheremesh.h> #include <Qt3DExtras/qspritegrid.h> #include <Qt3DExtras/qspritesheetitem.h> #include <Qt3DExtras/qtext2dentity.h> #include <Qt3DExtras/qtexturematerial.h> #include <Qt3DExtras/qtorusgeometry.h> +#include <Qt3DExtras/qtorusgeometryview.h> #include <Qt3DExtras/qtorusmesh.h> #include <Qt3DQuickExtras/private/quick3dlevelofdetailloader_p.h> @@ -122,18 +128,24 @@ void Qt3DQuick3DExtrasPlugin::registerTypes(const char *uri) // Meshes qmlRegisterType<Qt3DExtras::QConeMesh>(uri, 2, 0, "ConeMesh"); qmlRegisterType<Qt3DExtras::QConeGeometry>(uri, 2, 0, "ConeGeometry"); + qmlRegisterType<Qt3DExtras::QConeGeometryView>(uri, 2, 16, "ConeGeometryView"); qmlRegisterType<Qt3DExtras::QCuboidMesh>(uri, 2, 0, "CuboidMesh"); qmlRegisterType<Qt3DExtras::QCuboidGeometry>(uri, 2, 0, "CuboidGeometry"); + qmlRegisterType<Qt3DExtras::QCuboidGeometryView>(uri, 2, 16, "CuboidGeometryView"); qmlRegisterType<Qt3DExtras::QCylinderMesh>(uri, 2, 0, "CylinderMesh"); qmlRegisterType<Qt3DExtras::QCylinderGeometry>(uri, 2, 0, "CylinderGeometry"); + qmlRegisterType<Qt3DExtras::QCylinderGeometryView>(uri, 2, 16, "CylinderGeometryView"); qmlRegisterType<Qt3DExtras::QPlaneMesh>(uri, 2, 0, "PlaneMesh"); qmlRegisterType<Qt3DExtras::QPlaneMesh, 9>(uri, 2, 9, "PlaneMesh"); qmlRegisterType<Qt3DExtras::QPlaneGeometry>(uri, 2, 0, "PlaneGeometry"); + qmlRegisterType<Qt3DExtras::QPlaneGeometryView>(uri, 2, 16, "PlaneGeometryView"); qmlRegisterType<Qt3DExtras::QPlaneGeometry, 9>(uri, 2, 9, "PlaneGeometry"); qmlRegisterType<Qt3DExtras::QTorusMesh>(uri, 2, 0, "TorusMesh"); qmlRegisterType<Qt3DExtras::QTorusGeometry>(uri, 2, 0, "TorusGeometry"); + qmlRegisterType<Qt3DExtras::QTorusGeometryView>(uri, 2, 16, "TorusGeometryView"); qmlRegisterType<Qt3DExtras::QSphereMesh>(uri, 2, 0, "SphereMesh"); qmlRegisterType<Qt3DExtras::QSphereGeometry>(uri, 2, 0, "SphereGeometry"); + qmlRegisterType<Qt3DExtras::QSphereGeometryView>(uri, 2, 16, "SphereGeometryView"); // 3D Text qmlRegisterType<Qt3DExtras::QExtrudedTextGeometry>(uri, 2, 9, "ExtrudedTextGeometry"); |