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/materials | |
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/materials')
-rw-r--r-- | examples/qt3d/materials/Barrel.qml | 7 | ||||
-rw-r--r-- | examples/qt3d/materials/Chest.qml | 7 | ||||
-rw-r--r-- | examples/qt3d/materials/HousePlant.qml | 7 | ||||
-rw-r--r-- | examples/qt3d/materials/PlaneEntity.qml | 13 | ||||
-rw-r--r-- | examples/qt3d/materials/RenderableEntity.qml | 23 | ||||
-rw-r--r-- | examples/qt3d/materials/TrefoilKnot.qml | 15 | ||||
-rw-r--r-- | examples/qt3d/materials/main.qml | 2 |
7 files changed, 41 insertions, 33 deletions
diff --git a/examples/qt3d/materials/Barrel.qml b/examples/qt3d/materials/Barrel.qml index ba703a998..02a7e4812 100644 --- a/examples/qt3d/materials/Barrel.qml +++ b/examples/qt3d/materials/Barrel.qml @@ -44,9 +44,9 @@ Entity { property string bump: "no_bumps" property string specular: "" - property alias x: barrel.x - property alias y: barrel.y - property alias z: barrel.z + property real x: 0 + property real y: 0 + property real z: 0 property alias shininess: material.shininess property real scale: 1.0 @@ -54,6 +54,7 @@ Entity { id: barrel source: "assets/metalbarrel/metal_barrel.obj" scale: 0.03 * root.scale + position: Qt.vector3d(root.x, root.y, root.z) material: NormalDiffuseSpecularMapMaterial { id: material diff --git a/examples/qt3d/materials/Chest.qml b/examples/qt3d/materials/Chest.qml index bc3fcd838..3e361cadb 100644 --- a/examples/qt3d/materials/Chest.qml +++ b/examples/qt3d/materials/Chest.qml @@ -40,14 +40,15 @@ import Qt3D.Render 2.0 Entity { id: root - property alias x: chest.x - property alias y: chest.y - property alias z: chest.z + property real x: 0 + property real y: 0 + property real z: 0 property real scale: 1.0 RenderableEntity { id: chest source: "assets/chest/Chest.obj" + position: Qt.vector3d(root.x, root.y, root.z) scale: 0.03 * root.scale material: DiffuseMapMaterial { diff --git a/examples/qt3d/materials/HousePlant.qml b/examples/qt3d/materials/HousePlant.qml index 9ed378e6a..c8d4693d3 100644 --- a/examples/qt3d/materials/HousePlant.qml +++ b/examples/qt3d/materials/HousePlant.qml @@ -43,15 +43,16 @@ Entity { property string potShape: "cross" property string plantType: "bamboo" - property alias x: pot.x - property alias y: pot.y - property alias z: pot.z + property real x: 0 + property real y: 0 + property real z: 0 property real scale: 1.0 RenderableEntity { id: pot source: "assets/houseplants/" + root.potShape + "-pot.obj" scale: 0.03 * root.scale + position: Qt.vector3d(root.x, root.y, root.z) material: NormalDiffuseMapMaterial { diffuse: "assets/houseplants/pot.webp" diff --git a/examples/qt3d/materials/PlaneEntity.qml b/examples/qt3d/materials/PlaneEntity.qml index e02318597..ce07db08b 100644 --- a/examples/qt3d/materials/PlaneEntity.qml +++ b/examples/qt3d/materials/PlaneEntity.qml @@ -39,11 +39,8 @@ import Qt3D.Render 2.0 Entity { id: root - - property alias x: translateTransform.dx - property alias y: translateTransform.dy - property alias z: translateTransform.dz - property alias scale: scaleTransform.scale + property alias position: transform.translation + property alias scale: transform.scale property alias width: mesh.width property alias height: mesh.height property alias resolution: mesh.meshResolution @@ -51,11 +48,7 @@ Entity { components: [ transform, mesh, root.material ] - Transform { - id: transform - Translate { id: translateTransform } - Scale { id: scaleTransform } - } + Transform { id: transform } PlaneMesh { id: mesh diff --git a/examples/qt3d/materials/RenderableEntity.qml b/examples/qt3d/materials/RenderableEntity.qml index 093ba24e5..e309ec8ba 100644 --- a/examples/qt3d/materials/RenderableEntity.qml +++ b/examples/qt3d/materials/RenderableEntity.qml @@ -40,12 +40,10 @@ import Qt3D.Render 2.0 Entity { id: root - property alias x: translateTransform.dx - property alias y: translateTransform.dy - property alias z: translateTransform.dz - property alias scale: scaleTransform.scale - property alias rotationAngle: rotateTransform.angle - property alias rotationAxis: rotateTransform.axis + property vector3d position: Qt.vector3d(0, 0, 0) + property real scale: 1.0 + property real rotationAngle: 0.0 + property vector3d rotationAxis: Qt.vector3d(1, 0, 0) property alias source: mesh.source property Material material @@ -53,9 +51,16 @@ Entity { Transform { id: transform - Rotate { id: rotateTransform } - Scale { id: scaleTransform } - Translate { id: translateTransform } + matrix: { + var m = Qt.matrix4x4(1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1); + m.translate(root.position); + m.rotate(root.rotationAngle, root.rotationAxis); + m.scale(root.scale); + return m; + } } Mesh { diff --git a/examples/qt3d/materials/TrefoilKnot.qml b/examples/qt3d/materials/TrefoilKnot.qml index 762ae5398..9440d7a85 100644 --- a/examples/qt3d/materials/TrefoilKnot.qml +++ b/examples/qt3d/materials/TrefoilKnot.qml @@ -52,10 +52,17 @@ Entity { Transform { id: transform - Scale { scale: root.scale } - Rotate{ angle: root.theta; axis: Qt.vector3d(1.0, 0.0, 0.0) } - Rotate{ angle: root.phi; axis: Qt.vector3d(0.0, 1.0, 0.0) } - Translate { dx: root.x; dy: root.y; dz: root.z } + 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(root.x, root.y, root.z)); + m.rotate(phi, Qt.vector3d(0, 1, 0)); + m.rotate(theta, Qt.vector3d(1, 0, 0)); + m.scale(root.scale); + return m; + } } Mesh { diff --git a/examples/qt3d/materials/main.qml b/examples/qt3d/materials/main.qml index c41126efa..de759209b 100644 --- a/examples/qt3d/materials/main.qml +++ b/examples/qt3d/materials/main.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 |