Qt3DCore::QTransform Class
class Qt3DCore::QTransform用于对网格执行变换。更多...
| 标题: | #include <QTransform> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS 3DCore) target_link_libraries(mytarget PRIVATE Qt6::3DCore) |
| qmake: | QT += 3dcore |
| 在 QML 中: | Transform |
| 继承自: | Qt3DCore::QComponent |
| 状态: | 已弃用 |
该类已弃用。我们强烈建议在新代码中不要使用它。
属性
|
公共函数
| QTransform(Qt3DCore::QNode *parent = nullptr) | |
| QMatrix4x4 | matrix() const |
| QQuaternion | rotation() const |
| float | rotationX() const |
| float | rotationY() const |
| float | rotationZ() const |
| float | scale() const |
| QVector3D | scale3D() const |
| QVector3D | translation() const |
| QMatrix4x4 | worldMatrix() const |
公共槽位
| void | setMatrix(const QMatrix4x4 &matrix) |
| void | setRotation(const QQuaternion &rotation) |
| void | setRotationX(float rotationX) |
| void | setRotationY(float rotationY) |
| void | setRotationZ(float rotationZ) |
| void | setScale(float scale) |
| void | setScale3D(const QVector3D &scale) |
| void | setTranslation(const QVector3D &translation) |
信号
| void | matrixChanged() |
| void | rotationChanged(const QQuaternion &rotation) |
| void | rotationXChanged(float rotationX) |
| void | rotationYChanged(float rotationY) |
| void | rotationZChanged(float rotationZ) |
| void | scale3DChanged(const QVector3D &scale) |
| void | scaleChanged(float scale) |
| void | translationChanged(const QVector3D &translation) |
| void | worldMatrixChanged(const QMatrix4x4 &worldMatrix) |
静态公共成员
| QQuaternion | fromAxes(const QVector3D &xAxis, const QVector3D &yAxis, const QVector3D &zAxis) |
| QQuaternion | fromAxesAndAngles(const QVector3D &axis1, float angle1, const QVector3D &axis2, float angle2) |
| QQuaternion | fromAxesAndAngles(const QVector3D &axis1, float angle1, const QVector3D &axis2, float angle2, const QVector3D &axis3, float angle3) |
| QQuaternion | fromAxisAndAngle(const QVector3D &axis, float angle) |
| QQuaternion | fromAxisAndAngle(float x, float y, float z, float angle) |
| QQuaternion | fromEulerAngles(const QVector3D &eulerAngles) |
| QQuaternion | fromEulerAngles(float pitch, float yaw, float roll) |
| QMatrix4x4 | rotateAround(const QVector3D &point, float angle, const QVector3D &axis) |
| QMatrix4x4 | rotateFromAxes(const QVector3D &xAxis, const QVector3D &yAxis, const QVector3D &zAxis) |
详细说明
QTransform组件无法在多个QEntity 之间共享。变换由QVector3D 缩放、QQuaternion 旋转和QVector3D 平移组件构成。这些变换将按此顺序应用于网格。当设置QTransform::matrix 属性时,该属性会被分解为这些变换组件,并发出相应的信号。
提供了若干辅助函数用于配置 QTransform;fromAxisAndAngle 和fromAxesAndAngles 可用于设置围绕特定轴的旋转,fromEulerAngles 可用于根据欧拉角设置旋转,rotateAround 可用于将对象围绕相对于局部原点的特定点进行旋转。
属性文档
matrix : QMatrix4x4
存储变换的QMatrix4x4 。
注意:当 设置矩阵属性时 ,该矩阵会被分解为平移、旋转和缩放分量。
访问函数:
| QMatrix4x4 | matrix() const |
| void | setMatrix(const QMatrix4x4 &matrix) |
通知信号:
| void | matrixChanged() |
rotation : QQuaternion
将变换的旋转存储为QQuaternion 。
访问函数:
| QQuaternion | rotation() const |
| void | setRotation(const QQuaternion &rotation) |
通知器信号:
| void | rotationChanged(const QQuaternion &rotation) |
rotationX : float
将变换的 x 轴旋转以欧拉角形式存储。
访问函数:
| float | rotationX() const |
| void | setRotationX(float rotationX) |
通知信号:
| void | rotationXChanged(float rotationX) |
rotationY : float
将变换的 y 轴旋转以欧拉角的形式存储。
访问函数:
| float | rotationY() const |
| void | setRotationY(float rotationY) |
通知信号:
| void | rotationYChanged(float rotationY) |
rotationZ : float
将变换的 z 轴旋转作为欧拉角存储。
访问函数:
| float | rotationZ() const |
| void | setRotationZ(float rotationZ) |
通知信号:
| void | rotationZChanged(float rotationZ) |
scale : float
保存变换的统一缩放比例。如果缩放比例是通过setScale3D 设置的,则仅保存x值。
访问函数:
| float | scale() const |
| void | setScale(float scale) |
通知信号:
| void | scaleChanged(float scale) |
scale3D : QVector3D
将变换的缩放因子存储为QVector3D 。
访问函数:
| QVector3D | scale3D() const |
| void | setScale3D(const QVector3D &scale) |
通知信号:
| void | scale3DChanged(const QVector3D &scale) |
translation : QVector3D
将变换的转换结果存储为QVector3D 。
访问函数:
| QVector3D | translation() const |
| void | setTranslation(const QVector3D &translation) |
通知器信号:
| void | translationChanged(const QVector3D &translation) |
[read-only] worldMatrix : QMatrix4x4
存储该变换的世界变换矩阵。这假设QTransform 组件正被一个QEntity引用。这样可以更方便地识别子树中某个QEntity在世界坐标系中是否已发生变换,即使其本地变换可能并未改变。
访问函数:
| QMatrix4x4 | worldMatrix() const |
通知信号:
| void | worldMatrixChanged(const QMatrix4x4 &worldMatrix) |
成员函数文档
[explicit] QTransform::QTransform(Qt3DCore::QNode *parent = nullptr)
使用parent 创建一个新的QTransform。
[static invokable] QQuaternion QTransform::fromAxes(const QVector3D &xAxis, const QVector3D &yAxis, const QVector3D &zAxis)
创建一个 QQuaterniom 对象,该对象定义了以坐标轴xAxis 、yAxis 和zAxis 为基准的旋转。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[static invokable] QQuaternion QTransform::fromAxesAndAngles(const QVector3D &axis1, float angle1, const QVector3D &axis2, float angle2)
根据axis1 、angle1 、axis2 和angle2 创建一个 `QQuaternion `。返回生成的 `QQuaternion`。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[static invokable] QQuaternion QTransform::fromAxesAndAngles(const QVector3D &axis1, float angle1, const QVector3D &axis2, float angle2, const QVector3D &axis3, float angle3)
根据axis1 、angle1 、axis2 、angle2 、axis3 和angle3 创建一个 `QQuaternion `。返回生成的 `QQuaternion`。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[static invokable] QQuaternion QTransform::fromAxisAndAngle(const QVector3D &axis, float angle)
根据 `axis ` 和 `angle` 创建一个 `QQuaternion `。返回生成的 `QQuaternion`。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[static invokable] QQuaternion QTransform::fromAxisAndAngle(float x, float y, float z, float angle)
根据x 、y 、z 和angle 创建一个QQuaternion 。返回生成的QQuaternion 。
注意: 可通过元对象系统和 QML 调用此 函数。请参阅Q_INVOKABLE 。
[static invokable] QQuaternion QTransform::fromEulerAngles(const QVector3D &eulerAngles)
根据 `eulerAngles` 创建一个 `QQuaternion `。返回生成的 `QQuaternion`。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[static invokable] QQuaternion QTransform::fromEulerAngles(float pitch, float yaw, float roll)
根据pitch 、yaw 和roll 创建一个QQuaternion 。返回生成的QQuaternion 。
注意:此 函数可通过元对象系统以及从 QML 中调用。参见Q_INVOKABLE 。
[static invokable] QMatrix4x4 QTransform::rotateAround(const QVector3D &point, float angle, const QVector3D &axis)
根据axis 和angle ,围绕point 创建一个旋转矩阵。返回生成的QMatrix4x4 。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[static invokable] QMatrix4x4 QTransform::rotateFromAxes(const QVector3D &xAxis, const QVector3D &yAxis, const QVector3D &zAxis)
返回一个由坐标轴xAxis 、yAxis 、zAxis 定义的旋转矩阵。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
QMatrix4x4 QTransform::worldMatrix() const
返回与QTransform 关联的世界变换矩阵,当该 被可能属于QEntity层次结构的QEntity引用时。
注意: 这是属性 worldMatrix 的获取 函数。
© 2026 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.