QCamera Class

class Qt3DRender::QCamera

The QCamera class defines a view point through which the scene will be rendered. More...

Header: #include <Qt3DRender/QCamera>
qmake: QT += 3drender
Since: Qt 5.5
Instantiated By: Camera
Inherits: Qt3DCore::QEntity

This class was introduced in Qt 5.5.

Public Types

enum CameraTranslationOption { TranslateViewCenter, DontTranslateViewCenter }

Public Functions

QCamera(Qt3DCore::QNode *parent = nullptr)
void pan(float angle)
void pan(float angle, const QVector3D &axis)
void panAboutViewCenter(float angle)
void panAboutViewCenter(float angle, const QVector3D &axis)
QQuaternion panRotation(float angle) const
void roll(float angle)
void rollAboutViewCenter(float angle)
QQuaternion rollRotation(float angle) const
void rotate(const QQuaternion &q)
void rotateAboutViewCenter(const QQuaternion &q)
QQuaternion rotation(float angle, const QVector3D &axis) const
void setAspectRatio(float aspectRatio)
void setBottom(float bottom)
void setExposure(float exposure)
void setFarPlane(float farPlane)
void setFieldOfView(float fieldOfView)
void setLeft(float left)
void setNearPlane(float nearPlane)
void setPosition(const QVector3D &position)
void setProjectionMatrix(const QMatrix4x4 &projectionMatrix)
void setProjectionType(QCameraLens::ProjectionType type)
void setRight(float right)
void setTop(float top)
void setUpVector(const QVector3D &upVector)
void setViewCenter(const QVector3D &viewCenter)
void tilt(float angle)
void tiltAboutViewCenter(float angle)
QQuaternion tiltRotation(float angle) const
Qt3DCore::QTransform *transform() const
void translate(const QVector3D &vLocal, Qt3DRender::QCamera::CameraTranslationOption option = TranslateViewCenter)
void translateWorld(const QVector3D &vWorld, Qt3DRender::QCamera::CameraTranslationOption option = TranslateViewCenter)
void viewAll()
void viewEntity(Qt3DCore::QEntity *entity)
void viewSphere(const QVector3D &center, float radius)

Detailed Description

Member Type Documentation

enum QCamera::CameraTranslationOption

This enum specifies how camera view center is translated

ConstantValueDescription
Qt3DRender::QCamera::TranslateViewCenter0Translate the view center causing the view direction to remain the same
Qt3DRender::QCamera::DontTranslateViewCenter1Don't translate the view center causing the view direction to change

Member Function Documentation

QCamera::QCamera(Qt3DCore::QNode *parent = nullptr)

Creates a new QCamera instance with the specified parent.

void QCamera::pan(float angle)

Adjusts the pan angle of the camera by angle in degrees.

void QCamera::pan(float angle, const QVector3D &axis)

Adjusts the pan angle of the camera by angle in degrees on a chosen axis.

void QCamera::panAboutViewCenter(float angle)

Adjusts the camera pan about view center by angle in degrees.

void QCamera::panAboutViewCenter(float angle, const QVector3D &axis)

Adjusts the camera pan about view center by angle in degrees on axis.

QQuaternion QCamera::panRotation(float angle) const

Returns the calculated pan rotation in relation to the angle in degrees taken in to adjust the camera's pan or left/right rotation on the Y axis.

void QCamera::roll(float angle)

Adjusts the camera roll by angle in degrees.

void QCamera::rollAboutViewCenter(float angle)

Adjusts the camera roll about view center by angle in degrees.

QQuaternion QCamera::rollRotation(float angle) const

Returns the calculated roll rotation in relation to the angle in degrees taken in to adjust the camera's roll or lean left/right rotation on the Z axis.

void QCamera::rotate(const QQuaternion &q)

Rotates the camera with the use of a Quaternion in q.

void QCamera::rotateAboutViewCenter(const QQuaternion &q)

Rotates the camera about the view center with the use of a Quaternion in q.

QQuaternion QCamera::rotation(float angle, const QVector3D &axis) const

Returns the calculated rotation in relation to the angle in degrees and chosen axis taken in.

void QCamera::setAspectRatio(float aspectRatio)

Sets the camera's aspect ratio to aspectRatio.

void QCamera::setBottom(float bottom)

Sets the bottom of the camera to bottom.

void QCamera::setExposure(float exposure)

Sets the camera's exposure to exposure.

void QCamera::setFarPlane(float farPlane)

Sets the camera's far plane to farPlane

void QCamera::setFieldOfView(float fieldOfView)

Sets the camera's field of view to fieldOfView in degrees.

void QCamera::setLeft(float left)

Sets the left of the camera to left.

void QCamera::setNearPlane(float nearPlane)

Sets the camera's near plane to nearPlane.

void QCamera::setPosition(const QVector3D &position)

Sets the camera's position in 3D space to position.

void QCamera::setProjectionMatrix(const QMatrix4x4 &projectionMatrix)

Sets the camera's projection matrix to projectionMatrix.

void QCamera::setProjectionType(QCameraLens::ProjectionType type)

Sets the camera's projection type to type.

void QCamera::setRight(float right)

Sets the right of the camera to right.

void QCamera::setTop(float top)

Sets the top of the camera to top.

void QCamera::setUpVector(const QVector3D &upVector)

Sets the camera's up vector to upVector.

void QCamera::setViewCenter(const QVector3D &viewCenter)

Sets the camera's view center to viewCenter.

void QCamera::tilt(float angle)

Adjusts the tilt angle of the camera by angle in degrees.

void QCamera::tiltAboutViewCenter(float angle)

Adjusts the camera tilt about view center by angle in degrees.

QQuaternion QCamera::tiltRotation(float angle) const

Returns the calculated tilt rotation in relation to the angle in degrees taken in to adjust the camera's tilt or up/down rotation on the X axis.

Qt3DCore::QTransform *QCamera::transform() const

Returns the camera's position via transform.

void QCamera::translate(const QVector3D &vLocal, Qt3DRender::QCamera::CameraTranslationOption option = TranslateViewCenter)

Translates the camera's position and its view vector by vLocal in local coordinates. The option allows for toggling whether the view center should be translated.

void QCamera::translateWorld(const QVector3D &vWorld, Qt3DRender::QCamera::CameraTranslationOption option = TranslateViewCenter)

Translates the camera's position and its view vector by vWorld in world coordinates. The option allows for toggling whether the view center should be translated.

void QCamera::viewAll()

Rotates and moves the camera so that it's viewCenter is the center of the scene's bounding volume and the entire scene fits in the view port.

Note: Only works if the lens is in perspective or orthographic projection mode.

See also Qt3D.Render::Camera::projectionType.

void QCamera::viewEntity(Qt3DCore::QEntity *entity)

Rotates and moves the camera so that it's viewCenter is the center of the entity's bounding volume and the entire entity fits in the view port.

Note: Only works if the lens is in perspective or orthographic projection mode.

See also Camera.projectionType.

void QCamera::viewSphere(const QVector3D &center, float radius)

Rotates and moves the camera so that it's viewCenter is center and a sphere of radius fits in the view port.

Note: Only works if the lens is in perspective or orthographic projection mode.

See also Qt3D.Render::Camera::projectionType.