diff options
Diffstat (limited to 'src/core/core-components/qcameralens.cpp')
-rw-r--r-- | src/core/core-components/qcameralens.cpp | 153 |
1 files changed, 146 insertions, 7 deletions
diff --git a/src/core/core-components/qcameralens.cpp b/src/core/core-components/qcameralens.cpp index fde9d16ad..23449d6cb 100644 --- a/src/core/core-components/qcameralens.cpp +++ b/src/core/core-components/qcameralens.cpp @@ -59,7 +59,6 @@ QCameraLensPrivate::QCameraLensPrivate(QCameraLens *qq) { } - QCameraLens::QCameraLens(QNode *parent) : QComponent(*new QCameraLensPrivate(this), parent) { @@ -83,7 +82,13 @@ void QCameraLens::copy(const QNode *ref) d_func()->m_projectionMatrix = lens->d_func()->m_projectionMatrix; } -/*! \internal */ +/*! \class Qt3D::QCameraLens + * + * \brief Qt3D::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) { @@ -91,6 +96,13 @@ QCameraLens::QCameraLens(QCameraLensPrivate &dd, QNode *parent) d->updateOrthogonalProjection(); } +/*! + * Sets the lens' projection type \a projectionType. + * + * \note Qt3D::QCameraLens::Frustum and + * Qt3D::QCameraLens::PerspectiveProjection are two different ways of + * specifying the same projection. + */ void QCameraLens::setProjectionType(QCameraLens::ProjectionType projectionType) { Q_D(QCameraLens); @@ -101,15 +113,22 @@ void QCameraLens::setProjectionType(QCameraLens::ProjectionType projectionType) } } +/*! + * Returns the lens' projection type. + */ QCameraLens::ProjectionType QCameraLens::projectionType() const { Q_D(const QCameraLens); return d->m_projectionType; } -void QCameraLens::setOrthographicProjection( float left, float right, - float bottom, float top, - float nearPlane, float farPlane ) +/*! + * 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); @@ -124,8 +143,33 @@ void QCameraLens::setOrthographicProjection( float left, float right, d->updateProjectionMatrix(); } -void QCameraLens::setPerspectiveProjection( float fieldOfView, float aspectRatio, - float nearPlane, float farPlane ) +/*! + * 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); @@ -138,6 +182,10 @@ void QCameraLens::setPerspectiveProjection( float fieldOfView, float aspectRatio 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); @@ -148,12 +196,19 @@ void QCameraLens::setNearPlane(float 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); @@ -164,12 +219,22 @@ void QCameraLens::setFarPlane(float 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 + * Qt3D::QCameraLens::PerspectiveProjection. + */ void QCameraLens::setFieldOfView(float fieldOfView) { Q_D(QCameraLens); @@ -180,12 +245,25 @@ void QCameraLens::setFieldOfView(float 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 + * Qt3D::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 + * Qt3D::QCameraLens::PerspectiveProjection. + */ void QCameraLens::setAspectRatio(float aspectRatio) { Q_D(QCameraLens); @@ -196,12 +274,25 @@ void QCameraLens::setAspectRatio(float aspectRatio) d->updateProjectionMatrix(); } +/*! + * Returns the projection's aspect ratio. + * + * \note: The return value may be undefined if the projection type is not + * Qt3D::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 + * Qt3D::QCameraLens::PerspectiveProjection. + */ void QCameraLens::setLeft(float left) { Q_D(QCameraLens); @@ -212,12 +303,25 @@ void QCameraLens::setLeft(float left) d->updateProjectionMatrix(); } +/*! + * Returns the lower left window coordinate of the projection. + * + * \note The return value may be undefined if the projection type is + * Qt3D::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 + * Qt3D::QCameraLens::PerspectiveProjection. + */ void QCameraLens::setRight(float right) { Q_D(QCameraLens); @@ -228,12 +332,25 @@ void QCameraLens::setRight(float right) d->updateProjectionMatrix(); } +/*! + * Returns the upper right window coordinate of the projection. + * + * \note The return value may be undefined if the projection type is + * Qt3D::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 + * Qt3D::QCameraLens::PerspectiveProjection. + */ void QCameraLens::setBottom(float bottom) { Q_D(QCameraLens); @@ -244,12 +361,25 @@ void QCameraLens::setBottom(float bottom) d->updateProjectionMatrix(); } +/*! + * Returns the bottom window coordinate of the projection. + * + * \note The return value may be undefined if the projection type is + * Qt3D::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 + * Qt3D::QCameraLens::PerspectiveProjection. + */ void QCameraLens::setTop(float top) { Q_D(QCameraLens); @@ -260,12 +390,21 @@ void QCameraLens::setTop(float top) d->updateProjectionMatrix(); } +/*! + * Returns the bottom window coordinate of the projection. + * + * \note The return value may be undefined if the projection type is + * Qt3D::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); |