summaryrefslogtreecommitdiffstats
path: root/src/quick3d/quick3d
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2015-11-07 12:00:39 +0000
committerSean Harmer <sean.harmer@kdab.com>2015-11-13 17:52:37 +0000
commit6e5c2360c0eda7efb60c9ecf9c88d463384aa53d (patch)
treebf29eab92fc8ee847bcb472e6d749224f16b05b3 /src/quick3d/quick3d
parentd8da2c01d820137919f217367c758845e4817af2 (diff)
Extend qml value type for QMatrix4x4 to be more useful
Add functions for applying common transformations: translate, scale, rotate and lookAt that are needed when building affine transformation matrices. It would be very useful to update the QtObject::method_matrix4x4() function in qtdeclarative to allow calling Qt.matrix4x4() with no arguments and results in creating an identity matrix. Change-Id: Id66bb0e1435c015c25aaa717ca98f3aa5d539530 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/quick3d/quick3d')
-rw-r--r--src/quick3d/quick3d/qt3dquickvaluetypes_p.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/quick3d/quick3d/qt3dquickvaluetypes_p.h b/src/quick3d/quick3d/qt3dquickvaluetypes_p.h
index 1fec1f059..4aef66c14 100644
--- a/src/quick3d/quick3d/qt3dquickvaluetypes_p.h
+++ b/src/quick3d/quick3d/qt3dquickvaluetypes_p.h
@@ -261,6 +261,13 @@ public:
void setM43(qreal value) { v(3, 2) = value; }
void setM44(qreal value) { v(3, 3) = value; }
+ Q_INVOKABLE void translate(const QVector3D &t) { v.translate(t); }
+ Q_INVOKABLE void rotate(float angle, const QVector3D &axis) { v.rotate(angle, axis); }
+ Q_INVOKABLE void scale(float s) { v.scale(s); }
+ Q_INVOKABLE void scale(float sx, float sy, float sz) { v.scale(sx, sy, sz); }
+ Q_INVOKABLE void scale(const QVector3D &s) { v.scale(s); }
+ Q_INVOKABLE void lookAt(const QVector3D &eye, const QVector3D &center, const QVector3D &up) { v.lookAt(eye, center, up); }
+
Q_INVOKABLE QMatrix4x4 times(const QMatrix4x4 &m) const;
Q_INVOKABLE QVector4D times(const QVector4D &vec) const;
Q_INVOKABLE QVector3D times(const QVector3D &vec) const;