summaryrefslogtreecommitdiffstats
path: root/examples/qt3d/anaglyph-rendering
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2015-11-07 19:02:14 +0000
committerPaul Lemire <paul.lemire@kdab.com>2015-11-17 19:41:18 +0000
commit26a118cfbce29014864f6cdddae66cccb65ffb4f (patch)
treedaea9f2fc41c1df586c35cd56daa61f920ce5b58 /examples/qt3d/anaglyph-rendering
parentace675a084ab944a245500b9f54be653126c3147 (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/anaglyph-rendering')
-rw-r--r--examples/qt3d/anaglyph-rendering/StereoCamera.qml17
-rw-r--r--examples/qt3d/anaglyph-rendering/main.qml101
2 files changed, 64 insertions, 54 deletions
diff --git a/examples/qt3d/anaglyph-rendering/StereoCamera.qml b/examples/qt3d/anaglyph-rendering/StereoCamera.qml
index 4e0433883..c6218aee6 100644
--- a/examples/qt3d/anaglyph-rendering/StereoCamera.qml
+++ b/examples/qt3d/anaglyph-rendering/StereoCamera.qml
@@ -46,8 +46,8 @@ Entity {
property real nearPlane: 10.0
property real farPlane: 10000.0
- property alias viewCenter: eyeLookAt.viewCenter
- property alias position: eyeLookAt.position
+ property vector3d viewCenter: Qt.vector3d(0.0, 0.0, 0.0)
+ property vector3d position: Qt.vector3d(0.0, 0.0, 1.0)
readonly property real _fov2: Math.tan(fieldOfView * Math.PI / 180 * 0.5)
readonly property real top: nearPlane * _fov2
@@ -77,11 +77,14 @@ Entity {
Transform {
id: eyeTransform
- LookAt {
- id: eyeLookAt
- upVector: Qt.vector3d(0.0, 1.0, 0.0)
- viewCenter: root.viewCenter
- position: root.position
+
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.lookAt(root.position, root.viewCenter, Qt.vector3d(0.0, 1.0, 0.0));
+ return m;
}
}
diff --git a/examples/qt3d/anaglyph-rendering/main.qml b/examples/qt3d/anaglyph-rendering/main.qml
index 533b1118c..73a6bc59d 100644
--- a/examples/qt3d/anaglyph-rendering/main.qml
+++ b/examples/qt3d/anaglyph-rendering/main.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
+import QtQuick 2.4 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-import QtQuick 2.4 as QQ2
Entity {
id: root
@@ -56,7 +56,7 @@ Entity {
readonly property real cameraRadius: obstaclesRepeater.radius - 50
readonly property vector3d circlePosition: Qt.vector3d(cameraRadius * Math.cos(circleRotation), 0.0, cameraRadius * Math.sin(circleRotation))
readonly property vector3d tan: circlePosition.crossProduct(Qt.vector3d(0, 1, 0).normalized())
- viewCenter: planeTranslation.translation
+ viewCenter: planeTransform.translation
position: circlePosition.plus(Qt.vector3d(0, 45 * Math.sin(circleRotation * 2), 0)).plus(tan.times(-2))
QQ2.NumberAnimation {
@@ -85,16 +85,20 @@ Entity {
slices: 20
}
property Transform transform: Transform {
- Scale { id: cylinderScale; scale: 5 }
- Rotate {
- id: cylinderRotationTheta
- angle: 45
- axis: Qt.vector3d(1, 0, 0)
- }
- Rotate {
- id: cylinderRotationPhi
- angle: 30
- axis: Qt.vector3d(1, 0, 0)
+ id: cylinderTransform
+ property real theta: 0.0
+ property real phi: 0.0
+ property real userScale: 1.0
+
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(phi, Qt.vector3d(0.0, 1.0, 0.0));
+ m.rotate(theta, Qt.vector3d(1.0, 0.0, 0.0));
+ m.scale(userScale);
+ return m;
}
}
property Material phong: PhongMaterial {}
@@ -104,29 +108,29 @@ Entity {
running: true
QQ2.SequentialAnimation {
QQ2.NumberAnimation {
- target: cylinderScale
- property: "scale"
+ target: cylinderTransform
+ property: "userScale"
from: 5; to: 45
duration: 2000
easing.type: QQ2.Easing.OutInQuad
}
QQ2.NumberAnimation {
- target: cylinderScale
- property: "scale"
+ target: cylinderTransform
+ property: "userScale"
from: 45; to: 5
duration: 2000
easing.type: QQ2.Easing.InOutQuart
}
}
QQ2.NumberAnimation {
- target: cylinderRotationPhi
- property: "angle"
+ target: cylinderTransform
+ property: "phi"
from: 0; to: 360
duration: 4000
}
QQ2.NumberAnimation {
- target: cylinderRotationTheta
- property: "angle"
+ target: cylinderTransform
+ property: "theta"
from: 0; to: 720
duration: 4000
}
@@ -142,20 +146,20 @@ Entity {
source: "assets/obj/toyplane.obj"
},
Transform {
- Rotate { // roll
- id: roll
- axis : Qt.vector3d(1, 0, 0)
- angle : 30
- }
- Rotate {
- axis: Qt.vector3d(0, 1, 0)
- angle: stereoCamera.circleRotation * -2 * 180 / Math.PI + 180
- }
- Translate {
- id: planeTranslation
- dx: Math.sin(stereoCamera.circleRotation * -2) * obstaclesRepeater.radius
- dy: 0
- dz: Math.cos(stereoCamera.circleRotation * -2) * obstaclesRepeater.radius
+ id: planeTransform
+ property real rollAngle: 0.0
+
+ 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(stereoCamera.circleRotation * -2) * obstaclesRepeater.radius,
+ 0.0,
+ Math.cos(stereoCamera.circleRotation * -2) * obstaclesRepeater.radius))
+ m.rotate(stereoCamera.circleRotation * -2 * 180 / Math.PI + 180, Qt.vector3d(0.0, 1.0, 0.0));
+ m.rotate(planeTransform.rollAngle, Qt.vector3d(1.0, 0.0, 0.0));
+ return m;
}
},
PhongMaterial {
@@ -169,20 +173,20 @@ Entity {
loops: QQ2.Animation.Infinite
QQ2.NumberAnimation {
- target: roll
- property: "angle"
+ target: planeTransform
+ property: "rollAngle"
from: 30; to: 45
duration: 750
}
QQ2.NumberAnimation {
- target: roll
- property: "angle"
+ target: planeTransform
+ property: "rollAngle"
from: 45; to: 25
duration: 500
}
QQ2.NumberAnimation {
- target: roll
- property: "angle"
+ target: planeTransform
+ property: "rollAngle"
from: 25; to: 390
duration: 800
}
@@ -206,13 +210,16 @@ Entity {
Transform {
id: transform
readonly property real angle: Math.PI * 2.0 * index * obstaclesRepeater.det
- Rotate {
- angle: transform.angle * 180 / Math.PI
- axis: Qt.vector3d(0.0, 1.0, 0.0)
- }
- Translate {
- dx: obstaclesRepeater.radius * Math.cos(transform.angle)
- dz: obstaclesRepeater.radius * Math.sin(transform.angle)
+ 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(obstaclesRepeater.radius * Math.cos(transform.angle),
+ 0.0,
+ obstaclesRepeater.radius * Math.sin(transform.angle)))
+ m.rotate(transform.angle * 180 / Math.PI, Qt.vector3d(0.0, 1.0, 0.0));
+ return m;
}
},
PhongMaterial {