diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-01-15 15:09:44 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-01-16 17:17:49 +0000 |
commit | b0404a42ced2ea5a583e1c6ddc22940ffdc1e48e (patch) | |
tree | b073c3c680e388bda00228b204743b092b11de6a /src/core | |
parent | 8656b95ffb67efe7dd1cc3a65b12d277e83e1d22 (diff) |
Move QCamera/QCameraLens to Qt3DRender
Also get rid of Qt3DRender::QWindow and of the hard codes camera
controller.
Change-Id: I307735d01caf97b7a690b28de8dc99fc9866c35f
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/core-components/core-components.pri | 11 | ||||
-rw-r--r-- | src/core/core-components/qcamera.cpp | 486 | ||||
-rw-r--r-- | src/core/core-components/qcamera.h | 169 | ||||
-rw-r--r-- | src/core/core-components/qcamera_p.h | 89 | ||||
-rw-r--r-- | src/core/core-components/qcameralens.cpp | 476 | ||||
-rw-r--r-- | src/core/core-components/qcameralens.h | 137 | ||||
-rw-r--r-- | src/core/core-components/qcameralens_p.h | 129 | ||||
-rw-r--r-- | src/core/core.pri | 2 |
8 files changed, 0 insertions, 1499 deletions
diff --git a/src/core/core-components/core-components.pri b/src/core/core-components/core-components.pri deleted file mode 100644 index 737c6802e..000000000 --- a/src/core/core-components/core-components.pri +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS += \ - $$PWD/qcamera_p.h \ - $$PWD/qcamera.h \ - $$PWD/qcameralens.h \ - $$PWD/qcameralens_p.h - -SOURCES += \ - $$PWD/qcamera.cpp \ - $$PWD/qcameralens.cpp - -INCLUDEPATH += $$PWD diff --git a/src/core/core-components/qcamera.cpp b/src/core/core-components/qcamera.cpp deleted file mode 100644 index c83371189..000000000 --- a/src/core/core-components/qcamera.cpp +++ /dev/null @@ -1,486 +0,0 @@ -/**************************************************************************** -** -** 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 "qcamera.h" -#include "qcamera_p.h" - -QT_BEGIN_NAMESPACE - -namespace Qt3DCore { - -/*! - \class Qt3DCore::QCameraPrivate - \internal -*/ -QCameraPrivate::QCameraPrivate() - : QEntityPrivate() - , m_position(0.0f, 0.0f, 0.0f) - , m_viewCenter(0.0f, 0.0f, -100.0f) - , m_upVector(0.0f, 1.0f, 0.0f) - , m_cameraToCenter(m_viewCenter - m_position) - , m_viewMatrixDirty(false) - , m_lens(new QCameraLens()) - , m_transform(new QTransform()) -{ -} - -/*! - \qmltype Camera - \instantiates Qt3DCore::QCamera - \inherits Entity - \inqmlmodule Qt3D.Core - \since 5.5 -*/ - -QCamera::QCamera(QNode *parent) - : QEntity(*new QCameraPrivate, parent) -{ - QObject::connect(d_func()->m_lens, SIGNAL(projectionTypeChanged(QCameraLens::ProjectionType)), this, SIGNAL(projectionTypeChanged(QCameraLens::ProjectionType))); - QObject::connect(d_func()->m_lens, SIGNAL(nearPlaneChanged(float)), this, SIGNAL(nearPlaneChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(farPlaneChanged(float)), this, SIGNAL(farPlaneChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(fieldOfViewChanged(float)), this, SIGNAL(fieldOfViewChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(aspectRatioChanged(float)), this, SIGNAL(aspectRatioChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(leftChanged(float)), this, SIGNAL(leftChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(rightChanged(float)), this, SIGNAL(rightChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(bottomChanged(float)), this, SIGNAL(bottomChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(topChanged(float)), this, SIGNAL(topChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(projectionMatrixChanged(const QMatrix4x4 &)), this, SIGNAL(projectionMatrixChanged(const QMatrix4x4 &))); - QObject::connect(d_func()->m_transform, SIGNAL(matrixChanged(const QMatrix4x4 &)), this, SIGNAL(viewMatrixChanged(const QMatrix4x4 &))); - addComponent(d_func()->m_lens); - addComponent(d_func()->m_transform); -} - -QCamera::~QCamera() -{ - QNode::cleanup(); -} - -/*! \internal */ -QCamera::QCamera(QCameraPrivate &dd, QNode *parent) - : QEntity(dd, parent) -{ - QObject::connect(d_func()->m_lens, SIGNAL(projectionTypeChanged(QCameraLens::ProjectionType)), this, SIGNAL(projectionTypeChanged(QCameraLens::ProjectionType))); - QObject::connect(d_func()->m_lens, SIGNAL(nearPlaneChanged(float)), this, SIGNAL(nearPlaneChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(farPlaneChanged(float)), this, SIGNAL(farPlaneChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(fieldOfViewChanged(float)), this, SIGNAL(fieldOfViewChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(aspectRatioChanged(float)), this, SIGNAL(aspectRatioChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(leftChanged(float)), this, SIGNAL(leftChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(rightChanged(float)), this, SIGNAL(rightChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(bottomChanged(float)), this, SIGNAL(bottomChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(topChanged(float)), this, SIGNAL(topChanged(float))); - QObject::connect(d_func()->m_lens, SIGNAL(projectionMatrixChanged(const QMatrix4x4 &)), this, SIGNAL(projectionMatrixChanged(const QMatrix4x4 &))); - QObject::connect(d_func()->m_transform, SIGNAL(matrixChanged(const QMatrix4x4 &)), this, SIGNAL(viewMatrixChanged(const QMatrix4x4 &))); - addComponent(d_func()->m_lens); - addComponent(d_func()->m_transform); -} - -QCameraLens *QCamera::lens() const -{ - Q_D(const QCamera); - return d->m_lens; -} - -QTransform *QCamera::transform() const -{ - Q_D(const QCamera); - return d->m_transform; -} - -void QCamera::translate(const QVector3D &vLocal, CameraTranslationOption option) -{ - QVector3D viewVector = viewCenter() - position(); // From "camera" position to view center - - // Calculate the amount to move by in world coordinates - QVector3D vWorld; - if (!qFuzzyIsNull(vLocal.x())) { - // Calculate the vector for the local x axis - const QVector3D x = QVector3D::crossProduct(viewVector, upVector()).normalized(); - vWorld += vLocal.x() * x; - } - - if (!qFuzzyIsNull(vLocal.y())) - vWorld += vLocal.y() * upVector(); - - if (!qFuzzyIsNull(vLocal.z())) - vWorld += vLocal.z() * viewVector.normalized(); - - // Update the camera position using the calculated world vector - setPosition(position() + vWorld); - - // May be also update the view center coordinates - if (option == TranslateViewCenter) - setViewCenter(viewCenter() + vWorld); - - // Refresh the camera -> view center vector - viewVector = viewCenter() - position(); - - // Calculate a new up vector. We do this by: - // 1) Calculate a new local x-direction vector from the cross product of the new - // camera to view center vector and the old up vector. - // 2) The local x vector is the normal to the plane in which the new up vector - // must lay. So we can take the cross product of this normal and the new - // x vector. The new normal vector forms the last part of the orthonormal basis - const QVector3D x = QVector3D::crossProduct(viewVector, upVector()).normalized(); - setUpVector(QVector3D::crossProduct(x, viewVector).normalized()); -} - -void QCamera::translateWorld(const QVector3D &vWorld, CameraTranslationOption option) -{ - // Update the camera position using the calculated world vector - setPosition(position() + vWorld); - - // May be also update the view center coordinates - if (option == TranslateViewCenter) - setViewCenter(viewCenter() + vWorld); -} - -QQuaternion QCamera::tiltRotation(float angle) const -{ - const QVector3D viewVector = viewCenter() - position(); - const QVector3D xBasis = QVector3D::crossProduct(upVector(), viewVector.normalized()).normalized(); - return QQuaternion::fromAxisAndAngle(xBasis, -angle); -} - -QQuaternion QCamera::panRotation(float angle) const -{ - return QQuaternion::fromAxisAndAngle(upVector(), angle); -} - -QQuaternion QCamera::rollRotation(float angle) const -{ - QVector3D viewVector = viewCenter() - position(); - return QQuaternion::fromAxisAndAngle(viewVector, -angle); -} - -QQuaternion QCamera::rotation(float angle, const QVector3D &axis) const -{ - return QQuaternion::fromAxisAndAngle(axis, angle); -} - -void QCamera::tilt(float angle) -{ - QQuaternion q = tiltRotation(angle); - rotate(q); -} - -void QCamera::pan(float angle) -{ - QQuaternion q = panRotation(-angle); - rotate(q); -} - -void QCamera::pan(float angle, const QVector3D &axis) -{ - QQuaternion q = rotation(-angle, axis); - rotate(q); -} - -void QCamera::roll(float angle) -{ - QQuaternion q = rollRotation(-angle); - rotate(q); -} - -void QCamera::tiltAboutViewCenter(float angle) -{ - QQuaternion q = tiltRotation(-angle); - rotateAboutViewCenter(q); -} - -void QCamera::panAboutViewCenter(float angle) -{ - QQuaternion q = panRotation(angle); - rotateAboutViewCenter(q); -} - -void QCamera::panAboutViewCenter(float angle, const QVector3D &axis) -{ - QQuaternion q = rotation(angle, axis); - rotateAboutViewCenter(q); -} - -void QCamera::rollAboutViewCenter(float angle) -{ - QQuaternion q = rollRotation(angle); - rotateAboutViewCenter(q); -} - -void QCamera::rotate(const QQuaternion& q) -{ - setUpVector(q * upVector()); - QVector3D viewVector = viewCenter() - position(); - QVector3D cameraToCenter = q * viewVector; - setViewCenter(position() + cameraToCenter); -} - -void QCamera::rotateAboutViewCenter(const QQuaternion& q) -{ - setUpVector(q * upVector()); - QVector3D viewVector = viewCenter() - position(); - QVector3D cameraToCenter = q * viewVector; - setPosition(viewCenter() - cameraToCenter); - setViewCenter(position() + cameraToCenter); -} - -void QCamera::setProjectionType(QCameraLens::ProjectionType type) -{ - Q_D(QCamera); - d->m_lens->setProjectionType(type); -} - -/*! - \qmlproperty enumeration Qt3DCore::Camera::projectionType - - Holds the type of the camera projection (orthogonal or perspective). - - \value CameraLens.OrthographicProjection Orthographic projection - \value CameraLens.PerspectiveProjection Perspective projection -*/ -QCameraLens::ProjectionType QCamera::projectionType() const -{ - Q_D(const QCamera); - return d->m_lens->projectionType(); -} - -void QCamera::setNearPlane(float nearPlane) -{ - Q_D(QCamera); - d->m_lens->setNearPlane(nearPlane); -} - -/*! - \qmlproperty float Qt3DCore::Camera::nearPlane -*/ -float QCamera::nearPlane() const -{ - Q_D(const QCamera); - return d->m_lens->nearPlane(); -} - -void QCamera::setFarPlane(float farPlane) -{ - Q_D(QCamera); - d->m_lens->setFarPlane(farPlane); -} - -/*! - \qmlproperty float Qt3DCore::Camera::farPlane -*/ -float QCamera::farPlane() const -{ - Q_D(const QCamera); - return d->m_lens->farPlane(); -} - -void QCamera::setFieldOfView(float fieldOfView) -{ - Q_D(QCamera); - d->m_lens->setFieldOfView(fieldOfView); -} - -/*! - \qmlproperty float Qt3DCore::Camera::fieldOfView -*/ -float QCamera::fieldOfView() const -{ - Q_D(const QCamera); - return d->m_lens->fieldOfView(); -} - -void QCamera::setAspectRatio(float aspectRatio) -{ - Q_D(QCamera); - d->m_lens->setAspectRatio(aspectRatio); -} - -/*! - \qmlproperty float Qt3DCore::Camera::aspectRatio -*/ -float QCamera::aspectRatio() const -{ - Q_D(const QCamera); - return d->m_lens->aspectRatio(); -} - -void QCamera::setLeft(float left) -{ - Q_D(QCamera); - d->m_lens->setLeft(left); -} - -/*! - \qmlproperty float Qt3DCore::Camera::left -*/ -float QCamera::left() const -{ - Q_D(const QCamera); - return d->m_lens->left(); -} - -void QCamera::setRight(float right) -{ - Q_D(QCamera); - d->m_lens->setRight(right); -} - -/*! - \qmlproperty float Qt3DCore::Camera::right -*/ -float QCamera::right() const -{ - Q_D(const QCamera); - return d->m_lens->right(); -} - -void QCamera::setBottom(float bottom) -{ - Q_D(QCamera); - d->m_lens->setBottom(bottom); -} - -/*! - \qmlproperty float Qt3DCore::Camera::bottom -*/ -float QCamera::bottom() const -{ - Q_D(const QCamera); - return d->m_lens->bottom(); -} - -void QCamera::setTop(float top) -{ - Q_D(QCamera); - d->m_lens->setTop(top); -} - -/*! - \qmlproperty float Qt3DCore::Camera::top -*/ -float QCamera::top() const -{ - Q_D(const QCamera); - return d->m_lens->top(); -} - -/*! - \qmlproperty matrix4x4 Qt3DCore::Camera::projectionMatrix - \readonly -*/ -QMatrix4x4 QCamera::projectionMatrix() const -{ - Q_D(const QCamera); - return d->m_lens->projectionMatrix(); -} - -void QCamera::setPosition(const QVector3D &position) -{ - Q_D(QCamera); - d->m_position = position; - d->m_cameraToCenter = d->m_viewCenter - position; - d->m_viewMatrixDirty = true; - emit positionChanged(position); - emit viewVectorChanged(d->m_cameraToCenter); - d->updateViewMatrix(); -} - -/*! - \qmlproperty vector3d Qt3DCore::Camera::position -*/ -QVector3D QCamera::position() const -{ - Q_D(const QCamera); - return d->m_position; -} - -void QCamera::setUpVector(const QVector3D &upVector) -{ - Q_D(QCamera); - d->m_upVector = upVector; - d->m_viewMatrixDirty = true; - emit upVectorChanged(upVector); - d->updateViewMatrix(); -} - -/*! - \qmlproperty vector3d Qt3DCore::Camera::upVector -*/ -QVector3D QCamera::upVector() const -{ - Q_D(const QCamera); - return d->m_upVector; -} - -void QCamera::setViewCenter(const QVector3D &viewCenter) -{ - Q_D(QCamera); - d->m_viewCenter = viewCenter; - d->m_cameraToCenter = viewCenter - d->m_position; - d->m_viewMatrixDirty = true; - emit viewCenterChanged(viewCenter); - emit viewVectorChanged(d->m_cameraToCenter); - d->updateViewMatrix(); -} - -/*! - \qmlproperty vector3d Qt3DCore::Camera::viewCenter -*/ -QVector3D QCamera::viewCenter() const -{ - Q_D(const QCamera); - return d->m_viewCenter; -} - -/*! - \qmlproperty vector3d Qt3DCore::Camera::viewVector -*/ -QVector3D QCamera::viewVector() const -{ - Q_D(const QCamera); - return d->m_cameraToCenter; -} - -/*! - \qmlproperty matrix4x4 Qt3DCore::Camera::viewMatrix -*/ -QMatrix4x4 QCamera::viewMatrix() const -{ - Q_D(const QCamera); - return d->m_transform->matrix(); -} - -} // Qt3D - -QT_END_NAMESPACE diff --git a/src/core/core-components/qcamera.h b/src/core/core-components/qcamera.h deleted file mode 100644 index f09281c50..000000000 --- a/src/core/core-components/qcamera.h +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QT3DCORE_CAMERA_H -#define QT3DCORE_CAMERA_H - -#include <Qt3DCore/qentity.h> -#include <Qt3DCore/qcameralens.h> -#include <QMatrix4x4> -#include <QQuaternion> -#include <QVector3D> - -QT_BEGIN_NAMESPACE - -namespace Qt3DCore { - -class QLookAtTransform; -class QTransform; - -class QCameraPrivate; -class QT3DCORESHARED_EXPORT QCamera : public QEntity -{ - Q_OBJECT - // CameraLens - Q_PROPERTY(Qt3DCore::QCameraLens::ProjectionType projectionType READ projectionType WRITE setProjectionType NOTIFY projectionTypeChanged) - Q_PROPERTY(float nearPlane READ nearPlane WRITE setNearPlane NOTIFY nearPlaneChanged) - Q_PROPERTY(float farPlane READ farPlane WRITE setFarPlane NOTIFY farPlaneChanged) - Q_PROPERTY(float fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY fieldOfViewChanged) - Q_PROPERTY(float aspectRatio READ aspectRatio WRITE setAspectRatio NOTIFY aspectRatioChanged) - Q_PROPERTY(float left READ left WRITE setLeft NOTIFY leftChanged) - Q_PROPERTY(float right READ right WRITE setRight NOTIFY rightChanged) - Q_PROPERTY(float bottom READ bottom WRITE setBottom NOTIFY bottomChanged) - Q_PROPERTY(float top READ top WRITE setTop NOTIFY topChanged) - Q_PROPERTY(QMatrix4x4 projectionMatrix READ projectionMatrix NOTIFY projectionMatrixChanged) - // LookAt - Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(QVector3D upVector READ upVector WRITE setUpVector NOTIFY upVectorChanged) - Q_PROPERTY(QVector3D viewCenter READ viewCenter WRITE setViewCenter NOTIFY viewCenterChanged) - Q_PROPERTY(QVector3D viewVector READ viewVector NOTIFY viewVectorChanged) - Q_PROPERTY(QMatrix4x4 viewMatrix READ viewMatrix NOTIFY viewMatrixChanged) - -public: - explicit QCamera(QNode *parent = 0); - ~QCamera(); - - enum CameraTranslationOption { - TranslateViewCenter, - DontTranslateViewCenter - }; - Q_ENUM(CameraTranslationOption) - - QCameraLens *lens() const; - QTransform *transform() const; - - QQuaternion tiltRotation(float angle) const; - QQuaternion panRotation(float angle) const; - QQuaternion rollRotation(float angle) const; - QQuaternion rotation(float angle, const QVector3D &axis) const; - - // Translate relative to camera orientation axes - Q_INVOKABLE void translate(const QVector3D& vLocal, CameraTranslationOption option = TranslateViewCenter); - - // Translate relative to world axes - Q_INVOKABLE void translateWorld(const QVector3D& vWorld, CameraTranslationOption option = TranslateViewCenter); - - Q_INVOKABLE void tilt(float angle); - Q_INVOKABLE void pan(float angle); - Q_INVOKABLE void pan(float angle, const QVector3D &axis); - Q_INVOKABLE void roll(float angle); - - Q_INVOKABLE void tiltAboutViewCenter(float angle); - Q_INVOKABLE void panAboutViewCenter(float angle); - Q_INVOKABLE void panAboutViewCenter(float angle, const QVector3D &axis); - Q_INVOKABLE void rollAboutViewCenter(float angle); - - Q_INVOKABLE void rotate(const QQuaternion& q); - Q_INVOKABLE void rotateAboutViewCenter(const QQuaternion& q); - - QCameraLens::ProjectionType projectionType() const; - float nearPlane() const; - float farPlane() const; - float fieldOfView() const; - float aspectRatio() const; - float left() const; - float right() const; - float bottom() const; - float top() const; - QMatrix4x4 projectionMatrix() const; - QVector3D position() const; - QVector3D upVector() const; - QVector3D viewCenter() const; - QVector3D viewVector() const; - QMatrix4x4 viewMatrix() const; - -public Q_SLOTS: - void setProjectionType(QCameraLens::ProjectionType type); - void setNearPlane(float nearPlane); - void setFarPlane(float farPlane); - void setFieldOfView(float fieldOfView); - void setAspectRatio(float aspectRatio); - void setLeft(float left); - void setRight(float right); - void setBottom(float bottom); - void setTop(float top); - void setPosition(const QVector3D &position); - void setUpVector(const QVector3D &upVector); - void setViewCenter(const QVector3D &viewCenter); - -Q_SIGNALS: - void projectionTypeChanged(QCameraLens::ProjectionType projectionType); - void nearPlaneChanged(float nearPlane); - void farPlaneChanged(float farPlane); - void fieldOfViewChanged(float fieldOfView); - void aspectRatioChanged(float aspectRatio); - void leftChanged(float left); - void rightChanged(float right); - void bottomChanged(float bottom); - void topChanged(float top); - void projectionMatrixChanged(const QMatrix4x4 &projectionMatrix); - void positionChanged(const QVector3D &position); - void upVectorChanged(const QVector3D &upVector); - void viewCenterChanged(const QVector3D &viewCenter); - void viewVectorChanged(const QVector3D &viewVector); - void viewMatrixChanged(const QMatrix4x4 &viewMatrix); - -protected: - Q_DECLARE_PRIVATE(QCamera) - QT3D_CLONEABLE(QCamera) - QCamera(QCameraPrivate &dd, QNode *parent = 0); -}; - -} // namespace Qt3DCore - -QT_END_NAMESPACE - -#endif // QT3DCORE_CAMERA_H diff --git a/src/core/core-components/qcamera_p.h b/src/core/core-components/qcamera_p.h deleted file mode 100644 index c64b4a5ab..000000000 --- a/src/core/core-components/qcamera_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QT3DCORE_CAMERA_P_H -#define QT3DCORE_CAMERA_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/qcameralens.h> -#include <Qt3DCore/qtransform.h> -#include <private/qentity_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DCore { - -class QCameraPrivate : public QEntityPrivate -{ -public: - QCameraPrivate(); - - Q_DECLARE_PUBLIC(QCamera) - - void updateViewMatrix() - { - QMatrix4x4 m; - m.lookAt(m_position, m_viewCenter, m_upVector); - m_transform->setMatrix(m); - } - - QVector3D m_position; - QVector3D m_viewCenter; - QVector3D m_upVector; - - QVector3D m_cameraToCenter; // The vector from the camera position to the view center - bool m_viewMatrixDirty; - - // Components - QCameraLens *m_lens; - QTransform *m_transform; -}; - -} // namespace Qt3DCore - -QT_END_NAMESPACE - -#endif // QT3DCORE_CAMERA_P_H diff --git a/src/core/core-components/qcameralens.cpp b/src/core/core-components/qcameralens.cpp deleted file mode 100644 index d544d8767..000000000 --- a/src/core/core-components/qcameralens.cpp +++ /dev/null @@ -1,476 +0,0 @@ -/**************************************************************************** -** -** 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 "qcameralens.h" -#include "qcameralens_p.h" - -QT_BEGIN_NAMESPACE - -namespace Qt3DCore { - -/*! - \class Qt3DCore::QCameraLensPrivate - \internal -*/ -QCameraLensPrivate::QCameraLensPrivate() - : QComponentPrivate() - , m_projectionType(QCameraLens::OrthographicProjection) - , m_nearPlane(0.1f) - , m_farPlane(1024.0f) - , m_fieldOfView(25.0f) - , m_aspectRatio(1.0f) - , m_left(-0.5f) - , m_right(0.5f) - , m_bottom(-0.5f) - , m_top(0.5f) -{ -} - -QCameraLens::QCameraLens(QNode *parent) - : QComponent(*new QCameraLensPrivate, parent) -{ - Q_D(QCameraLens); - d->updateProjectionMatrix(); -} - -QCameraLens::~QCameraLens() -{ - QNode::cleanup(); -} - -void QCameraLens::copy(const QNode *ref) -{ - QComponent::copy(ref); - const QCameraLens *lens = static_cast<const QCameraLens*>(ref); - d_func()->m_projectionType = lens->d_func()->m_projectionType; - d_func()->m_nearPlane = lens->d_func()->m_nearPlane; - d_func()->m_farPlane = lens->d_func()->m_farPlane; - d_func()->m_fieldOfView = lens->d_func()->m_fieldOfView; - d_func()->m_aspectRatio = lens->d_func()->m_aspectRatio; - d_func()->m_left = lens->d_func()->m_left; - d_func()->m_right = lens->d_func()->m_right; - d_func()->m_bottom = lens->d_func()->m_bottom; - d_func()->m_top = lens->d_func()->m_top; - d_func()->m_projectionMatrix = lens->d_func()->m_projectionMatrix; -} - -/*! \class Qt3DCore::QCameraLens - * \inmodule Qt3DCore - * - * \brief Qt3DCore::QCameraLens specifies the projection matrix that will be used to - * define a Camera for a 3D scene. - * - * \since 5.5 - */ -QCameraLens::QCameraLens(QCameraLensPrivate &dd, QNode *parent) - : QComponent(dd, parent) -{ - Q_D(QCameraLens); - d->updateOrthographicProjection(); -} - -/*! - * Sets the lens' projection type \a projectionType. - * - * \note Qt3DCore::QCameraLens::Frustum and - * Qt3DCore::QCameraLens::PerspectiveProjection are two different ways of - * specifying the same projection. - */ -void QCameraLens::setProjectionType(QCameraLens::ProjectionType projectionType) -{ - Q_D(QCameraLens); - if (d->m_projectionType != projectionType) { - d->m_projectionType = projectionType; - emit projectionTypeChanged(projectionType); - d->updateProjectionMatrix(); - } -} - -/*! - * Returns the lens' projection type. - */ -QCameraLens::ProjectionType QCameraLens::projectionType() const -{ - Q_D(const QCameraLens); - return d->m_projectionType; -} - -/*! - * Defines an orthographic projection based on \a left, \a right, \a bottom, \a - * top, \a nearPlane, \a farPlane. - */ -void QCameraLens::setOrthographicProjection(float left, float right, - float bottom, float top, - float nearPlane, float farPlane) -{ - Q_D(QCameraLens); - bool block = blockNotifications(true); - setLeft(left); - setRight(right); - setBottom(bottom); - setTop(top); - setNearPlane(nearPlane); - setFarPlane(farPlane); - setProjectionType(OrthographicProjection); - blockNotifications(block); - d->updateProjectionMatrix(); -} - -/*! - * Defines an orthographic projection based on \a left, \a right, \a bottom, \a - * top, \a nearPlane, \a farPlane. - */ -void QCameraLens::setFrustumProjection(float left, float right, - float bottom, float top, - float nearPlane, float farPlane) -{ - Q_D(QCameraLens); - bool block = blockNotifications(true); - setLeft(left); - setRight(right); - setBottom(bottom); - setTop(top); - setNearPlane(nearPlane); - setFarPlane(farPlane); - setProjectionType(FrustumProjection); - blockNotifications(block); - d->updateProjectionMatrix(); -} - -/*! - * Defines a perspective projection based on \a fieldOfView, \a aspectRatio, \a - * nearPlane, \a farPlane. - */ -void QCameraLens::setPerspectiveProjection(float fieldOfView, float aspectRatio, - float nearPlane, float farPlane) -{ - Q_D(QCameraLens); - bool block = blockNotifications(true); - setFieldOfView(fieldOfView); - setAspectRatio(aspectRatio); - setNearPlane(nearPlane); - setFarPlane(farPlane); - setProjectionType(PerspectiveProjection); - blockNotifications(block); - d->updateProjectionMatrix(); -} - -/*! - * Sets the projection's near plane to \a nearPlane. This triggers a projection - * matrix update. - */ -void QCameraLens::setNearPlane(float nearPlane) -{ - Q_D(QCameraLens); - if (qFuzzyCompare(d->m_nearPlane, nearPlane)) - return; - d->m_nearPlane = nearPlane; - emit nearPlaneChanged(nearPlane); - d->updateProjectionMatrix(); -} - -/*! - * Returns the projection's near plane. - */ -float QCameraLens::nearPlane() const -{ - Q_D(const QCameraLens); - return d->m_nearPlane; -} - -/*! - * Sets the projection's far plane to \a farPlane. This triggers a projection - * matrix update. - */ -void QCameraLens::setFarPlane(float farPlane) -{ - Q_D(QCameraLens); - if (qFuzzyCompare(d->m_farPlane, farPlane)) - return; - d->m_farPlane = farPlane; - emit farPlaneChanged(farPlane); - d->updateProjectionMatrix(); -} - -/*! - * Returns the projection's far plane. - */ -float QCameraLens::farPlane() const -{ - Q_D(const QCameraLens); - return d->m_farPlane; -} - -/*! - * Sets the projection's field of view to \a fieldOfView degrees. This triggers - * a projection matrix update. - * - * \note this has no effect if the projection type is not - * Qt3DCore::QCameraLens::PerspectiveProjection. - */ -void QCameraLens::setFieldOfView(float fieldOfView) -{ - Q_D(QCameraLens); - if (qFuzzyCompare(d->m_fieldOfView, fieldOfView)) - return; - d->m_fieldOfView = fieldOfView; - emit fieldOfViewChanged(fieldOfView); - d->updateProjectionMatrix(); -} - -/*! - * Returns the projection's field of view in degrees. - * - * \note: The return value may be undefined if the projection type is not - * Qt3DCore::QCameraLens::PerspectiveProjection. - */ -float QCameraLens::fieldOfView() const -{ - Q_D(const QCameraLens); - return d->m_fieldOfView; -} - -/*! - * Sets the projection's aspect ratio to \a aspectRatio. This triggers a projection - * matrix update. - * - * \note this has no effect if the projection type is not - * Qt3DCore::QCameraLens::PerspectiveProjection. - */ -void QCameraLens::setAspectRatio(float aspectRatio) -{ - Q_D(QCameraLens); - if (qFuzzyCompare(d->m_aspectRatio, aspectRatio)) - return; - d->m_aspectRatio = aspectRatio; - emit aspectRatioChanged(aspectRatio); - d->updateProjectionMatrix(); -} - -/*! - * Returns the projection's aspect ratio. - * - * \note: The return value may be undefined if the projection type is not - * Qt3DCore::QCameraLens::PerspectiveProjection. - */ -float QCameraLens::aspectRatio() const -{ - Q_D(const QCameraLens); - return d->m_aspectRatio; -} - -/*! - * Sets the projection's lower left window coordinate to \a left. This - * triggers a projection matrix update. - * - * \note this has no effect if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. - */ -void QCameraLens::setLeft(float left) -{ - Q_D(QCameraLens); - if (qFuzzyCompare(d->m_left, left)) - return; - d->m_left = left; - emit leftChanged(left); - d->updateProjectionMatrix(); -} - -/*! - * Returns the lower left window coordinate of the projection. - * - * \note The return value may be undefined if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. - */ -float QCameraLens::left() const -{ - Q_D(const QCameraLens); - return d->m_left; -} - -/*! - * Sets the projection's upper right window coordinate to \a right. This triggers - * a projection matrix update. - * - * \note this has no effect if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. - */ -void QCameraLens::setRight(float right) -{ - Q_D(QCameraLens); - if (qFuzzyCompare(d->m_right, right)) - return; - d->m_right = right; - emit rightChanged(right); - d->updateProjectionMatrix(); -} - -/*! - * Returns the upper right window coordinate of the projection. - * - * \note The return value may be undefined if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. - */ -float QCameraLens::right() const -{ - Q_D(const QCameraLens); - return d->m_right; -} - -/*! - * Sets the projection's bottom window coordinate to \a bottom. This triggers a - * projection matrix update. - * - * \note this has no effect if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. - */ -void QCameraLens::setBottom(float bottom) -{ - Q_D(QCameraLens); - if (qFuzzyCompare(d->m_bottom, bottom)) - return; - d->m_bottom = bottom; - emit bottomChanged(bottom); - d->updateProjectionMatrix(); -} - -/*! - * Returns the bottom window coordinate of the projection. - * - * \note The return value may be undefined if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. - */ -float QCameraLens::bottom() const -{ - Q_D(const QCameraLens); - return d->m_bottom; -} - -/*! - * Sets the projection's top window coordinate to \a top. This triggers a - * projection matrix update. - * - * \note this has no effect if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. - */ -void QCameraLens::setTop(float top) -{ - Q_D(QCameraLens); - if (qFuzzyCompare(d->m_top, top)) - return; - d->m_top = top; - emit topChanged(top); - d->updateProjectionMatrix(); -} - -/*! - * Returns the bottom window coordinate of the projection. - * - * \note The return value may be undefined if the projection type is - * Qt3DCore::QCameraLens::PerspectiveProjection. - */ -float QCameraLens::top() const -{ - Q_D(const QCameraLens); - return d->m_top; -} - -/*! - * Returns the projection matrix. - */ -QMatrix4x4 QCameraLens::projectionMatrix() const -{ - Q_D(const QCameraLens); - return d->m_projectionMatrix; -} - -} // Qt3D - -/*! - \qmltype CameraLens - \instantiates Qt3DCore::QCameraLens - \inqmlmodule Qt3D.Core - \inherits Component3D - \since 5.5 -*/ - -/*! - \qmlproperty enumeration Qt3DCore::CameraLens::projectionType - - Holds the type of the camera projection (orthogonal or perspective). - - \value CameraLens.OrthographicProjection Orthogonal projection - \value CameraLens.PerspectiveProjection Perspective projection -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::nearPlane -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::farPlane -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::fieldOfView -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::aspectRatio -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::left -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::right -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::bottom -*/ - -/*! - \qmlproperty float Qt3DCore::CameraLens::top -*/ - -/*! - \qmlproperty matrix4x4 Qt3DCore::CameraLens::projectionMatrix - \readonly -*/ - -QT_END_NAMESPACE diff --git a/src/core/core-components/qcameralens.h b/src/core/core-components/qcameralens.h deleted file mode 100644 index 120148e29..000000000 --- a/src/core/core-components/qcameralens.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QT3DCORE_CAMERALENS_H -#define QT3DCORE_CAMERALENS_H - -#include <Qt3DCore/qcomponent.h> -#include <Qt3DCore/qt3dcore_global.h> - -#include <QMatrix4x4> -#include <QQuaternion> -#include <QVector3D> - -QT_BEGIN_NAMESPACE - -namespace Qt3DCore { - -class QCameraLensPrivate; - -class QT3DCORESHARED_EXPORT QCameraLens : public QComponent -{ - Q_OBJECT - Q_PROPERTY(ProjectionType projectionType READ projectionType WRITE setProjectionType NOTIFY projectionTypeChanged) - Q_PROPERTY(float nearPlane READ nearPlane WRITE setNearPlane NOTIFY nearPlaneChanged) - Q_PROPERTY(float farPlane READ farPlane WRITE setFarPlane NOTIFY farPlaneChanged) - Q_PROPERTY(float fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY fieldOfViewChanged) - Q_PROPERTY(float aspectRatio READ aspectRatio WRITE setAspectRatio NOTIFY aspectRatioChanged) - Q_PROPERTY(float left READ left WRITE setLeft NOTIFY leftChanged) - Q_PROPERTY(float right READ right WRITE setRight NOTIFY rightChanged) - Q_PROPERTY(float bottom READ bottom WRITE setBottom NOTIFY bottomChanged) - Q_PROPERTY(float top READ top WRITE setTop NOTIFY topChanged) - Q_PROPERTY(QMatrix4x4 projectionMatrix READ projectionMatrix NOTIFY projectionMatrixChanged) - -public: - explicit QCameraLens(QNode *parent = 0); - ~QCameraLens(); - - enum ProjectionType { - OrthographicProjection, - PerspectiveProjection, - FrustumProjection - }; - Q_ENUM(ProjectionType) - - ProjectionType projectionType() const; - float nearPlane() const; - float farPlane() const; - float fieldOfView() const; - float aspectRatio() const; - float left() const; - float right() const; - float bottom() const; - float top() const; - - QMatrix4x4 projectionMatrix() const; - - void setOrthographicProjection(float left, float right, - float bottom, float top, - float nearPlane, float farPlane); - - void setFrustumProjection(float left, float right, - float bottom, float top, - float nearPlane, float farPlane); - - void setPerspectiveProjection(float fieldOfView, float aspect, - float nearPlane, float farPlane); - -public Q_SLOTS: - void setProjectionType(ProjectionType projectionType); - void setNearPlane(float nearPlane); - void setFarPlane(float farPlane); - void setFieldOfView(float fieldOfView); - void setAspectRatio(float aspectRatio); - void setLeft(float left); - void setRight(float right); - void setBottom(float bottom); - void setTop(float top); - -Q_SIGNALS: - void projectionTypeChanged(QCameraLens::ProjectionType projectionType); - void nearPlaneChanged(float nearPlane); - void farPlaneChanged(float farPlane); - void fieldOfViewChanged(float fieldOfView); - void aspectRatioChanged(float aspectRatio); - void leftChanged(float left); - void rightChanged(float right); - void bottomChanged(float bottom); - void topChanged(float top); - void projectionMatrixChanged(const QMatrix4x4 &projectionMatrix); - -protected: - QCameraLens(QCameraLensPrivate &dd, QNode *parent = 0); - void copy(const QNode *ref) Q_DECL_OVERRIDE; - -private: - Q_DECLARE_PRIVATE(QCameraLens) - QT3D_CLONEABLE(QCameraLens) -}; - -} // Qt3D - -QT_END_NAMESPACE - -#endif // CAMERALENS_H diff --git a/src/core/core-components/qcameralens_p.h b/src/core/core-components/qcameralens_p.h deleted file mode 100644 index 02cc292bb..000000000 --- a/src/core/core-components/qcameralens_p.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QT3DCORE_CAMERALENS_P_H -#define QT3DCORE_CAMERALENS_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/qcomponent_p.h> -#include "qcameralens.h" - -#include <Qt3DCore/qscenepropertychange.h> - -#include <QtGui/qmatrix4x4.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DCore { - -class QCameraLensPrivate : public QComponentPrivate -{ -public: - QCameraLensPrivate(); - - inline void updateProjectionMatrix() - { - switch (m_projectionType) { - case QCameraLens::OrthographicProjection: - updateOrthographicProjection(); - break; - case QCameraLens::PerspectiveProjection: - updatePerpectiveProjection(); - break; - case QCameraLens::FrustumProjection: - updateFrustumProjection(); - break; - } - } - - Q_DECLARE_PUBLIC(QCameraLens) - - QCameraLens::ProjectionType m_projectionType; - - float m_nearPlane; - float m_farPlane; - - float m_fieldOfView; - float m_aspectRatio; - - float m_left; - float m_right; - float m_bottom; - float m_top; - - mutable QMatrix4x4 m_projectionMatrix; - -private: - inline void updatePerpectiveProjection() - { - Q_Q(QCameraLens); - m_projectionMatrix.setToIdentity(); - m_projectionMatrix.perspective(m_fieldOfView, m_aspectRatio, m_nearPlane, m_farPlane); - Q_EMIT q->projectionMatrixChanged(m_projectionMatrix); - } - - inline void updateOrthographicProjection() - { - Q_Q(QCameraLens); - m_projectionMatrix.setToIdentity(); - m_projectionMatrix.ortho(m_left, m_right, m_bottom, m_top, m_nearPlane, m_farPlane); - Q_EMIT q->projectionMatrixChanged(m_projectionMatrix); - } - - inline void updateFrustumProjection() - { - Q_Q(QCameraLens); - m_projectionMatrix.setToIdentity(); - m_projectionMatrix.frustum(m_left, m_right, m_bottom, m_top, m_nearPlane, m_farPlane); - Q_EMIT q->projectionMatrixChanged(m_projectionMatrix); - } -}; - -} // namespace Qt3DCore - -QT_END_NAMESPACE - -#endif // QT3DCORE_CAMERALENS_P_H diff --git a/src/core/core.pri b/src/core/core.pri index 45bd7a692..d257a2519 100644 --- a/src/core/core.pri +++ b/src/core/core.pri @@ -6,8 +6,6 @@ include (./aspects/aspects.pri) include (./jobs/jobs.pri) # Nodes include (./nodes/nodes.pri) -# Qml Components -include (./core-components/core-components.pri) #Transformations include (./transforms/transforms.pri) # Resources Management |