Qt3DRender::QCameraLens Class

class Qt3DRender::QCameraLens

Qt3DRender::QCameraLens 指定用于为 3D 场景定义相机的投影矩阵。更多

头文件: #include <Qt3DRender/QCameraLens>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
在 QML 中: CameraLens
继承: Qt3DCore::QComponent
状态:已废弃

公共类型

enum ProjectionType { OrthographicProjection, PerspectiveProjection, FrustumProjection, CustomProjection }

属性

公共功能

QCameraLens(Qt3DCore::QNode *parent = nullptr)
float aspectRatio() const
float bottom() const
float exposure() const
float farPlane() const
float fieldOfView() const
float left() const
float nearPlane() const
QMatrix4x4 projectionMatrix() const
Qt3DRender::QCameraLens::ProjectionType projectionType() const
float right() const
void setFrustumProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane)
void setOrthographicProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane)
void setPerspectiveProjection(float fieldOfView, float aspectRatio, float nearPlane, float farPlane)
float top() 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 setProjectionMatrix(const QMatrix4x4 &projectionMatrix)
void setProjectionType(Qt3DRender::QCameraLens::ProjectionType projectionType)
void setRight(float right)
void setTop(float top)

信号

void aspectRatioChanged(float aspectRatio)
void bottomChanged(float bottom)
void exposureChanged(float exposure)
void farPlaneChanged(float farPlane)
void fieldOfViewChanged(float fieldOfView)
void leftChanged(float left)
void nearPlaneChanged(float nearPlane)
void projectionMatrixChanged(const QMatrix4x4 &projectionMatrix)
void projectionTypeChanged(Qt3DRender::QCameraLens::ProjectionType projectionType)
void rightChanged(float right)
void topChanged(float top)

详细说明

成员类型文档

enum QCameraLens::ProjectionType

指定Qt3DRender::QCameraLens 的哪些参数用于计算投影矩阵。

常数说明
Qt3DRender::QCameraLens::OrthographicProjection0正交投影
Qt3DRender::QCameraLens::PerspectiveProjection1透视投影
Qt3DRender::QCameraLens::FrustumProjection2正投影
Qt3DRender::QCameraLens::CustomProjection3用户自定义投影

属性文档

aspectRatio : float

保存摄像机镜头的当前宽高比。

注意: :如果投影类型不是Qt3DRender::QCameraLens::PerspectiveProjection ,返回值可能未定义。

访问功能:

float aspectRatio() const
void setAspectRatio(float aspectRatio)

通知信号:

void aspectRatioChanged(float aspectRatio)

bottom : float

保存摄像机镜头的当前底平面。

注: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,返回值可能未定义。

访问功能:

float bottom() const
void setBottom(float bottom)

通知信号:

void bottomChanged(float bottom)

exposure : float

保存相机镜头的当前曝光。

访问功能:

float exposure() const
void setExposure(float exposure)

提示信号:

void exposureChanged(float exposure)

farPlane : float

保存当前摄像机镜头的近平面。

访问功能:

float farPlane() const
void setFarPlane(float farPlane)

通知信号:

void farPlaneChanged(float farPlane)

fieldOfView : float

保存摄像机镜头的当前视野。

注意: :如果投影类型不是Qt3DRender::QCameraLens::PerspectiveProjection ,返回值可能未定义。

访问功能:

float fieldOfView() const
void setFieldOfView(float fieldOfView)

通知信号:

void fieldOfViewChanged(float fieldOfView)

left : float

保存当前摄像机镜头的左平面。

注: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,返回值可能未定义。

访问功能:

float left() const
void setLeft(float left)

通知信号:

void leftChanged(float left)

nearPlane : float

保存当前摄像机镜头的近平面。

访问功能:

float nearPlane() const
void setNearPlane(float nearPlane)

通知信号:

void nearPlaneChanged(float nearPlane)

projectionMatrix : QMatrix4x4

保存摄像机镜头的当前投影矩阵。

访问功能:

QMatrix4x4 projectionMatrix() const
void setProjectionMatrix(const QMatrix4x4 &projectionMatrix)

通知信号:

void projectionMatrixChanged(const QMatrix4x4 &projectionMatrix)

projectionType : ProjectionType

保存摄像机投影类型。

访问功能:

Qt3DRender::QCameraLens::ProjectionType projectionType() const
void setProjectionType(Qt3DRender::QCameraLens::ProjectionType projectionType)

通知信号:

void projectionTypeChanged(Qt3DRender::QCameraLens::ProjectionType projectionType)

另请参阅 Qt3DRender::QCameraLens::ProjectionType

right : float

保存当前摄像机镜头的右平面。

注: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,返回值可能未定义。

访问功能:

float right() const
void setRight(float right)

通知信号:

void rightChanged(float right)

top : float

保存当前摄像机镜头的顶平面。

注: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,返回值可能未定义。

访问功能:

float top() const
void setTop(float top)

Notifier 信号:

void topChanged(float top)

成员函数 文档

[explicit] QCameraLens::QCameraLens(Qt3DCore::QNode *parent = nullptr)

用给定的parent

[slot] void QCameraLens::setAspectRatio(float aspectRatio)

将投影的纵横比设置为aspectRatio 。这将触发投影矩阵更新。

注: 如果投影类型不是Qt3DRender::QCameraLens::PerspectiveProjection ,则该设置无效。

注: 属性aspectRatio 的设置函数。

另请参阅 aspectRatio() 。

[slot] void QCameraLens::setBottom(float bottom)

将投影的底部窗口坐标设置为bottom 。这将触发投影矩阵更新。

注: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,则该设置无效。

注: 属性bottom 的设置函数。

另请参阅 bottom() 。

[slot] void QCameraLens::setExposure(float exposure)

设置摄像机镜头的exposure

注: 属性exposure 的设置函数。

另请参阅 exposure().

[slot] void QCameraLens::setFarPlane(float farPlane)

将投影的远平面设置为farPlane 。这将触发投影矩阵更新。

注: 属性farPlane 的设置函数。

另请参阅 farPlane() 。

[slot] void QCameraLens::setFieldOfView(float fieldOfView)

将投影的视场设置为fieldOfView 度。这会触发投影矩阵更新。

注: 如果投影类型不是Qt3DRender::QCameraLens::PerspectiveProjection ,则该设置无效。

注: 属性fieldOfView 的设置函数。

另请参阅 fieldOfView().

void QCameraLens::setFrustumProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane)

根据left,right,bottom,top,nearPlane,farPlane 定义正投影。

[slot] void QCameraLens::setLeft(float left)

将投影的左下角窗口坐标设置为left 。这将触发投影矩阵更新。

注: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,则该设置无效。

注: 属性left 的设置函数。

另请参阅 left().

[slot] void QCameraLens::setNearPlane(float nearPlane)

将投影的近平面设置为nearPlane 。这将触发投影矩阵更新。

注: 属性nearPlane 的设置函数。

另请参阅 nearPlane() 。

void QCameraLens::setOrthographicProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane)

根据left,right,bottom,top,nearPlane,farPlane 定义正投影。

void QCameraLens::setPerspectiveProjection(float fieldOfView, float aspectRatio, float nearPlane, float farPlane)

根据fieldOfView,aspectRatio,nearPlane,farPlane 定义透视投影。

[slot] void QCameraLens::setProjectionMatrix(const QMatrix4x4 &projectionMatrix)

将投影矩阵设置为projectionMatrix

注: 这将把投影类型设置为Qt3DRender::QCameraLens::CustomProjection ,从而忽略可能指定的所有其他摄像机参数。

注: 属性projectionMatrix 的设置函数。

另请参阅 projectionMatrix().

[slot] void QCameraLens::setProjectionType(Qt3DRender::QCameraLens::ProjectionType projectionType)

设置镜头的投影类型projectionType

注: Qt3DRender::QCameraLens::Frustum 和Qt3DRender::QCameraLens::PerspectiveProjection 是指定相同投影的两种不同方法。

注: 属性projectionType 的设置函数。

另请参阅 projectionType() 。

[slot] void QCameraLens::setRight(float right)

将投影的右上窗口坐标设置为right 。这将触发投影矩阵更新。

注: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,则该设置无效。

注: 属性right 的设置函数。

另请参阅 right().

[slot] void QCameraLens::setTop(float top)

将投影的窗口顶坐标设置为top 。这将触发投影矩阵更新。

注: 如果投影类型为Qt3DRender::QCameraLens::PerspectiveProjection ,则该设置无效。

注: 属性top 的设置函数。

另请参阅 top().

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.