summaryrefslogtreecommitdiffstats
path: root/src/core/geometry
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/geometry')
-rw-r--r--src/core/geometry/geometry.pri17
-rw-r--r--src/core/geometry/qabstractfunctor.cpp97
-rw-r--r--src/core/geometry/qabstractfunctor.h107
-rw-r--r--src/core/geometry/qattribute.cpp492
-rw-r--r--src/core/geometry/qattribute.h157
-rw-r--r--src/core/geometry/qattribute_p.h87
-rw-r--r--src/core/geometry/qbuffer.cpp314
-rw-r--r--src/core/geometry/qbuffer.h128
-rw-r--r--src/core/geometry/qbuffer_p.h90
-rw-r--r--src/core/geometry/qgeometry.cpp264
-rw-r--r--src/core/geometry/qgeometry.h89
-rw-r--r--src/core/geometry/qgeometry_p.h86
-rw-r--r--src/core/geometry/qgeometryfactory_p.h80
13 files changed, 2008 insertions, 0 deletions
diff --git a/src/core/geometry/geometry.pri b/src/core/geometry/geometry.pri
new file mode 100644
index 000000000..13756ccb3
--- /dev/null
+++ b/src/core/geometry/geometry.pri
@@ -0,0 +1,17 @@
+INCLUDEPATH += $$PWD
+
+HEADERS += \
+ $$PWD/qabstractfunctor.h \
+ $$PWD/qattribute.h \
+ $$PWD/qattribute_p.h \
+ $$PWD/qbuffer.h \
+ $$PWD/qbuffer_p.h \
+ $$PWD/qgeometry_p.h \
+ $$PWD/qgeometry.h \
+ $$PWD/qgeometryfactory_p.h
+
+SOURCES += \
+ $$PWD/qabstractfunctor.cpp \
+ $$PWD/qattribute.cpp \
+ $$PWD/qbuffer.cpp \
+ $$PWD/qgeometry.cpp \
diff --git a/src/core/geometry/qabstractfunctor.cpp b/src/core/geometry/qabstractfunctor.cpp
new file mode 100644
index 000000000..3bd774a4f
--- /dev/null
+++ b/src/core/geometry/qabstractfunctor.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 "qabstractfunctor.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+/*!
+ \class Qt3DCore::QAbstractFunctor
+ \inmodule Qt3DCore
+ \since 5.7
+ \brief QAbstractFunctor is an abstract base class for all functors.
+
+ The QAbstractFunctor is used as a base class for all functors and data
+ generators in Qt3DCore module.
+
+ When user defines a new functor or generator, they need to implement the
+ \l QAbstractFunctor::id() method, which should be done using the \c {QT3D_FUNCTOR}
+ macro in the class definition.
+ */
+/*!
+ \fn qintptr Qt3DCore::QAbstractFunctor::id() const
+
+ Returns a pointer to the id of the functor.
+ */
+/*!
+ \fn qintptr Qt3DCore::functorTypeId()
+
+ Returns a pointer to the type id of the functor.
+*/
+/*!
+ \macro QT3D_FUNCTOR(Class)
+ \relates Qt3DCore::QAbstractFunctor
+
+ This macro assigns functor id to the \a Class, which is used by QAbstractFunctor::functor_cast
+ to determine if the cast can be done.
+ */
+
+/*!
+ \fn template<class T> const T * Qt3DCore::QAbstractFunctor::functor_cast(const QAbstractFunctor *other) const
+
+ This method is used to cast functor \a other to type T if the other is of
+ type T (or of subclass); otherwise returns 0. This method works similarly
+ to \l [QtCore] {qobject_cast(const QObject *object)}{qobject_cast()},
+ except with functors derived from QAbstractFunctor.
+
+ \warning If T was not declared with \l QT3D_FUNCTOR macro, then the results are undefined.
+ */
+
+/*! Desctructor */
+QAbstractFunctor::~QAbstractFunctor()
+{
+
+}
+
+} // Qt3D
+
+QT_END_NAMESPACE
+
diff --git a/src/core/geometry/qabstractfunctor.h b/src/core/geometry/qabstractfunctor.h
new file mode 100644
index 000000000..9bd6e670b
--- /dev/null
+++ b/src/core/geometry/qabstractfunctor.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** 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 QT3DCORE_QABSTRACTFUNCTOR_H
+#define QT3DCORE_QABSTRACTFUNCTOR_H
+
+#include <Qt3DCore/qt3dcore_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+// This will generate a unique id() function per type
+// <=> 1 unique function address per type
+template<class T>
+struct FunctorType
+{
+ static qintptr id()
+ {
+ // The MSVC linker can under some cases optimize all the template
+ // functions into a single function. The code below is there to ensure
+ // that the linker won't collapse all these distincts functions into one
+ static T *t = nullptr;
+ return reinterpret_cast<qintptr>(t);
+ }
+};
+
+template<class T>
+qintptr functorTypeId()
+{
+ return reinterpret_cast<qintptr>(&FunctorType<T>::id);
+}
+
+#define QT3D_FUNCTOR(Class) \
+ qintptr id() const override { \
+ return Qt3DCore::functorTypeId<Class>(); \
+ }
+
+
+class Q_3DCORESHARED_EXPORT QAbstractFunctor
+{
+public:
+ QAbstractFunctor() = default;
+ virtual ~QAbstractFunctor();
+ virtual qintptr id() const = 0;
+
+ // TODO: Remove when moving a copy of this to Qt3DCore
+ template<class T>
+ const T *functor_cast(const QAbstractFunctor *other) const
+ {
+ if (other->id() == functorTypeId<T>())
+ return static_cast<const T *>(other);
+ return nullptr;
+ }
+private:
+ Q_DISABLE_COPY(QAbstractFunctor)
+};
+
+template<class T>
+const T *functor_cast(const QAbstractFunctor *other)
+{
+ if (other->id() == functorTypeId<T>())
+ return static_cast<const T *>(other);
+ return nullptr;
+}
+
+} // Qt3DCore
+
+QT_END_NAMESPACE
+
+#endif // QT3DCORE_QABSTRACTFUNCTOR_H
diff --git a/src/core/geometry/qattribute.cpp b/src/core/geometry/qattribute.cpp
new file mode 100644
index 000000000..6be9c0203
--- /dev/null
+++ b/src/core/geometry/qattribute.cpp
@@ -0,0 +1,492 @@
+/****************************************************************************
+**
+** 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 "qattribute.h"
+#include "qattribute_p.h"
+#include <Qt3DCore/qbuffer.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+QAttributePrivate::QAttributePrivate()
+ : QNodePrivate()
+ , m_buffer(nullptr)
+ , m_name()
+ , m_vertexBaseType(QAttribute::Float)
+ , m_vertexSize(1)
+ , m_count(0)
+ , m_byteStride(0)
+ , m_byteOffset(0)
+ , m_divisor(0)
+ , m_attributeType(QAttribute::VertexAttribute)
+{
+}
+
+/*!
+ * \qmltype Attribute
+ * \instantiates Qt3DCore::QAttribute
+ * \inqmlmodule Qt3D.Core
+ * \brief Defines an attribute and how data should be read from a Buffer.
+ *
+ * There are 3 types of attributes.
+ * \list
+ * \li VertexAttribute: used to define data to be read on a per vertex basis
+ * \li IndexAttribute: used to define vertex indices when indexed draw calls are
+ * to be used
+ *\li DrawIndirectAttribute: used to specify the DrawIndirect buffer to be used
+ * when indirect draw calls are to be used
+ * \endlist
+ *
+ * \note when an attribute is of type DrawIndirectAttribute, only count, stride
+ * and offset are relevant.
+ *
+ * When providing your own attributes, it may make sense to name your attribute
+ * using helpers such as QAttribute::defaultPositionAttributeName() as that
+ * will ensure your geometry will be compatible with picking and the various
+ * materials provided in the Qt3DExtras module.
+ */
+
+/*!
+ * \class Qt3DCore::QAttribute
+ * \inheaderfile Qt3DCore/QAttribute
+ * \inmodule Qt3DCore
+ *
+ * \inherits Qt3DCore::QNode
+ *
+ * \brief Defines an attribute and how data should be read from a QBuffer.
+ *
+ * There are 3 types of attributes.
+ * \list
+ * \li VertexAttribute: used to define data to be read on a per vertex basis
+ * \li IndexAttribute: used to define vertex indices when indexed draw calls are
+ * to be used
+ *\li DrawIndirectAttribute: used to specify the DrawIndirect buffer to be used
+ * when indirect draw calls are to be used
+ * \endlist
+ *
+ * \note when an attribute is of type DrawIndirectAttribute, only count, stride
+ * and offset are relevant.
+ *
+ * When providing your own attributes, it may make sense to name your attribute
+ * using helpers such as QAttribute::defaultPositionAttributeName() as that
+ * will ensure your geometry will be compatible with picking and the various
+ * materials provided in the Qt3DExtras module.
+ *
+ * \sa QBuffer
+ */
+
+/*!
+ * \typedef Qt3DCore::QBufferPtr
+ * \relates Qt3DCore::QAttribute
+ */
+
+/*!
+ * \enum QAttribute::AttributeType
+ *
+ * The type of the attribute.
+ *
+ * \value VertexAttribute
+ * \value IndexAttribute
+ * \value DrawIndirectAttribute
+ */
+
+/*!
+ * \enum QAttribute::VertexBaseType
+ *
+ * The type of the data.
+ *
+ * \value Byte
+ * \value UnsignedByte
+ * \value Short
+ * \value UnsignedShort
+ * \value Int
+ * \value UnsignedInt
+ * \value HalfFloat
+ * \value Float
+ * \value Double
+ */
+
+/*!
+ * Constructs a new QAttribute with \a parent.
+ */
+QAttribute::QAttribute(QNode *parent)
+ : QNode(*new QAttributePrivate(), parent)
+{
+}
+
+/*!
+ * Constructs a new QAttribute from \a buf of \a type, \a dataSize, \a count, \a offset,
+ * and \a stride with \a parent.
+ */
+QAttribute::QAttribute(QBuffer *buf, VertexBaseType type, uint dataSize, uint count, uint offset, uint stride, QNode *parent)
+ : QAttribute(parent)
+{
+ Q_D(QAttribute);
+ setBuffer(buf);
+ d->m_count = count;
+ d->m_byteOffset = offset;
+ d->m_vertexBaseType = type;
+ d->m_vertexSize = dataSize;
+ d->m_byteStride = stride;
+}
+
+
+/*!
+ * Constructs a new QAttribute named \a name from \a buf of \a type, \a
+ * dataSize, \a count, \a offset, and \a stride with \a parent.
+ */
+QAttribute::QAttribute(QBuffer *buf, const QString &name, VertexBaseType type, uint dataSize, uint count, uint offset, uint stride, QNode *parent)
+ : QAttribute(parent)
+{
+ Q_D(QAttribute);
+ setBuffer(buf);
+ d->m_name = name;
+ d->m_count = count;
+ d->m_byteOffset = offset;
+ d->m_vertexBaseType = type;
+ d->m_vertexSize = dataSize;
+ d->m_byteStride = stride;
+}
+
+/*! \internal */
+QAttribute::~QAttribute()
+{
+}
+
+/*!
+ * \property QAttribute::buffer
+ *
+ * Holds the buffer.
+ */
+QBuffer *QAttribute::buffer() const
+{
+ Q_D(const QAttribute);
+ return d->m_buffer;
+}
+
+/*!
+ * \property QAttribute::name
+ *
+ * Holds the name.
+ */
+QString QAttribute::name() const
+{
+ Q_D(const QAttribute);
+ return d->m_name;
+}
+
+/*!
+ * \property QAttribute::vertexSize
+ *
+ * Holds the data size, it can only be 1 to 4 units (scalars and vectors),
+ * 9 units (3x3 matrices) or 16 units (4x4 matrices).
+ */
+uint QAttribute::vertexSize() const
+{
+ Q_D(const QAttribute);
+ return d->m_vertexSize;
+}
+
+/*!
+ * \property QAttribute::vertexBaseType
+ *
+ * Holds the data type.
+ */
+QAttribute::VertexBaseType QAttribute::vertexBaseType() const
+{
+ Q_D(const QAttribute);
+ return d->m_vertexBaseType;
+}
+
+/*!
+ * \property QAttribute::count
+ *
+ * Holds the count.
+ */
+uint QAttribute::count() const
+{
+ Q_D(const QAttribute);
+ return d->m_count;
+}
+
+/*!
+ * \property QAttribute::byteStride
+ *
+ * Holds the byte stride.
+ */
+uint QAttribute::byteStride() const
+{
+ Q_D(const QAttribute);
+ return d->m_byteStride;
+}
+
+/*!
+ * \property QAttribute::byteOffset
+ *
+ * Holds the byte offset.
+ */
+uint QAttribute::byteOffset() const
+{
+ Q_D(const QAttribute);
+ return d->m_byteOffset;
+}
+
+/*!
+ * \property QAttribute::divisor
+ *
+ * Holds the divisor.
+ */
+uint QAttribute::divisor() const
+{
+ Q_D(const QAttribute);
+ return d->m_divisor;
+}
+
+/*!
+ * \property QAttribute::attributeType
+ *
+ * Holds the attribute type.
+ */
+QAttribute::AttributeType QAttribute::attributeType() const
+{
+ Q_D(const QAttribute);
+ return d->m_attributeType;
+}
+
+void QAttribute::setBuffer(QBuffer *buffer)
+{
+ Q_D(QAttribute);
+ if (d->m_buffer == buffer)
+ return;
+
+ if (d->m_buffer)
+ d->unregisterDestructionHelper(d->m_buffer);
+
+ // We need to add it as a child of the current node if it has been declared inline
+ // Or not previously added as a child of the current node so that
+ // 1) The backend gets notified about it's creation
+ // 2) When the current node is destroyed, it gets destroyed as well
+ if (buffer && !buffer->parent())
+ buffer->setParent(this);
+
+ d->m_buffer = buffer;
+
+ // Ensures proper bookkeeping
+ if (d->m_buffer)
+ d->registerDestructionHelper(d->m_buffer, &QAttribute::setBuffer, d->m_buffer);
+
+ emit bufferChanged(buffer);
+}
+
+void QAttribute::setName(const QString &name)
+{
+ Q_D(QAttribute);
+ if (d->m_name == name)
+ return;
+
+ d->m_name = name;
+ emit nameChanged(name);
+}
+
+void QAttribute::setVertexBaseType(VertexBaseType type)
+{
+ Q_D(QAttribute);
+
+ if (d->m_vertexBaseType == type)
+ return;
+
+ d->m_vertexBaseType = type;
+ emit vertexBaseTypeChanged(type);
+ emit dataTypeChanged(type);
+}
+
+void QAttribute::setVertexSize(uint size)
+{
+ Q_D(QAttribute);
+ if (d->m_vertexSize == size)
+ return;
+ Q_ASSERT((size >= 1 && size <= 4) || (size == 9) || (size == 16));
+ d->m_vertexSize = size;
+ emit vertexSizeChanged(size);
+ emit dataSizeChanged(size);
+}
+
+void QAttribute::setCount(uint count)
+{
+ Q_D(QAttribute);
+ if (d->m_count == count)
+ return;
+
+ d->m_count = count;
+ emit countChanged(count);
+}
+
+void QAttribute::setByteStride(uint byteStride)
+{
+ Q_D(QAttribute);
+ if (d->m_byteStride == byteStride)
+ return;
+
+ d->m_byteStride = byteStride;
+ emit byteStrideChanged(byteStride);
+}
+
+void QAttribute::setByteOffset(uint byteOffset)
+{
+ Q_D(QAttribute);
+ if (d->m_byteOffset == byteOffset)
+ return;
+
+ d->m_byteOffset = byteOffset;
+ emit byteOffsetChanged(byteOffset);
+}
+
+void QAttribute::setDivisor(uint divisor)
+{
+ Q_D(QAttribute);
+ if (d->m_divisor == divisor)
+ return;
+
+ d->m_divisor = divisor;
+ emit divisorChanged(divisor);
+}
+
+void QAttribute::setAttributeType(AttributeType attributeType)
+{
+ Q_D(QAttribute);
+ if (d->m_attributeType == attributeType)
+ return;
+
+ d->m_attributeType = attributeType;
+ emit attributeTypeChanged(attributeType);
+}
+/*!
+ * \brief QAttribute::defaultPositionAttributeName
+ * \return the name of the default position attribute
+ */
+QString QAttribute::defaultPositionAttributeName()
+{
+ return QStringLiteral("vertexPosition");
+}
+/*!
+ * \brief QAttribute::defaultNormalAttributeName
+ * \return the name of the default normal attribute
+ */
+QString QAttribute::defaultNormalAttributeName()
+{
+ return QStringLiteral("vertexNormal");
+}
+/*!
+ * \brief QAttribute::defaultColorAttributeName
+ * \return the name of the default color attribute
+ */
+QString QAttribute::defaultColorAttributeName()
+{
+ return QStringLiteral("vertexColor");
+}
+/*!
+ * \brief QAttribute::defaultTextureCoordinateAttributeName
+ * \return the name of the default texture coordinate attribute
+ */
+QString QAttribute::defaultTextureCoordinateAttributeName()
+{
+ return QStringLiteral("vertexTexCoord");
+}
+/*!
+ * \brief QAttribute::defaultTangentAttributeName
+ * \return the name of the default tangent attribute
+ */
+QString QAttribute::defaultTangentAttributeName()
+{
+ return QStringLiteral("vertexTangent");
+}
+
+/*!
+ * \brief QAttribute::defaultJointIndicesAttributeName
+ * \return the name of the default joint indices attribute
+ */
+QString QAttribute::defaultJointIndicesAttributeName()
+{
+ return QStringLiteral("vertexJointIndices");
+}
+
+/*!
+ * \brief QAttribute::defaultJointIndicesAttributeName
+ * \return the name of the default joint weights attribute
+ */
+QString QAttribute::defaultJointWeightsAttributeName()
+{
+ return QStringLiteral("vertexJointWeights");
+}
+
+/*!
+ * \brief QAttribute::defaultTextureCoordinate1AttributeName
+ * \return the name of the default attribute for the second layer of texture
+ * coordinates
+ */
+QString QAttribute::defaultTextureCoordinate1AttributeName()
+{
+ return QStringLiteral("vertexTexCoord1");
+}
+
+/*!
+ * \brief QAttribute::defaultTextureCoordinate2AttributeName
+ * \return the name of the default attribute for the third layer of texture
+ * coordinates
+ */
+QString QAttribute::defaultTextureCoordinate2AttributeName()
+{
+ return QStringLiteral("vertexTexCoord2");
+}
+
+/*!
+\fn Qt3DCore::QAttribute::dataSizeChanged(uint vertexSize)
+
+The signal is emitted with \a vertexSize when the dataSize changes.
+*/
+/*!
+\fn Qt3DCore::QAttribute::dataTypeChanged(Qt3DCore::QAttribute::VertexBaseType vertexBaseType)
+
+The signal is emitted with \a vertexBaseType when the dataType changed.
+*/
+
+} // Qt3DCore
+
+QT_END_NAMESPACE
diff --git a/src/core/geometry/qattribute.h b/src/core/geometry/qattribute.h
new file mode 100644
index 000000000..aa0e5ce8b
--- /dev/null
+++ b/src/core/geometry/qattribute.h
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** 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 QT3DCORE_QATTRIBUTE_H
+#define QT3DCORE_QATTRIBUTE_H
+
+#include <Qt3DCore/qt3dcore_global.h>
+#include <Qt3DCore/qnode.h>
+#include <QtCore/QSharedPointer>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+class QBuffer;
+class QAttributePrivate;
+
+typedef QSharedPointer<QBuffer> QBufferPtr;
+
+class Q_3DCORESHARED_EXPORT QAttribute : public QNode
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DCore::QBuffer *buffer READ buffer WRITE setBuffer NOTIFY bufferChanged)
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(VertexBaseType vertexBaseType READ vertexBaseType WRITE setVertexBaseType NOTIFY vertexBaseTypeChanged)
+ Q_PROPERTY(uint vertexSize READ vertexSize WRITE setVertexSize NOTIFY vertexSizeChanged)
+ Q_PROPERTY(uint count READ count WRITE setCount NOTIFY countChanged)
+ Q_PROPERTY(uint byteStride READ byteStride WRITE setByteStride NOTIFY byteStrideChanged)
+ Q_PROPERTY(uint byteOffset READ byteOffset WRITE setByteOffset NOTIFY byteOffsetChanged)
+ Q_PROPERTY(uint divisor READ divisor WRITE setDivisor NOTIFY divisorChanged)
+ Q_PROPERTY(AttributeType attributeType READ attributeType WRITE setAttributeType NOTIFY attributeTypeChanged)
+ Q_PROPERTY(QString defaultPositionAttributeName READ defaultPositionAttributeName CONSTANT)
+ Q_PROPERTY(QString defaultNormalAttributeName READ defaultNormalAttributeName CONSTANT)
+ Q_PROPERTY(QString defaultColorAttributeName READ defaultColorAttributeName CONSTANT)
+ Q_PROPERTY(QString defaultTextureCoordinateAttributeName READ defaultTextureCoordinateAttributeName CONSTANT)
+ Q_PROPERTY(QString defaultTextureCoordinate1AttributeName READ defaultTextureCoordinate1AttributeName CONSTANT REVISION 11)
+ Q_PROPERTY(QString defaultTextureCoordinate2AttributeName READ defaultTextureCoordinate2AttributeName CONSTANT REVISION 11)
+ Q_PROPERTY(QString defaultTangentAttributeName READ defaultTangentAttributeName CONSTANT)
+ Q_PROPERTY(QString defaultJointIndicesAttributeName READ defaultJointIndicesAttributeName CONSTANT REVISION 10)
+ Q_PROPERTY(QString defaultJointWeightsAttributeName READ defaultJointWeightsAttributeName CONSTANT REVISION 10)
+
+public:
+ enum AttributeType {
+ VertexAttribute,
+ IndexAttribute,
+ DrawIndirectAttribute
+ };
+
+ Q_ENUM(AttributeType) // LCOV_EXCL_LINE
+
+ enum VertexBaseType {
+ Byte = 0,
+ UnsignedByte,
+ Short,
+ UnsignedShort,
+ Int,
+ UnsignedInt,
+ HalfFloat,
+ Float,
+ Double
+ };
+ Q_ENUM(VertexBaseType) // LCOV_EXCL_LINE
+
+ explicit QAttribute(QNode *parent = nullptr);
+ explicit QAttribute(QBuffer *buf, VertexBaseType vertexBaseType, uint vertexSize, uint count, uint offset = 0, uint stride = 0, QNode *parent = nullptr);
+ explicit QAttribute(QBuffer *buf, const QString &name, VertexBaseType vertexBaseType, uint vertexSize, uint count, uint offset = 0, uint stride = 0, QNode *parent = nullptr);
+ ~QAttribute();
+
+ QBuffer *buffer() const;
+ QString name() const;
+ VertexBaseType vertexBaseType() const;
+ uint vertexSize() const;
+ uint count() const;
+ uint byteStride() const;
+ uint byteOffset() const;
+ uint divisor() const;
+ AttributeType attributeType() const;
+
+ Q_INVOKABLE static QString defaultPositionAttributeName();
+ Q_INVOKABLE static QString defaultNormalAttributeName();
+ Q_INVOKABLE static QString defaultColorAttributeName();
+ Q_INVOKABLE static QString defaultTextureCoordinateAttributeName();
+ Q_INVOKABLE static QString defaultTangentAttributeName();
+ static QString defaultJointIndicesAttributeName();
+ static QString defaultJointWeightsAttributeName();
+ static QString defaultTextureCoordinate1AttributeName();
+ static QString defaultTextureCoordinate2AttributeName();
+
+public Q_SLOTS:
+ void setBuffer(QBuffer *buffer);
+ void setName(const QString &name);
+ void setVertexBaseType(VertexBaseType type);
+ void setVertexSize(uint size);
+ void setCount(uint count);
+ void setByteStride(uint byteStride);
+ void setByteOffset(uint byteOffset);
+ void setDivisor(uint divisor);
+ void setAttributeType(AttributeType attributeType);
+
+Q_SIGNALS:
+ void bufferChanged(QBuffer *buffer);
+ void nameChanged(const QString &name);
+ void vertexBaseTypeChanged(VertexBaseType vertexBaseType);
+ void vertexSizeChanged(uint vertexSize);
+ void dataTypeChanged(VertexBaseType vertexBaseType);
+ void dataSizeChanged(uint vertexSize);
+ void countChanged(uint count);
+ void byteStrideChanged(uint byteStride);
+ void byteOffsetChanged(uint byteOffset);
+ void divisorChanged(uint divisor);
+ void attributeTypeChanged(AttributeType attributeType);
+
+private:
+ Q_DECLARE_PRIVATE(QAttribute)
+};
+
+} // Qt3DCore
+
+QT_END_NAMESPACE
+
+#endif // QT3DCORE_QATTRIBUTE_H
diff --git a/src/core/geometry/qattribute_p.h b/src/core/geometry/qattribute_p.h
new file mode 100644
index 000000000..755a62207
--- /dev/null
+++ b/src/core/geometry/qattribute_p.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** 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 QT3DCORE_QATTRIBUTE_P_H
+#define QT3DCORE_QATTRIBUTE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DCore/QAttribute>
+#include <Qt3DCore/QBuffer>
+#include <private/qnode_p.h>
+#include <private/qt3dcore_global_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+class QAttribute;
+
+class Q_3DCORE_PRIVATE_EXPORT QAttributePrivate : public Qt3DCore::QNodePrivate
+{
+public:
+ Q_DECLARE_PUBLIC(QAttribute)
+
+ QAttributePrivate();
+
+ QBuffer *m_buffer;
+ QString m_name;
+ QAttribute::VertexBaseType m_vertexBaseType;
+ uint m_vertexSize;
+ uint m_count;
+ uint m_byteStride;
+ uint m_byteOffset;
+ uint m_divisor;
+ QAttribute::AttributeType m_attributeType;
+};
+
+} // Qt3DCore
+
+QT_END_NAMESPACE
+
+#endif // QT3DCORE_QATTRIBUTE_P_H
diff --git a/src/core/geometry/qbuffer.cpp b/src/core/geometry/qbuffer.cpp
new file mode 100644
index 000000000..1b0101c26
--- /dev/null
+++ b/src/core/geometry/qbuffer.cpp
@@ -0,0 +1,314 @@
+/****************************************************************************
+**
+** 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 "qbuffer.h"
+#include "qbuffer_p.h"
+#include <Qt3DCore/private/corelogging_p.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DCore;
+
+namespace Qt3DCore {
+
+QBufferPrivate::QBufferPrivate()
+ : QNodePrivate()
+ , m_type(QBuffer::VertexBuffer)
+ , m_usage(QBuffer::StaticDraw)
+ , m_access(QBuffer::Write)
+{
+}
+
+void QBufferPrivate::setData(const QByteArray &data)
+{
+ Q_Q(QBuffer);
+ const bool blocked = q->blockNotifications(true);
+ m_data = data;
+ emit q->dataChanged(data);
+ q->blockNotifications(blocked);
+}
+
+/*!
+ * \qmltype Buffer
+ * \instantiates Qt3DCore::QBuffer
+ * \inqmlmodule Qt3D.Render
+ *
+ * \brief Provides a data store for raw data to later be used as vertices or
+ * uniforms.
+ */
+
+/*!
+ * \qmlproperty QBuffer::UsageType Buffer::usage
+ *
+ * Holds the buffer usage.
+ */
+
+/*!
+ * \qmlproperty QBuffer::BufferType Buffer::type
+ *
+ * Holds the buffer type.
+ *
+ * \deprecated
+ */
+
+/*!
+ * \class Qt3DCore::QBuffer
+ * \inheaderfile Qt3DCore/QBuffer
+ * \inmodule Qt3DCore
+ *
+ * \inherits Qt3DCore::QNode
+ *
+ * \brief Provides a data store for raw data to later be used as vertices or
+ * uniforms.
+ *
+ * Data can be provided directly using QBuffer::setData().
+ */
+
+/*!
+ * \fn void Qt3DCore::QBuffer::dataChanged(const QByteArray &bytes)
+ *
+ * This signal is emitted with \a bytes when data changes.
+ */
+
+/*!
+ * \fn void Qt3DCore::QBuffer::dataAvailable()
+ *
+ * This signal is emitted when data becomes available.
+ */
+
+/*!
+ * \enum QBuffer::BufferType
+ *
+ * The type of the buffer.
+ *
+ * \value VertexBuffer
+ * GL_ARRAY_BUFFER
+ * \value IndexBuffer
+ * GL_ELEMENT_ARRAY_BUFFER
+ * \value PixelPackBuffer
+ * GL_PIXEL_PACK_BUFFER
+ * \value PixelUnpackBuffer
+ * GL_PIXEL_UNPACK_BUFFER
+ * \value UniformBuffer
+ * GL_UNIFORM_BUFFER
+ * \value ShaderStorageBuffer
+ * GL_SHADER_STORAGE_BUFFER
+ * \value DrawIndirectBuffer
+ * GL_DRAW_INDIRECT_BUFFER
+ *
+ * \deprecated
+ */
+
+/*!
+ * \enum QBuffer::UsageType
+ *
+ * The type of the usage.
+ *
+ * \value StreamDraw
+ * GL_STREAM_DRAW
+ * \value StreamRead
+ * GL_STREAM_READ
+ * \value StreamCopy
+ * GL_STREAM_COPY
+ * \value StaticDraw
+ * GL_STATIC_DRAW
+ * \value StaticRead
+ * GL_STATIC_READ
+ * \value StaticCopy
+ * GL_STATIC_COPY
+ * \value DynamicDraw
+ * GL_DYNAMIC_DRAW
+ * \value DynamicRead
+ * GL_DYNAMIC_READ
+ * \value DynamicCopy
+ * GL_DYNAMIC_COPY
+ */
+
+/*!
+ * \enum QBuffer::AccessType
+ *
+ * \value Write
+ * Write access
+ * \value Read
+ * Read access
+ * \value ReadWrite
+ * Write|Read
+ */
+
+/*!
+ * \typedef Qt3DCore::QBufferDataGeneratorPtr
+ * \relates Qt3DCore::QBuffer
+ */
+
+/*!
+ * Constructs a new QBuffer with \a parent.
+ */
+QBuffer::QBuffer(QNode *parent)
+ : QNode(*new QBufferPrivate(), parent)
+{
+}
+
+/*!
+ * Constructs a new QBuffer of buffer type \a ty with \a parent.
+ *
+ * \deprecated
+ */
+QBuffer::QBuffer(QBuffer::BufferType ty, QNode *parent)
+ : QNode(*new QBufferPrivate(), parent)
+{
+ Q_D(QBuffer);
+ d->m_type = ty;
+}
+
+/*!
+ * \internal
+ */
+QBuffer::~QBuffer()
+{
+}
+
+/*!
+ * Sets \a bytes as data.
+ */
+void QBuffer::setData(const QByteArray &bytes)
+{
+ Q_D(QBuffer);
+ if (bytes != d->m_data) {
+ d->setData(bytes);
+ d->update();
+ }
+}
+
+/*!
+ * Updates the data by replacing it with \a bytes at \a offset.
+ */
+void QBuffer::updateData(int offset, const QByteArray &bytes)
+{
+ Q_D(QBuffer);
+ Q_ASSERT(offset >= 0 && (offset + bytes.size()) <= d->m_data.size());
+
+ // Update data
+ d->m_data.replace(offset, bytes.size(), bytes);
+ const bool blocked = blockNotifications(true);
+ emit dataChanged(d->m_data);
+ blockNotifications(blocked);
+
+ QBufferUpdate updateData;
+ updateData.offset = offset;
+ updateData.data = bytes;
+ setProperty("QT3D_updateData", QVariant::fromValue(updateData));
+ d->update();
+}
+
+/*!
+ * \return the data.
+ */
+QByteArray QBuffer::data() const
+{
+ Q_D(const QBuffer);
+ return d->m_data;
+}
+
+/*!
+ * \property QBuffer::usage
+ *
+ * Holds the buffer usage.
+ */
+QBuffer::UsageType QBuffer::usage() const
+{
+ Q_D(const QBuffer);
+ return d->m_usage;
+}
+
+void QBuffer::setUsage(QBuffer::UsageType usage)
+{
+ Q_D(QBuffer);
+ if (usage != d->m_usage) {
+ d->m_usage = usage;
+ emit usageChanged(usage);
+ }
+}
+
+/*!
+ * \property QBuffer::type
+ *
+ * Holds the buffer type.
+ *
+ * \deprecated
+ */
+QBuffer::BufferType QBuffer::type() const
+{
+ Q_D(const QBuffer);
+ return d->m_type;
+}
+
+void QBuffer::setAccessType(QBuffer::AccessType access)
+{
+ Q_D(QBuffer);
+ if (d->m_access != access) {
+ d->m_access = access;
+ Q_EMIT accessTypeChanged(access);
+ }
+}
+
+/*!
+ * \property Qt3DCore::QBuffer::accessType
+ *
+ * Returns the \l {QBuffer::}{AccessType} of the buffer.
+ *
+ * \sa QBuffer::AccessType
+ */
+QBuffer::AccessType QBuffer::accessType() const
+{
+ Q_D(const QBuffer);
+ return d->m_access;
+}
+
+void QBuffer::setType(QBuffer::BufferType type)
+{
+ Q_D(QBuffer);
+ if (type != d->m_type) {
+ d->m_type = type;
+ emit typeChanged(type);
+ }
+}
+
+} // namespace Qt3DCore
+
+QT_END_NAMESPACE
diff --git a/src/core/geometry/qbuffer.h b/src/core/geometry/qbuffer.h
new file mode 100644
index 000000000..d60f99fa7
--- /dev/null
+++ b/src/core/geometry/qbuffer.h
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** 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 QT3DCORE_QBUFFER_H
+#define QT3DCORE_QBUFFER_H
+
+#include <Qt3DCore/qnode.h>
+#include <Qt3DCore/qt3dcore_global.h>
+#include <QtCore/QSharedPointer>
+
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+class QBufferPrivate;
+
+class Q_3DCORESHARED_EXPORT QBuffer : public Qt3DCore::QNode
+{
+ Q_OBJECT
+ Q_PROPERTY(BufferType type READ type WRITE setType NOTIFY typeChanged)
+ Q_PROPERTY(UsageType usage READ usage WRITE setUsage NOTIFY usageChanged)
+ Q_PROPERTY(AccessType accessType READ accessType WRITE setAccessType NOTIFY accessTypeChanged REVISION 9)
+
+public:
+ enum BufferType
+ {
+ VertexBuffer = 0x8892, // GL_ARRAY_BUFFER
+ IndexBuffer = 0x8893, // GL_ELEMENT_ARRAY_BUFFER
+ PixelPackBuffer = 0x88EB, // GL_PIXEL_PACK_BUFFER
+ PixelUnpackBuffer = 0x88EC, // GL_PIXEL_UNPACK_BUFFER
+ UniformBuffer = 0x8A11, // GL_UNIFORM_BUFFER
+ ShaderStorageBuffer = 0x90D2, // GL_SHADER_STORAGE_BUFFER
+ DrawIndirectBuffer = 0x8F3F // GL_DRAW_INDIRECT_BUFFER
+ };
+ Q_ENUM(BufferType) // LCOV_EXCL_LINE
+
+ enum UsageType
+ {
+ StreamDraw = 0x88E0, // GL_STREAM_DRAW
+ StreamRead = 0x88E1, // GL_STREAM_READ
+ StreamCopy = 0x88E2, // GL_STREAM_COPY
+ StaticDraw = 0x88E4, // GL_STATIC_DRAW
+ StaticRead = 0x88E5, // GL_STATIC_READ
+ StaticCopy = 0x88E6, // GL_STATIC_COPY
+ DynamicDraw = 0x88E8, // GL_DYNAMIC_DRAW
+ DynamicRead = 0x88E9, // GL_DYNAMIC_READ
+ DynamicCopy = 0x88EA // GL_DYNAMIC_COPY
+ };
+ Q_ENUM(UsageType) // LCOV_EXCL_LINE
+
+ enum AccessType {
+ Write = 0x1,
+ Read = 0x2,
+ ReadWrite = Write|Read
+ };
+ Q_ENUM(AccessType) // LCOV_EXCL_LINE
+
+ explicit QBuffer(Qt3DCore::QNode *parent = nullptr);
+ QT_DEPRECATED explicit QBuffer(BufferType ty, Qt3DCore::QNode *parent = nullptr);
+ ~QBuffer();
+
+ UsageType usage() const;
+ QT_DEPRECATED BufferType type() const;
+ AccessType accessType() const;
+
+ void setData(const QByteArray &bytes);
+ QByteArray data() const;
+
+ Q_INVOKABLE void updateData(int offset, const QByteArray &bytes);
+
+public Q_SLOTS:
+ QT_DEPRECATED void setType(BufferType type);
+ void setUsage(UsageType usage);
+ void setAccessType(AccessType access);
+
+Q_SIGNALS:
+ void dataChanged(const QByteArray &bytes);
+ void typeChanged(BufferType type);
+ void usageChanged(UsageType usage);
+ void accessTypeChanged(AccessType access);
+ void dataAvailable();
+
+private:
+ Q_DECLARE_PRIVATE(QBuffer)
+};
+
+} // namespace Qt3DCore
+
+QT_END_NAMESPACE
+
+#endif // QT3DCORE_QBUFFER_H
diff --git a/src/core/geometry/qbuffer_p.h b/src/core/geometry/qbuffer_p.h
new file mode 100644
index 000000000..c4bb9d834
--- /dev/null
+++ b/src/core/geometry/qbuffer_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** 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 QT3DCORE_QBUFFER_P_H
+#define QT3DCORE_QBUFFER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DCore/private/qnode_p.h>
+#include <Qt3DCore/qbuffer.h>
+#include <Qt3DCore/qt3dcore_global.h>
+#include <private/qnode_p.h>
+#include <QByteArray>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+class Q_3DCORESHARED_EXPORT QBufferPrivate : public Qt3DCore::QNodePrivate
+{
+public:
+ Q_DECLARE_PUBLIC(QBuffer)
+
+ QBufferPrivate();
+
+ QByteArray m_data;
+ QBuffer::BufferType m_type;
+ QBuffer::UsageType m_usage;
+ QBuffer::AccessType m_access;
+
+ void setData(const QByteArray &data);
+};
+
+struct QBufferUpdate
+{
+ int offset;
+ QByteArray data;
+};
+
+} // namespace Qt3DCore
+
+QT_END_NAMESPACE
+Q_DECLARE_METATYPE(Qt3DCore::QBufferUpdate) // LCOV_EXCL_LINE
+
+#endif // QT3DCORE_QBUFFER_P_H
diff --git a/src/core/geometry/qgeometry.cpp b/src/core/geometry/qgeometry.cpp
new file mode 100644
index 000000000..008ad4b3d
--- /dev/null
+++ b/src/core/geometry/qgeometry.cpp
@@ -0,0 +1,264 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 "qgeometry.h"
+#include "qgeometryfactory_p.h"
+#include "qgeometry_p.h"
+#include <private/qnode_p.h>
+#include <Qt3DCore/qattribute.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DCore;
+
+QGeometryFactory::~QGeometryFactory()
+{
+}
+
+QGeometryPrivate::QGeometryPrivate()
+ : QNodePrivate(),
+ m_boundingVolumePositionAttribute(nullptr)
+{
+}
+
+QGeometryPrivate::~QGeometryPrivate()
+{
+}
+
+void QGeometryPrivate::setExtent(const QVector3D &minExtent, const QVector3D &maxExtent)
+{
+ Q_Q(QGeometry);
+ if (m_minExtent != minExtent) {
+ m_minExtent = minExtent;
+ emit q->minExtentChanged(minExtent);
+ }
+
+ if (m_maxExtent != maxExtent) {
+ m_maxExtent = maxExtent;
+ emit q->maxExtentChanged(maxExtent);
+ }
+}
+
+/*!
+ \qmltype Geometry
+ \instantiates Qt3DCore::QGeometry
+ \inqmlmodule Qt3D.Core
+ \inherits Node
+ \since 5.7
+ \brief Encapsulates geometry.
+
+ A Geometry type is used to group a list of Attribute objects together
+ to form a geometric shape Qt3D is able to render using GeometryRenderer.
+ Special attribute can be set in order to calculate bounding volume of the shape.
+ */
+
+/*!
+ \class Qt3DCore::QGeometry
+ \inmodule Qt3DCore
+ \since 5.7
+ \brief Encapsulates geometry.
+
+ A Qt3DCore::QGeometry class is used to group a list of Qt3DCore::QAttribute
+ objects together to form a geometric shape Qt3D is able to render using
+ Qt3DCore::QGeometryRenderer. Special attribute can be set in order to calculate
+ bounding volume of the shape.
+ */
+
+/*!
+ \qmlproperty Attribute Geometry::boundingVolumePositionAttribute
+
+ Holds the attribute used to compute the bounding volume. The bounding volume is used internally
+ for picking and view frustum culling.
+
+ If unspecified, the system will look for the attribute using the name returned by
+ QAttribute::defaultPositionAttributeName.
+
+ \sa Attribute
+ */
+/*!
+ \qmlproperty list<Attribute> Geometry::attributes
+
+ Holds the list of attributes the geometry comprises of.
+ */
+
+/*!
+ \property QGeometry::boundingVolumePositionAttribute
+
+ Holds the attribute used to compute the bounding volume. The bounding volume is used internally
+ for picking and view frustum culling.
+
+ If unspecified, the system will look for the attribute using the name returned by
+ QAttribute::defaultPositionAttributeName.
+
+ \sa Qt3DCore::QAttribute
+ */
+
+
+/*!
+ Constructs a new QGeometry with \a parent.
+ */
+QGeometry::QGeometry(QNode *parent)
+ : QGeometry(*new QGeometryPrivate(), parent) {}
+
+/*!
+ \fn Qt3DCore::QGeometryFactory::operator()()
+
+ Returns the generated geometry.
+*/
+/*!
+ \fn bool Qt3DCore::QGeometryFactory::operator==(const QGeometryFactory &other) const = 0
+
+ Compares the factory with the factory specified in \a other.
+ Returns true if they are equal.
+*/
+/*!
+ \internal
+ */
+QGeometry::~QGeometry()
+{
+}
+
+/*!
+ \internal
+ */
+QGeometry::QGeometry(QGeometryPrivate &dd, QNode *parent)
+ : QNode(dd, parent)
+{
+}
+
+/*!
+ \fn void Qt3DCore::QGeometry::addAttribute(Qt3DCore::QAttribute *attribute)
+ Adds an \a attribute to this geometry.
+ */
+void QGeometry::addAttribute(QAttribute *attribute)
+{
+ Q_ASSERT(attribute);
+ Q_D(QGeometry);
+ if (!d->m_attributes.contains(attribute)) {
+ d->m_attributes.append(attribute);
+
+ // Ensures proper bookkeeping
+ d->registerDestructionHelper(attribute, &QGeometry::removeAttribute, d->m_attributes);
+
+ // We need to add it as a child of the current node if it has been declared inline
+ // Or not previously added as a child of the current node so that
+ // 1) The backend gets notified about it's creation
+ // 2) When the current node is destroyed, it gets destroyed as well
+ if (!attribute->parent())
+ attribute->setParent(this);
+
+ d->update();
+ }
+}
+
+/*!
+ \fn void Qt3DCore::QGeometry::removeAttribute(Qt3DCore::QAttribute *attribute)
+ Removes the given \a attribute from this geometry.
+ */
+void QGeometry::removeAttribute(QAttribute *attribute)
+{
+ Q_ASSERT(attribute);
+ Q_D(QGeometry);
+ d->m_attributes.removeOne(attribute);
+ // Remove bookkeeping connection
+ d->unregisterDestructionHelper(attribute);
+ d->update();
+}
+
+void QGeometry::setBoundingVolumePositionAttribute(QAttribute *boundingVolumePositionAttribute)
+{
+ Q_D(QGeometry);
+ if (d->m_boundingVolumePositionAttribute != boundingVolumePositionAttribute) {
+ d->m_boundingVolumePositionAttribute = boundingVolumePositionAttribute;
+ emit boundingVolumePositionAttributeChanged(boundingVolumePositionAttribute);
+ }
+}
+
+QAttribute *QGeometry::boundingVolumePositionAttribute() const
+{
+ Q_D(const QGeometry);
+ return d->m_boundingVolumePositionAttribute;
+}
+
+/*!
+ \qmlproperty vector3d Geometry::minExtent
+
+ Holds the vertex with the lowest x, y, z position values.
+ */
+
+/*!
+ \property QGeometry::minExtent
+
+ Holds the vertex with the lowest x, y, z position values.
+ */
+QVector3D QGeometry::minExtent() const
+{
+ Q_D(const QGeometry);
+ return d->m_minExtent;
+}
+
+/*!
+ \qmlproperty vector3d Geometry::maxExtent
+
+ Holds the vertex with the highest x, y, z position values.
+ */
+
+/*!
+ \property QGeometry::maxExtent
+
+ Holds the vertex with the highest x, y, z position values.
+ */
+QVector3D QGeometry::maxExtent() const
+{
+ Q_D(const QGeometry);
+ return d->m_maxExtent;
+}
+
+/*!
+ Returns the list of attributes in this geometry.
+ */
+QVector<QAttribute *> QGeometry::attributes() const
+{
+ Q_D(const QGeometry);
+ return d->m_attributes;
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qgeometry.cpp"
diff --git a/src/core/geometry/qgeometry.h b/src/core/geometry/qgeometry.h
new file mode 100644
index 000000000..a619884a0
--- /dev/null
+++ b/src/core/geometry/qgeometry.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 QT3DCORE_QGEOMETRY_H
+#define QT3DCORE_QGEOMETRY_H
+
+#include <Qt3DCore/qnode.h>
+#include <Qt3DCore/qt3dcore_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+class QAttribute;
+class QGeometryPrivate;
+
+class Q_3DCORESHARED_EXPORT QGeometry : public Qt3DCore::QNode
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DCore::QAttribute *boundingVolumePositionAttribute READ boundingVolumePositionAttribute WRITE setBoundingVolumePositionAttribute NOTIFY boundingVolumePositionAttributeChanged)
+ Q_PROPERTY(QVector3D minExtent READ minExtent NOTIFY minExtentChanged REVISION 13)
+ Q_PROPERTY(QVector3D maxExtent READ maxExtent NOTIFY maxExtentChanged REVISION 13)
+public:
+ explicit QGeometry(Qt3DCore::QNode *parent = nullptr);
+ ~QGeometry();
+
+ QVector<QAttribute *> attributes() const;
+ Q_INVOKABLE void addAttribute(Qt3DCore::QAttribute *attribute);
+ Q_INVOKABLE void removeAttribute(Qt3DCore::QAttribute *attribute);
+
+ QAttribute *boundingVolumePositionAttribute() const;
+ QVector3D minExtent() const;
+ QVector3D maxExtent() const;
+
+public Q_SLOTS:
+ void setBoundingVolumePositionAttribute(QAttribute *boundingVolumePositionAttribute);
+
+Q_SIGNALS:
+ void boundingVolumePositionAttributeChanged(QAttribute *boundingVolumePositionAttribute);
+ Q_REVISION(13) void minExtentChanged(const QVector3D &minExtent);
+ Q_REVISION(13) void maxExtentChanged(const QVector3D &maxExtent);
+protected:
+ explicit QGeometry(QGeometryPrivate &dd, Qt3DCore::QNode *parent = nullptr);
+
+private:
+ Q_DECLARE_PRIVATE(QGeometry)
+};
+
+} // namespace Qt3DCore
+
+QT_END_NAMESPACE
+
+#endif // QT3DCORE_QGEOMETRY_H
diff --git a/src/core/geometry/qgeometry_p.h b/src/core/geometry/qgeometry_p.h
new file mode 100644
index 000000000..467131fbe
--- /dev/null
+++ b/src/core/geometry/qgeometry_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 QT3DCORE_QGEOMETRY_P_H
+#define QT3DCORE_QGEOMETRY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DCore/private/qt3dcore_global_p.h>
+#include <Qt3DCore/private/qnode_p.h>
+#include <Qt3DCore/qgeometry.h>
+#include <QVector3D>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+class QAttribute;
+
+class Q_3DCORESHARED_EXPORT QGeometryPrivate : public QNodePrivate
+{
+public:
+ Q_DECLARE_PUBLIC(QGeometry)
+ QGeometryPrivate();
+ ~QGeometryPrivate();
+
+ void setExtent(const QVector3D &minExtent, const QVector3D &maxExtent);
+
+
+ QVector<QAttribute *> m_attributes;
+ QAttribute *m_boundingVolumePositionAttribute;
+ QVector3D m_minExtent;
+ QVector3D m_maxExtent;
+};
+
+} // namespace Qt3DCore
+
+QT_END_NAMESPACE
+
+#endif // QT3DCORE_QGEOMETRY_P_H
+
diff --git a/src/core/geometry/qgeometryfactory_p.h b/src/core/geometry/qgeometryfactory_p.h
new file mode 100644
index 000000000..47f3a5281
--- /dev/null
+++ b/src/core/geometry/qgeometryfactory_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 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 QT3DCORE_QGEOMETRYFACTORY_P_H
+#define QT3DCORE_QGEOMETRYFACTORY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DCore/qt3dcore_global.h>
+#include <Qt3DCore/qabstractfunctor.h>
+#include <QtCore/QSharedPointer>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DCore {
+
+class QGeometry;
+
+class Q_3DCORESHARED_EXPORT QGeometryFactory : public QAbstractFunctor
+{
+public:
+ virtual ~QGeometryFactory();
+ virtual QGeometry *operator()() = 0;
+ virtual bool operator ==(const QGeometryFactory &other) const = 0;
+};
+
+typedef QSharedPointer<QGeometryFactory> QGeometryFactoryPtr;
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(Qt3DCore::QGeometryFactoryPtr) // LCOV_EXCL_LINE
+
+#endif // QT3DCORE_QGEOMETRYFACTORY_P_H