1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DCORE_QTRANSFORM_H
5#define QT3DCORE_QTRANSFORM_H
6
7#include <Qt3DCore/qcomponent.h>
8#include <QtGui/qmatrix4x4.h>
9#include <QtGui/qquaternion.h>
10#include <QtGui/qvector3d.h>
11
12QT_BEGIN_NAMESPACE
13
14namespace Qt3DCore {
15
16class QTransformPrivate;
17class Q_3DCORESHARED_EXPORT QTransform : public QComponent
18{
19 Q_OBJECT
20 Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY matrixChanged)
21 Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scaleChanged)
22 Q_PROPERTY(QVector3D scale3D READ scale3D WRITE setScale3D NOTIFY scale3DChanged)
23 Q_PROPERTY(QQuaternion rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
24 Q_PROPERTY(QVector3D translation READ translation WRITE setTranslation NOTIFY translationChanged)
25 Q_PROPERTY(float rotationX READ rotationX WRITE setRotationX NOTIFY rotationXChanged)
26 Q_PROPERTY(float rotationY READ rotationY WRITE setRotationY NOTIFY rotationYChanged)
27 Q_PROPERTY(float rotationZ READ rotationZ WRITE setRotationZ NOTIFY rotationZChanged)
28 Q_PROPERTY(QMatrix4x4 worldMatrix READ worldMatrix NOTIFY worldMatrixChanged QT3D_PROPERTY_REVISION(2, 14))
29
30public:
31 explicit QTransform(QNode *parent = nullptr);
32 ~QTransform();
33
34 float scale() const;
35 QVector3D scale3D() const;
36 QQuaternion rotation() const;
37 QVector3D translation() const;
38
39 Q_INVOKABLE static QQuaternion fromAxisAndAngle(const QVector3D &axis, float angle);
40 Q_INVOKABLE static QQuaternion fromAxisAndAngle(float x, float y, float z, float angle);
41
42 Q_INVOKABLE static QQuaternion fromAxesAndAngles(const QVector3D &axis1, float angle1,
43 const QVector3D &axis2, float angle2);
44 Q_INVOKABLE static QQuaternion fromAxesAndAngles(const QVector3D &axis1, float angle1,
45 const QVector3D &axis2, float angle2,
46 const QVector3D &axis3, float angle3);
47 Q_INVOKABLE static QQuaternion fromAxes(const QVector3D &xAxis, const QVector3D &yAxis, const QVector3D &zAxis);
48
49 Q_INVOKABLE static QQuaternion fromEulerAngles(const QVector3D &eulerAngles);
50 Q_INVOKABLE static QQuaternion fromEulerAngles(float pitch, float yaw, float roll);
51
52 Q_INVOKABLE static QMatrix4x4 rotateAround(const QVector3D &point, float angle, const QVector3D &axis);
53 Q_INVOKABLE static QMatrix4x4 rotateFromAxes(const QVector3D &xAxis, const QVector3D &yAxis, const QVector3D &zAxis);
54
55 QMatrix4x4 matrix() const;
56 QMatrix4x4 worldMatrix() const;
57
58 float rotationX() const;
59 float rotationY() const;
60 float rotationZ() const;
61
62public Q_SLOTS:
63 void setScale(float scale);
64 void setScale3D(const QVector3D &scale);
65 void setRotation(const QQuaternion &rotation);
66 void setTranslation(const QVector3D &translation);
67 void setMatrix(const QMatrix4x4 &matrix);
68
69 void setRotationX(float rotationX);
70 void setRotationY(float rotationY);
71 void setRotationZ(float rotationZ);
72
73Q_SIGNALS:
74 void scaleChanged(float scale);
75 void scale3DChanged(const QVector3D &scale);
76 void rotationChanged(const QQuaternion &rotation);
77 void translationChanged(const QVector3D &translation);
78 void matrixChanged();
79 void rotationXChanged(float rotationX);
80 void rotationYChanged(float rotationY);
81 void rotationZChanged(float rotationZ);
82 void worldMatrixChanged(const QMatrix4x4 &worldMatrix);
83
84protected:
85 explicit QTransform(QTransformPrivate &dd, QNode *parent = nullptr);
86
87private:
88 Q_DECLARE_PRIVATE(QTransform)
89};
90
91} // namespace Qt3DCore
92
93QT_END_NAMESPACE
94
95#endif // QT3DCORE_QTRANSFORM_H
96

source code of qt3d/src/core/transforms/qtransform.h