diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2015-11-07 19:02:14 +0000 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2015-11-17 19:41:18 +0000 |
commit | 26a118cfbce29014864f6cdddae66cccb65ffb4f (patch) | |
tree | daea9f2fc41c1df586c35cd56daa61f920ce5b58 /examples/qt3d/shadow-map-qml/Toyplane.qml | |
parent | ace675a084ab944a245500b9f54be653126c3147 (diff) |
Remove transforms property of QTransform
Compound transformations are now built up using QMatrix4x4 in both QML
and C++. Updating examples accordingly.
Change-Id: I03c9abf1f6cdd1b56226dc0e16a7ad5ce84516dd
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'examples/qt3d/shadow-map-qml/Toyplane.qml')
-rw-r--r-- | examples/qt3d/shadow-map-qml/Toyplane.qml | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/examples/qt3d/shadow-map-qml/Toyplane.qml b/examples/qt3d/shadow-map-qml/Toyplane.qml index 3bc1c0d53..1f883f2bb 100644 --- a/examples/qt3d/shadow-map-qml/Toyplane.qml +++ b/examples/qt3d/shadow-map-qml/Toyplane.qml @@ -34,9 +34,9 @@ ** ****************************************************************************/ +import QtQuick 2.1 as QQ2 import Qt3D.Core 2.0 import Qt3D.Render 2.0 -import QtQuick 2.1 as QQ2 Entity { id: root @@ -50,40 +50,27 @@ Entity { Transform { id: toyplaneTransform - property real rollAngle : 0 - property real pitchAngle : 15 - property real altitude : 5 + property real rollAngle: 0 + property real pitchAngle: 15 + property real altitude: 5 property real angle: 0 property real scaleFactor: 10 QQ2.Behavior on rollAngle { QQ2.SpringAnimation { spring: 2; damping: 0.2} } - Scale { - scale: 1.0 / toyplaneTransform.scaleFactor - } - - Rotate { // roll - axis : Qt.vector3d(1, 0, 0) - angle : toyplaneTransform.rollAngle - } - - Rotate { // pitch - axis : Qt.vector3d(0, 0, 1) - angle : toyplaneTransform.pitchAngle - } - - Rotate { - id: toyplaneRotation - axis: Qt.vector3d(0, 1, 0) - angle: toyplaneTransform.angle - } - - Translate { - property real translation: 1 - - dx: Math.sin(toyplaneTransform.angle * Math.PI / 180) * translation * toyplaneTransform.scaleFactor - dy: toyplaneTransform.altitude - dz: Math.cos(toyplaneTransform.angle * Math.PI / 180) * translation * toyplaneTransform.scaleFactor + matrix: { + var m = Qt.matrix4x4(1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1); + m.translate(Qt.vector3d(Math.sin(angle * Math.PI / 180) * scaleFactor, + altitude, + Math.cos(angle * Math.PI / 180) * scaleFactor)); + m.rotate(angle, Qt.vector3d(0, 1, 0)); + m.rotate(pitchAngle, Qt.vector3d(0, 0, 1)); + m.rotate(rollAngle, Qt.vector3d(1, 0, 0)); + m.scale(1.0 / toyplaneTransform.scaleFactor); + return m; } } |