summaryrefslogtreecommitdiffstats
path: root/src/extras/geometries
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-05-24 12:09:44 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-05-24 12:10:02 +0100
commit77d294db076dac19e8b549b445ffede9f7260c84 (patch)
tree828ee7a6862ec5c0bd24f97cb540625a2c647376 /src/extras/geometries
parent59f8fec8a41606b3185fe3a4e276978e3e1ed5ef (diff)
parent939b9b4b7591e8a421cf048a0a84ed3e75d81d21 (diff)
Merge branch 'dev' into wip/animationwip/animation
Diffstat (limited to 'src/extras/geometries')
-rw-r--r--src/extras/geometries/qconegeometry.cpp4
-rw-r--r--src/extras/geometries/qconemesh.cpp6
-rw-r--r--src/extras/geometries/qcuboidgeometry.cpp3
-rw-r--r--src/extras/geometries/qcuboidgeometry.h2
-rw-r--r--src/extras/geometries/qcuboidgeometry_p.h3
-rw-r--r--src/extras/geometries/qcuboidmesh.cpp3
-rw-r--r--src/extras/geometries/qcuboidmesh.h2
-rw-r--r--src/extras/geometries/qcylindergeometry.cpp5
-rw-r--r--src/extras/geometries/qcylindermesh.cpp6
-rw-r--r--src/extras/geometries/qplanegeometry.cpp49
-rw-r--r--src/extras/geometries/qplanegeometry.h6
-rw-r--r--src/extras/geometries/qplanegeometry_p.h4
-rw-r--r--src/extras/geometries/qplanemesh.cpp27
-rw-r--r--src/extras/geometries/qplanemesh.h6
-rw-r--r--src/extras/geometries/qspheregeometry.cpp4
-rw-r--r--src/extras/geometries/qspheremesh.cpp3
-rw-r--r--src/extras/geometries/qtorusgeometry.cpp6
-rw-r--r--src/extras/geometries/qtorusmesh.cpp3
18 files changed, 116 insertions, 26 deletions
diff --git a/src/extras/geometries/qconegeometry.cpp b/src/extras/geometries/qconegeometry.cpp
index a86d10f6b..12bbf7ce3 100644
--- a/src/extras/geometries/qconegeometry.cpp
+++ b/src/extras/geometries/qconegeometry.cpp
@@ -57,10 +57,12 @@
#include "qconegeometry.h"
#include "qconegeometry_p.h"
+
#include <Qt3DRender/qbuffer.h>
#include <Qt3DRender/qbufferdatagenerator.h>
#include <Qt3DRender/qattribute.h>
-#include <QVector3D>
+#include <QtGui/QVector3D>
+
#include <cmath>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/geometries/qconemesh.cpp b/src/extras/geometries/qconemesh.cpp
index 8baa19217..5e327df03 100644
--- a/src/extras/geometries/qconemesh.cpp
+++ b/src/extras/geometries/qconemesh.cpp
@@ -41,13 +41,15 @@
# define _USE_MATH_DEFINES // For MSVC
#endif
-#include "qconemesh.h"
#include "qconegeometry.h"
+
+#include <Qt3DExtras/qconemesh.h>
#include <Qt3DRender/qbuffer.h>
#include <Qt3DRender/qbufferdatagenerator.h>
#include <Qt3DRender/qattribute.h>
+#include <QtGui/QVector3D>
+
#include <qmath.h>
-#include <QVector3D>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/geometries/qcuboidgeometry.cpp b/src/extras/geometries/qcuboidgeometry.cpp
index 28743858a..3bb68a500 100644
--- a/src/extras/geometries/qcuboidgeometry.cpp
+++ b/src/extras/geometries/qcuboidgeometry.cpp
@@ -39,12 +39,15 @@
#include "qcuboidgeometry.h"
#include "qcuboidgeometry_p.h"
+
#include <Qt3DRender/qattribute.h>
#include <Qt3DRender/qbuffer.h>
#include <Qt3DRender/qbufferdatagenerator.h>
#include <Qt3DRender/private/renderlogging_p.h>
+
#include <limits>
+
QT_BEGIN_NAMESPACE
using namespace Qt3DRender;
diff --git a/src/extras/geometries/qcuboidgeometry.h b/src/extras/geometries/qcuboidgeometry.h
index fad5dcf9f..2c295d6c4 100644
--- a/src/extras/geometries/qcuboidgeometry.h
+++ b/src/extras/geometries/qcuboidgeometry.h
@@ -42,7 +42,7 @@
#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qgeometry.h>
-#include <QSize>
+#include <QtCore/QSize>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/geometries/qcuboidgeometry_p.h b/src/extras/geometries/qcuboidgeometry_p.h
index 212be19b4..cfabc0388 100644
--- a/src/extras/geometries/qcuboidgeometry_p.h
+++ b/src/extras/geometries/qcuboidgeometry_p.h
@@ -51,8 +51,9 @@
// We mean it.
//
+#include <QtCore/QSize>
+
#include <Qt3DRender/private/qgeometry_p.h>
-#include <QSize>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/geometries/qcuboidmesh.cpp b/src/extras/geometries/qcuboidmesh.cpp
index 88c735746..9e10d93a4 100644
--- a/src/extras/geometries/qcuboidmesh.cpp
+++ b/src/extras/geometries/qcuboidmesh.cpp
@@ -38,7 +38,8 @@
****************************************************************************/
#include "qcuboidmesh.h"
-#include "qcuboidgeometry.h"
+
+#include <Qt3DExtras/qcuboidgeometry.h>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/geometries/qcuboidmesh.h b/src/extras/geometries/qcuboidmesh.h
index f709703c5..ca33c5f2d 100644
--- a/src/extras/geometries/qcuboidmesh.h
+++ b/src/extras/geometries/qcuboidmesh.h
@@ -42,7 +42,7 @@
#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qgeometryrenderer.h>
-#include <QSize>
+#include <QtCore/QSize>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/geometries/qcylindergeometry.cpp b/src/extras/geometries/qcylindergeometry.cpp
index 29f7ea7e0..4051477a6 100644
--- a/src/extras/geometries/qcylindergeometry.cpp
+++ b/src/extras/geometries/qcylindergeometry.cpp
@@ -43,11 +43,14 @@
#include "qcylindergeometry.h"
#include "qcylindergeometry_p.h"
+
#include <Qt3DRender/qbuffer.h>
#include <Qt3DRender/qbufferdatagenerator.h>
#include <Qt3DRender/qattribute.h>
+#include <QtGui/QVector3D>
+
#include <qmath.h>
-#include <QVector3D>
+
QT_BEGIN_NAMESPACE
diff --git a/src/extras/geometries/qcylindermesh.cpp b/src/extras/geometries/qcylindermesh.cpp
index 9b0ded28b..02df6295f 100644
--- a/src/extras/geometries/qcylindermesh.cpp
+++ b/src/extras/geometries/qcylindermesh.cpp
@@ -43,12 +43,14 @@
#endif
#include "qcylindermesh.h"
-#include "qcylindergeometry.h"
+
+#include <Qt3DExtras/qcylindergeometry.h>
#include <Qt3DRender/qbuffer.h>
#include <Qt3DRender/qbufferdatagenerator.h>
#include <Qt3DRender/qattribute.h>
+#include <QtGui/QVector3D>
+
#include <qmath.h>
-#include <QVector3D>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/geometries/qplanegeometry.cpp b/src/extras/geometries/qplanegeometry.cpp
index 16b401d3d..14ddb25e6 100644
--- a/src/extras/geometries/qplanegeometry.cpp
+++ b/src/extras/geometries/qplanegeometry.cpp
@@ -39,9 +39,11 @@
#include "qplanegeometry.h"
#include "qplanegeometry_p.h"
+
#include <Qt3DRender/qattribute.h>
#include <Qt3DRender/qbuffer.h>
#include <Qt3DRender/qbufferdatagenerator.h>
+
#include <limits>
QT_BEGIN_NAMESPACE
@@ -52,7 +54,7 @@ namespace Qt3DExtras {
namespace {
-QByteArray createPlaneVertexData(float w, float h, const QSize &resolution)
+QByteArray createPlaneVertexData(float w, float h, const QSize &resolution, bool mirrored)
{
Q_ASSERT(w > 0.0f);
Q_ASSERT(h > 0.0f);
@@ -93,7 +95,7 @@ QByteArray createPlaneVertexData(float w, float h, const QSize &resolution)
// texture coordinates
*fptr++ = u;
- *fptr++ = v;
+ *fptr++ = mirrored ? 1.0f - v : v;
// normal
*fptr++ = 0.0f;
@@ -147,17 +149,18 @@ QByteArray createPlaneIndexData(const QSize &resolution)
class PlaneVertexBufferFunctor : public QBufferDataGenerator
{
public:
- explicit PlaneVertexBufferFunctor(float w, float h, const QSize &resolution)
+ explicit PlaneVertexBufferFunctor(float w, float h, const QSize &resolution, bool mirrored)
: m_width(w)
, m_height(h)
, m_resolution(resolution)
+ , m_mirrored(mirrored)
{}
~PlaneVertexBufferFunctor() {}
QByteArray operator()() Q_DECL_FINAL
{
- return createPlaneVertexData(m_width, m_height, m_resolution);
+ return createPlaneVertexData(m_width, m_height, m_resolution, m_mirrored);
}
bool operator ==(const QBufferDataGenerator &other) const Q_DECL_FINAL
@@ -166,7 +169,8 @@ public:
if (otherFunctor != nullptr)
return (otherFunctor->m_width == m_width &&
otherFunctor->m_height == m_height &&
- otherFunctor->m_resolution == m_resolution);
+ otherFunctor->m_resolution == m_resolution &&
+ otherFunctor->m_mirrored == m_mirrored);
return false;
}
@@ -176,6 +180,7 @@ public:
float m_width;
float m_height;
QSize m_resolution;
+ bool m_mirrored;
};
class PlaneIndexBufferFunctor : public QBufferDataGenerator
@@ -235,6 +240,13 @@ public:
*/
/*!
+ * \qmlproperty bool PlaneGeometry::mirrored
+ * \since 5.9
+ *
+ * Controls if the UV coordinates of the plane should be flipped vertically.
+ */
+
+/*!
* \qmlproperty Attribute PlaneGeometry::positionAttribute
*
* Holds the geometry position attribute.
@@ -316,7 +328,7 @@ void QPlaneGeometry::updateVertices()
d->m_normalAttribute->setCount(nVerts);
d->m_texCoordAttribute->setCount(nVerts);
d->m_tangentAttribute->setCount(nVerts);
- d->m_vertexBuffer->setDataGenerator(QSharedPointer<PlaneVertexBufferFunctor>::create(d->m_width, d->m_height, d->m_meshResolution));
+ d->m_vertexBuffer->setDataGenerator(QSharedPointer<PlaneVertexBufferFunctor>::create(d->m_width, d->m_height, d->m_meshResolution, d->m_mirrored));
}
/*!
@@ -363,6 +375,16 @@ void QPlaneGeometry::setHeight(float height)
emit heightChanged(height);
}
+void QPlaneGeometry::setMirrored(bool mirrored)
+{
+ Q_D(QPlaneGeometry);
+ if (mirrored == d->m_mirrored)
+ return;
+ d->m_mirrored = mirrored;
+ updateVertices();
+ emit mirroredChanged(mirrored);
+}
+
/*!
* \property QPlaneGeometry::resolution
*
@@ -397,6 +419,18 @@ float QPlaneGeometry::height() const
}
/*!
+ * \property QPlaneGeometry::mirrored
+ * \since 5.9
+ *
+ * Controls if the UV coordinates of the plane should be flipped vertically.
+ */
+bool QPlaneGeometry::mirrored() const
+{
+ Q_D(const QPlaneGeometry);
+ return d->m_mirrored;
+}
+
+/*!
* \property QPlaneGeometry::positionAttribute
*
* Holds the geometry position attribute.
@@ -456,6 +490,7 @@ QPlaneGeometryPrivate::QPlaneGeometryPrivate()
, m_width(1.0f)
, m_height(1.0f)
, m_meshResolution(QSize(2, 2))
+ , m_mirrored(false)
, m_positionAttribute(nullptr)
, m_normalAttribute(nullptr)
, m_texCoordAttribute(nullptr)
@@ -523,7 +558,7 @@ void QPlaneGeometryPrivate::init()
// Each primitive has 3 vertives
m_indexAttribute->setCount(faces * 3);
- m_vertexBuffer->setDataGenerator(QSharedPointer<PlaneVertexBufferFunctor>::create(m_width, m_height, m_meshResolution));
+ m_vertexBuffer->setDataGenerator(QSharedPointer<PlaneVertexBufferFunctor>::create(m_width, m_height, m_meshResolution, m_mirrored));
m_indexBuffer->setDataGenerator(QSharedPointer<PlaneIndexBufferFunctor>::create(m_meshResolution));
q->addAttribute(m_positionAttribute);
diff --git a/src/extras/geometries/qplanegeometry.h b/src/extras/geometries/qplanegeometry.h
index 7ec5cba43..4a4efe6eb 100644
--- a/src/extras/geometries/qplanegeometry.h
+++ b/src/extras/geometries/qplanegeometry.h
@@ -42,7 +42,7 @@
#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qgeometry.h>
-#include <QSize>
+#include <QtCore/QSize>
QT_BEGIN_NAMESPACE
@@ -62,6 +62,7 @@ class QT3DEXTRASSHARED_EXPORT QPlaneGeometry : public Qt3DRender::QGeometry
Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged)
Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged)
Q_PROPERTY(QSize resolution READ resolution WRITE setResolution NOTIFY resolutionChanged)
+ Q_PROPERTY(bool mirrored READ mirrored WRITE setMirrored NOTIFY mirroredChanged REVISION 9)
Q_PROPERTY(Qt3DRender::QAttribute *positionAttribute READ positionAttribute CONSTANT)
Q_PROPERTY(Qt3DRender::QAttribute *normalAttribute READ normalAttribute CONSTANT)
Q_PROPERTY(Qt3DRender::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT)
@@ -78,6 +79,7 @@ public:
QSize resolution() const;
float width() const;
float height() const;
+ bool mirrored() const;
Qt3DRender::QAttribute *positionAttribute() const;
Qt3DRender::QAttribute *normalAttribute() const;
@@ -89,11 +91,13 @@ public Q_SLOTS:
void setResolution(const QSize &resolution);
void setWidth(float width);
void setHeight(float height);
+ void setMirrored(bool mirrored);
Q_SIGNALS:
void resolutionChanged(const QSize &resolution);
void widthChanged(float width);
void heightChanged(float height);
+ void mirroredChanged(bool mirrored);
protected:
QPlaneGeometry(QPlaneGeometryPrivate &dd, QNode *parent = nullptr);
diff --git a/src/extras/geometries/qplanegeometry_p.h b/src/extras/geometries/qplanegeometry_p.h
index d0a4e88e4..68d979895 100644
--- a/src/extras/geometries/qplanegeometry_p.h
+++ b/src/extras/geometries/qplanegeometry_p.h
@@ -51,8 +51,9 @@
// We mean it.
//
+#include <QtCore/QSize>
+
#include <Qt3DRender/private/qgeometry_p.h>
-#include <QSize>
QT_BEGIN_NAMESPACE
@@ -74,6 +75,7 @@ public:
float m_width;
float m_height;
QSize m_meshResolution;
+ bool m_mirrored;
Qt3DRender::QAttribute *m_positionAttribute;
Qt3DRender::QAttribute *m_normalAttribute;
Qt3DRender::QAttribute *m_texCoordAttribute;
diff --git a/src/extras/geometries/qplanemesh.cpp b/src/extras/geometries/qplanemesh.cpp
index 120aed6df..4804df024 100644
--- a/src/extras/geometries/qplanemesh.cpp
+++ b/src/extras/geometries/qplanemesh.cpp
@@ -38,7 +38,8 @@
****************************************************************************/
#include "qplanemesh.h"
-#include "qplanegeometry.h"
+
+#include <Qt3DExtras/qplanegeometry.h>
QT_BEGIN_NAMESPACE
@@ -72,6 +73,13 @@ namespace Qt3DExtras {
*/
/*!
+ * \qmlproperty bool PlaneMesh::mirrored
+ * \since 5.9
+ *
+ * Controls if the UV coordinates of the plane should be flipped vertically.
+ */
+
+/*!
* \class Qt3DExtras::QPlaneMesh
* \inheaderfile Qt3DExtras/QPlaneMesh
* \inmodule Qt3DExtras
@@ -91,6 +99,7 @@ QPlaneMesh::QPlaneMesh(QNode *parent)
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);
QGeometryRenderer::setGeometry(geometry);
}
@@ -146,6 +155,22 @@ QSize QPlaneMesh::meshResolution() const
return static_cast<QPlaneGeometry *>(geometry())->resolution();
}
+void QPlaneMesh::setMirrored(bool mirrored)
+{
+ static_cast<QPlaneGeometry *>(geometry())->setMirrored(mirrored);
+}
+
+/*!
+ * \property QPlaneMesh::mirrored
+ * \since 5.9
+ *
+ * Controls if the UV coordinates of the plane should be flipped vertically.
+ */
+bool QPlaneMesh::mirrored() const
+{
+ return static_cast<QPlaneGeometry *>(geometry())->mirrored();
+}
+
} // namespace Qt3DExtras
QT_END_NAMESPACE
diff --git a/src/extras/geometries/qplanemesh.h b/src/extras/geometries/qplanemesh.h
index b1505db17..1cf2ae79e 100644
--- a/src/extras/geometries/qplanemesh.h
+++ b/src/extras/geometries/qplanemesh.h
@@ -42,7 +42,7 @@
#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qgeometryrenderer.h>
-#include <QSize>
+#include <QtCore/QSize>
QT_BEGIN_NAMESPACE
@@ -54,6 +54,7 @@ class QT3DEXTRASSHARED_EXPORT QPlaneMesh : public Qt3DRender::QGeometryRenderer
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 QPlaneMesh(Qt3DCore::QNode *parent = nullptr);
@@ -62,16 +63,19 @@ public:
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
diff --git a/src/extras/geometries/qspheregeometry.cpp b/src/extras/geometries/qspheregeometry.cpp
index a79eb8074..eae12ef39 100644
--- a/src/extras/geometries/qspheregeometry.cpp
+++ b/src/extras/geometries/qspheregeometry.cpp
@@ -39,15 +39,17 @@
#include "qspheregeometry.h"
#include "qspheregeometry_p.h"
+
#include <Qt3DRender/qbufferdatagenerator.h>
#include <Qt3DRender/qbuffer.h>
#include <Qt3DRender/qattribute.h>
+#include <qmath.h>
+
#ifndef _USE_MATH_DEFINES
# define _USE_MATH_DEFINES // For MSVC
#endif
-#include <qmath.h>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/geometries/qspheremesh.cpp b/src/extras/geometries/qspheremesh.cpp
index 988a95990..22089d7ab 100644
--- a/src/extras/geometries/qspheremesh.cpp
+++ b/src/extras/geometries/qspheremesh.cpp
@@ -39,7 +39,8 @@
****************************************************************************/
#include "qspheremesh.h"
-#include "qspheregeometry.h"
+
+#include <Qt3DExtras/qspheregeometry.h>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/geometries/qtorusgeometry.cpp b/src/extras/geometries/qtorusgeometry.cpp
index 08afce1b0..57c94ec95 100644
--- a/src/extras/geometries/qtorusgeometry.cpp
+++ b/src/extras/geometries/qtorusgeometry.cpp
@@ -39,12 +39,14 @@
#include "qtorusgeometry.h"
#include "qtorusgeometry_p.h"
+
#include <Qt3DRender/qbuffer.h>
#include <Qt3DRender/qbufferdatagenerator.h>
#include <Qt3DRender/qattribute.h>
+#include <QtGui/QVector3D>
+#include <QtGui/QVector4D>
+
#include <qmath.h>
-#include <QVector3D>
-#include <QVector4D>
QT_BEGIN_NAMESPACE
diff --git a/src/extras/geometries/qtorusmesh.cpp b/src/extras/geometries/qtorusmesh.cpp
index 96fce9ec0..8e7c678db 100644
--- a/src/extras/geometries/qtorusmesh.cpp
+++ b/src/extras/geometries/qtorusmesh.cpp
@@ -43,7 +43,8 @@
#endif
#include "qtorusmesh.h"
-#include "qtorusgeometry.h"
+
+#include <Qt3DExtras/qtorusgeometry.h>
QT_BEGIN_NAMESPACE