summaryrefslogtreecommitdiffstats
path: root/examples/qt3d/anaglyph-rendering
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2018-01-24 15:09:27 +0100
committerPaul Lemire <paul.lemire@kdab.com>2018-01-24 15:02:54 +0000
commit42a8d30929a3dd3bd81c12a1b5ba289b1c3897bb (patch)
tree5b6365f099932c311e137f6209d17c52cc7b59d7 /examples/qt3d/anaglyph-rendering
parent1dc0ddf0534180b94c56084117c78232350223b0 (diff)
anaglyph-rendering: Fix StereoCamera following viewMatrix changes
Change-Id: I42d0091368914e0f3f8cb76c707d576227d7b5f2 Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'examples/qt3d/anaglyph-rendering')
-rw-r--r--examples/qt3d/anaglyph-rendering/StereoCamera.qml24
1 files changed, 14 insertions, 10 deletions
diff --git a/examples/qt3d/anaglyph-rendering/StereoCamera.qml b/examples/qt3d/anaglyph-rendering/StereoCamera.qml
index c8db4c0a9..ea013c0b0 100644
--- a/examples/qt3d/anaglyph-rendering/StereoCamera.qml
+++ b/examples/qt3d/anaglyph-rendering/StereoCamera.qml
@@ -62,6 +62,7 @@ Entity {
property vector3d viewCenter: Qt.vector3d(0.0, 0.0, 0.0)
property vector3d position: Qt.vector3d(0.0, 0.0, 1.0)
+ property vector3d upVector: Qt.vector3d(0.0, 1.0, 0.0)
readonly property real _fov2: Math.tan(fieldOfView * Math.PI / 180 * 0.5)
readonly property real top: nearPlane * _fov2
@@ -94,23 +95,26 @@ Entity {
matrix: {
var m = Qt.matrix4x4();
- m.lookAt(root.position, root.viewCenter, Qt.vector3d(0.0, 1.0, 0.0));
- return m;
+ m.translate(root.position)
+ var zAxis = root.position.minus(root.viewCenter).normalized()
+ var xAxis = root.upVector.crossProduct(zAxis).normalized();
+ var yAxis = zAxis.crossProduct(xAxis);
+ var r = Qt.matrix4x4(xAxis.x, yAxis.x, zAxis.x, 0,
+ xAxis.y, yAxis.y, zAxis.y, 0,
+ xAxis.z, yAxis.z, zAxis.z, 0,
+ 0, 0, 0, 1)
+ return m.times(r);
}
}
+ components: [ eyeTransform ]
+
property Entity leftCamera: Entity {
- components: [
- leftEyeLens,
- eyeTransform
- ]
+ components: [ leftEyeLens ]
}
property Entity rightCamera: Entity {
id: rightCameraEntity
- components: [
- rightEyeLens,
- eyeTransform
- ]
+ components: [ rightEyeLens ]
}
}