summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2015-08-09 00:01:17 +0100
committerSean Harmer <sean.harmer@kdab.com>2015-08-10 01:24:07 +0000
commit0c6e8e1dbf40c27ef85ed421a90807370781c7ed (patch)
treef546c39e3bad93fdb4273f3ff99e5f828c8d72d3
parent1c65685f25b522777097deeffbe7fbde1ae811c8 (diff)
Add QBoxCollider C++ and QML types
Change-Id: I9bd2d2fd13ef5c6899284aa0ac68fdd7fcdefbac Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/collision/collision.pri7
-rw-r--r--src/collision/qboxcollider.cpp124
-rw-r--r--src/collision/qboxcollider.h83
-rw-r--r--src/collision/qboxcollider_p.h64
-rw-r--r--src/quick3d/imports/collision/qt3dquick3dcollisionplugin.cpp2
5 files changed, 278 insertions, 2 deletions
diff --git a/src/collision/collision.pri b/src/collision/collision.pri
index 7996dc6b7..aa783a971 100644
--- a/src/collision/collision.pri
+++ b/src/collision/collision.pri
@@ -5,8 +5,11 @@ HEADERS += \
$$PWD/qcollisionaspect.h \
$$PWD/qcollisionaspect_p.h \
$$PWD/qspherecollider.h \
- $$PWD/qspherecollider_p.h
+ $$PWD/qspherecollider_p.h \
+ $$PWD/qboxcollider.h \
+ $$PWD/qboxcollider_p.h
SOURCES += \
$$PWD/qcollisionaspect.cpp \
- $$PWD/qspherecollider.cpp
+ $$PWD/qspherecollider.cpp \
+ $$PWD/qboxcollider.cpp
diff --git a/src/collision/qboxcollider.cpp b/src/collision/qboxcollider.cpp
new file mode 100644
index 000000000..523b52d2b
--- /dev/null
+++ b/src/collision/qboxcollider.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qboxcollider.h"
+#include "qboxcollider_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+/*!
+ \class Qt3D::QBoxColliderPrivate
+ \internal
+*/
+QBoxColliderPrivate::QBoxColliderPrivate()
+ : QComponentPrivate()
+ , m_center()
+ , m_radii(0.5f, 0.5f, 0.5f) // Unit cube
+{
+}
+
+/*!
+ \class Qt3D::QBoxCollider
+ \inmodule Qt3DCollision
+ \since 5.5
+ \brief Represents a box used for collision detection
+*/
+
+/*!
+ \qmltype BoxCollider
+ \inqmlmodule Qt3D.Collision
+ \instantiates Qt3D::QBoxCollider
+ \inherits Component3D
+ \since 5.5
+*/
+
+/*!
+ Constructs a new QBoxCollider instance with parent \a parent.
+ */
+QBoxCollider::QBoxCollider(QNode *parent)
+ : QComponent(*new QBoxColliderPrivate, parent)
+{
+}
+
+/*! \internal */
+QBoxCollider::QBoxCollider(QBoxColliderPrivate &dd, QNode *parent)
+ : QComponent(dd, parent)
+{
+}
+
+QBoxCollider::~QBoxCollider()
+{
+ QNode::cleanup();
+}
+
+QVector3D QBoxCollider::center() const
+{
+ Q_D(const QBoxCollider);
+ return d->m_center;
+}
+
+QVector3D QBoxCollider::radii() const
+{
+ Q_D(const QBoxCollider);
+ return d->m_radii;
+}
+
+void QBoxCollider::setCenter(const QVector3D &center)
+{
+ Q_D(QBoxCollider);
+ if (d->m_center == center)
+ return;
+
+ d->m_center = center;
+ emit centerChanged(center);
+}
+
+void QBoxCollider::setRadii(const QVector3D &radii)
+{
+ Q_D(QBoxCollider);
+ if (d->m_radii == radii)
+ return;
+
+ d->m_radii = radii;
+ emit radiiChanged(radii);
+}
+
+QT_END_NAMESPACE
+
+} // namespace Qt3D
+
diff --git a/src/collision/qboxcollider.h b/src/collision/qboxcollider.h
new file mode 100644
index 000000000..81aa7456f
--- /dev/null
+++ b/src/collision/qboxcollider.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_QBOXCOLLIDER_H
+#define QT3D_QBOXCOLLIDER_H
+
+#include <QComponent>
+#include <Qt3DCollision/qt3dcollision_global.h>
+#include <QtGui/qvector3d.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QBoxColliderPrivate;
+
+class QT3DCOLLISIONSHARED_EXPORT QBoxCollider : public QComponent
+{
+ Q_OBJECT
+ Q_PROPERTY(QVector3D center READ center WRITE setCenter NOTIFY centerChanged)
+ Q_PROPERTY(QVector3D radii READ radii WRITE setRadii NOTIFY radiiChanged)
+
+public:
+ explicit QBoxCollider(QNode *parent = 0);
+ ~QBoxCollider();
+
+ QVector3D center() const;
+ QVector3D radii() const;
+
+public Q_SLOTS:
+ void setCenter(const QVector3D &center);
+ void setRadii(const QVector3D &radii);
+
+Q_SIGNALS:
+ void centerChanged(QVector3D center);
+ void radiiChanged(QVector3D radii);
+
+protected:
+ QBoxCollider(QBoxColliderPrivate &dd, QNode *parent = 0);
+
+private:
+ Q_DECLARE_PRIVATE(QBoxCollider)
+ QT3D_CLONEABLE(QBoxCollider)
+};
+
+} // namespace Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_QBOXCOLLIDER_H
diff --git a/src/collision/qboxcollider_p.h b/src/collision/qboxcollider_p.h
new file mode 100644
index 000000000..85c2e18d3
--- /dev/null
+++ b/src/collision/qboxcollider_p.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_QBOXCOLLIDER_P_H
+#define QT3D_QBOXCOLLIDER_P_H
+
+#include <Qt3DCore/private/qcomponent_p.h>
+#include <QtGui/QVector3D>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3D {
+
+class QBoxCollider;
+
+class QBoxColliderPrivate : public QComponentPrivate
+{
+ QBoxColliderPrivate();
+
+ Q_DECLARE_PUBLIC(QBoxCollider)
+
+ QVector3D m_center;
+ QVector3D m_radii;
+};
+
+} // namespace Qt3D
+
+QT_END_NAMESPACE
+
+#endif // QT3D_QBOXCOLLIDER_P_H
+
diff --git a/src/quick3d/imports/collision/qt3dquick3dcollisionplugin.cpp b/src/quick3d/imports/collision/qt3dquick3dcollisionplugin.cpp
index ec0aa0114..cc4d2ebd2 100644
--- a/src/quick3d/imports/collision/qt3dquick3dcollisionplugin.cpp
+++ b/src/quick3d/imports/collision/qt3dquick3dcollisionplugin.cpp
@@ -35,6 +35,7 @@
****************************************************************************/
#include <QtQml>
+#include <Qt3DCollision/qboxcollider.h>
#include <Qt3DCollision/qspherecollider.h>
#include "qt3dquick3dcollisionplugin.h"
@@ -42,6 +43,7 @@ QT_BEGIN_NAMESPACE
void Qt3DQuick3DCollisionPlugin::registerTypes(const char *uri)
{
+ qmlRegisterType<Qt3D::QBoxCollider>(uri, 2, 0, "BoxCollider");
qmlRegisterType<Qt3D::QSphereCollider>(uri, 2, 0, "SphereCollider");
}