summaryrefslogtreecommitdiffstats
path: root/src/render/backend/cameralens.cpp
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2015-09-13 16:48:23 +0100
committerSean Harmer <sean.harmer@kdab.com>2015-10-13 08:55:19 +0000
commit97ead2ac459516699f88cc6679c700fad4a090d1 (patch)
tree61d0e220ffa75ff5f4c9eb7422b93ea1f1f998d3 /src/render/backend/cameralens.cpp
parentc6f60a8861470d61a1e27310a95b5d21e0112c54 (diff)
Rename RenderCameraLens -> CameraLens
Change-Id: I58e4422c265ddf7a32c0615b378c8017fe0a3461 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/backend/cameralens.cpp')
-rw-r--r--src/render/backend/cameralens.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/render/backend/cameralens.cpp b/src/render/backend/cameralens.cpp
new file mode 100644
index 000000000..faf4fee06
--- /dev/null
+++ b/src/render/backend/cameralens.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 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 "cameralens_p.h"
+#include <Qt3DRenderer/private/renderlogging_p.h>
+
+#include <Qt3DCore/qtransform.h>
+#include <Qt3DCore/qcameralens.h>
+#include <Qt3DCore/qentity.h>
+#include <Qt3DCore/qscenepropertychange.h>
+
+#include <QOpenGLContext>
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3D;
+
+namespace Qt3DRender {
+namespace Render {
+
+CameraLens::CameraLens()
+ : QBackendNode()
+{
+ m_clearColor = QVector4D(0.5, 0.5, 1.0, 1.0);
+}
+
+CameraLens::~CameraLens()
+{
+ cleanup();
+}
+
+void CameraLens::cleanup()
+{
+
+}
+
+void CameraLens::updateFromPeer(Qt3D::QNode *peer)
+{
+ QCameraLens *lens = static_cast<QCameraLens *>(peer);
+ setProjection(lens->projectionMatrix());
+ m_enabled = lens->isEnabled();
+}
+
+void CameraLens::setProjection(const QMatrix4x4 &projection)
+{
+ m_projection = projection;
+}
+
+void CameraLens::sceneChangeEvent(const Qt3D::QSceneChangePtr &e)
+{
+ switch (e->type()) {
+ case NodeUpdated: {
+ QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
+
+ if (propertyChange->propertyName() == QByteArrayLiteral("projectionMatrix")) {
+ QMatrix4x4 projectionMatrix = propertyChange->value().value<QMatrix4x4>();
+ m_projection = projectionMatrix;
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) {
+ m_enabled = propertyChange->value().toBool();
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE