QCamera Class▲
-
Header: Qt3DRender/QCamera
-
Since: Qt 5.5
-
CMake:
find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
-
qmake: QT += 3drender
-
Inherited By:
-
Instantiated By: qml-qt3d-render-camera.xml
-
Inherits: Qt3DCore::QEntity
Detailed Description▲
Member Type Documentation▲
enum QCamera::CameraTranslationOption▲
This enum specifies how camera view center is translated
Constant |
Value |
Description |
---|---|---|
Qt3DRender::QCamera::TranslateViewCenter |
0 |
Translate the view center causing the view direction to remain the same |
Qt3DRender::QCamera::DontTranslateViewCenter |
1 |
Don't translate the view center causing the view direction to change |
Property Documentation▲
aspectRatio : float▲
Holds the current aspect ratio.
Access functions:
-
float aspectRatio() const
-
void setAspectRatio(float aspectRatio)
Notifier signal:
-
void aspectRatioChanged(float aspectRatio)
bottom : float▲
Holds the current bottom of the camera.
This property is only relevant when projectionType is QCameraLens::OrthographicProjection.
Access functions:
-
float bottom() const
-
void setBottom(float bottom)
Notifier signal:
-
void bottomChanged(float bottom)
exposure : float▲
Holds the current exposure of the camera.
The default value is 0.0.
The MetalRoughMaterial in Qt 3D Extras is currently the only provided material that makes use of camera exposure. Negative values will cause the material to be darker, and positive values will cause it to be lighter.
Custom materials may choose to interpret the value differently.
Access functions:
-
float exposure() const
-
void setExposure(float exposure)
Notifier signal:
-
void exposureChanged(float exposure)
farPlane : float▲
Holds the current camera far plane. Objects that are farther from the camera than the farPlane will not be rendered.
Access functions:
-
float farPlane() const
-
void setFarPlane(float farPlane)
Notifier signal:
-
void farPlaneChanged(float farPlane)
fieldOfView : float▲
Holds the current vertical field of view in degrees.
Along with aspectRatio, this property determines how much of the scene is visible to the camera. In that respect you might think of it as analogous to choosing a wide angle (wide horizontal field of view) or telephoto (narrow horizontal field of view) lens depending on how much of a scene you want to capture.
fieldOfView is only relevant when projectionType is QCameraLens::PerspectiveProjection.
Access functions:
-
float fieldOfView() const
-
void setFieldOfView(float fieldOfView)
Notifier signal:
-
void fieldOfViewChanged(float fieldOfView)
left : float▲
Holds the current left of the camera.
This property is only relevant when projectionType is QCameraLens::OrthographicProjection.
Access functions:
-
float left() const
-
void setLeft(float left)
Notifier signal:
-
void leftChanged(float left)
[read-only, since 5.14] lens : Qt3DRender::QCameraLens* const▲
Holds the Qt3DRender::QCameraLens component of the camera.
This property was introduced in Qt 5.14.
Access functions:
-
*lens() const
nearPlane : float▲
Holds the current camera near plane. Objects that are closer to the camera than the nearPlane will not be rendered.
Access functions:
-
float nearPlane() const
-
void setNearPlane(float nearPlane)
Notifier signal:
-
void nearPlaneChanged(float nearPlane)
position : QVector3D▲
Holds the camera's position in coordinates relative to the parent entity.
Access functions:
-
position() const
-
void setPosition(const &position)
Notifier signal:
-
void positionChanged(const &position)
projectionMatrix : QMatrix4x4▲
Holds the current projection matrix of the camera.
Access functions:
-
projectionMatrix() const
-
void setProjectionMatrix(const &projectionMatrix)
Notifier signal:
-
void projectionMatrixChanged(const &projectionMatrix)
projectionType : Qt3DRender::QCameraLens::ProjectionType▲
Holds the type of the camera projection. The default value is QCameraLens::PerspectiveProjection.
-
QCameraLens::OrthographicProjection - Parallel lines appear parallel. Objects appear the same size regardless of distance.
-
QCameraLens::PerspectiveProjection - Parallel lines appear to meet in the distance. Objects appear to shrink the farther they are from the camera.
Access functions:
-
projectionType() const
-
void setProjectionType( type)
Notifier signal:
-
void projectionTypeChanged( projectionType)
See Also▲
right : float▲
Holds the current right of the camera.
This property is only relevant when projectionType is QCameraLens::OrthographicProjection.
Access functions:
-
float right() const
-
void setRight(float right)
Notifier signal:
-
void rightChanged(float right)
top : float▲
Holds the current top of the camera.
This property is only relevant when projectionType is QCameraLens::OrthographicProjection.
Access functions:
-
float top() const
-
void setTop(float top)
Notifier signal:
-
void topChanged(float top)
[read-only, since 5.14] transform : Qt3DCore::QTransform* const▲
Holds the Qt3DCore::QTransform component of the camera.
This property was introduced in Qt 5.14.
Access functions:
-
*transform() const
upVector : QVector3D▲
Holds the camera's up vector in coordinates relative to the parent entity.
The up vector indicates which direction the top of the camera is facing. Think of taking a picture: after positioning yourself and pointing the camera at your target, you might rotate the camera left or right, giving you a portrait or landscape (or angled!) shot. upVector allows you to control this type of movement.
Access functions:
-
upVector() const
-
void setUpVector(const &upVector)
Notifier signal:
-
void upVectorChanged(const &upVector)
viewCenter : QVector3D▲
Holds the camera's view center in coordinates relative to the parent entity.
Intuitively, the viewCenter is the location the camera is pointing at.
Access functions:
-
viewCenter() const
-
void setViewCenter(const &viewCenter)
Notifier signal:
-
void viewCenterChanged(const &viewCenter)
[read-only] viewVector : const QVector3D▲
Holds the camera's view vector in coordinates relative to the parent entity.
This vector decribes the displacement from the camera (position) to its target (viewCenter).
Access functions:
-
viewVector() const
Notifier signal:
-
void viewVectorChanged(const &viewVector)
Member Function Documentation▲
[explicit] QCamera::QCamera(Qt3DCore::QNode *parent = nullptr)▲
Creates a new QCamera instance with the specified parent.
Qt3DRender::QCameraLens *QCamera::lens() const▲
Returns the current lens.
Getter function for property lens.
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.
Setter function for property aspectRatio.
See Also▲
See also aspectRatio()
void QCamera::setBottom(float bottom)▲
Sets the bottom of the camera to bottom.
Setter function for property bottom.
See Also▲
See also bottom()
void QCamera::setExposure(float exposure)▲
Sets the camera's exposure to exposure.
Setter function for property exposure.
See Also▲
See also exposure()
void QCamera::setFarPlane(float farPlane)▲
Sets the camera's far plane to farPlane
Setter function for property farPlane.
See Also▲
See also farPlane()
void QCamera::setFieldOfView(float fieldOfView)▲
Sets the camera's field of view to fieldOfView in degrees.
Setter function for property fieldOfView.
See Also▲
See also fieldOfView()
void QCamera::setLeft(float left)▲
void QCamera::setNearPlane(float nearPlane)▲
Sets the camera's near plane to nearPlane.
Setter function for property nearPlane.
See Also▲
See also nearPlane()
void QCamera::setPosition(const QVector3D &position)▲
Sets the camera's position in 3D space to position.
Setter function for property position.
See Also▲
See also position()
void QCamera::setProjectionMatrix(const QMatrix4x4 &projectionMatrix)▲
Sets the camera's projection matrix to projectionMatrix.
Setter function for property projectionMatrix.
See Also▲
See also projectionMatrix()
void QCamera::setProjectionType(QCameraLens::ProjectionType type)▲
Sets the camera's projection type to type.
Setter function for property projectionType.
See Also▲
See also projectionType()
void QCamera::setRight(float right)▲
Sets the right of the camera to right.
Setter function for property right.
See Also▲
See also right()
void QCamera::setTop(float top)▲
void QCamera::setUpVector(const QVector3D &upVector)▲
Sets the camera's up vector to upVector.
Setter function for property upVector.
See Also▲
See also upVector()
void QCamera::setViewCenter(const QVector3D &viewCenter)▲
Sets the camera's view center to viewCenter.
Setter function for property viewCenter.
See Also▲
See also 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.
Getter function for property 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.
Only works if the lens is in perspective or orthographic projection mode.
See Also▲
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.
Only works if the lens is in perspective or orthographic projection mode.
See Also▲
See also Camera.projectionType
void QCamera::viewSphere(const QVector3D ¢er, float radius)▲
Rotates and moves the camera so that it's viewCenter is center and a sphere of radius fits in the view port.
Only works if the lens is in perspective or orthographic projection mode.
See Also▲
See also Qt3D.Render::Camera::projectionType
Obsolete Members for QCamera▲
The following members of class QCamera are deprecated. We strongly advise against using them in new code.
Obsolete Property Documentation▲
[read-only] viewMatrix : const QMatrix4x4▲
This property is deprecated. We strongly advise against using it in new code.
Holds the camera's view matrix in coordinates relative to the parent entity.
Access functions:
-
viewMatrix() const
Notifier signal:
-
void viewMatrixChanged()