QTransform Class

class Qt3DCore::QTransform

Used to perform transforms on meshes. More...

Header: #include <QTransform>
qmake: QT += 3dcore
Since: Qt 5.6
Instantiated By: Transform
Inherits: Qt3DCore::QComponent

This class was introduced in Qt 5.6.

Properties

Public Functions

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

Public Slots

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)

Signals

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)

Detailed Description

The QTransform component is not shareable between multiple QEntity's. The transformation is held as QVector3D scale, QQuaternion rotation and QVector3D translation components. The transformations are applied to the mesh in that order. When QTransform::matrix property is set, it is decomposed to these transform components and corresponding signals are emitted.

Several helper functions are provided to set up the QTransform; fromAxisAndAngle and fromAxesAndAngles can be used to set the rotation around specific axes, fromEulerAngles can be used to set the rotation based on euler angles and rotateAround can be used to rotate the object around specific point relative to local origin.

Property Documentation

matrix : QMatrix4x4

Holds the QMatrix4x4 of the transform.

Note: When the matrix property is set, it is decomposed to translation, rotation and scale components.

Access functions:

QMatrix4x4 matrix() const
void setMatrix(const QMatrix4x4 &matrix)

Notifier signal:

void matrixChanged()

rotation : QQuaternion

Holds the rotation of the transform as QQuaternion.

Access functions:

QQuaternion rotation() const
void setRotation(const QQuaternion &rotation)

Notifier signal:

void rotationChanged(const QQuaternion &rotation)

rotationX : float

Holds the x rotation of the transform as Euler angle.

Access functions:

float rotationX() const
void setRotationX(float rotationX)

Notifier signal:

void rotationXChanged(float rotationX)

rotationY : float

Holds the y rotation of the transform as Euler angle.

Access functions:

float rotationY() const
void setRotationY(float rotationY)

Notifier signal:

void rotationYChanged(float rotationY)

rotationZ : float

Holds the z rotation of the transform as Euler angle.

Access functions:

float rotationZ() const
void setRotationZ(float rotationZ)

Notifier signal:

void rotationZChanged(float rotationZ)

scale : float

Holds the uniform scale of the transform. If the scale has been set with setScale3D, holds the x value only.

Access functions:

float scale() const
void setScale(float scale)

Notifier signal:

void scaleChanged(float scale)

scale3D : QVector3D

Holds the scale of the transform as QVector3D.

Access functions:

QVector3D scale3D() const
void setScale3D(const QVector3D &scale)

Notifier signal:

void scale3DChanged(const QVector3D &scale)

translation : QVector3D

Holds the translation of the transform as QVector3D.

Access functions:

QVector3D translation() const
void setTranslation(const QVector3D &translation)

Notifier signal:

void translationChanged(const QVector3D &translation)

worldMatrix : const QMatrix4x4

Holds the world transformation matrix for the transform. This assumes the QTransform component is being referenced by a QEntity. This makes it more convenient to identify when a QEntity part of a subtree has been transformed in the world even though its local transformation might not have changed.

This property was introduced in Qt 5.14.

Access functions:

QMatrix4x4 worldMatrix() const

Notifier signal:

void worldMatrixChanged(const QMatrix4x4 &worldMatrix)