summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/qt3d/anaglyph-rendering/StereoCamera.qml17
-rw-r--r--examples/qt3d/anaglyph-rendering/main.qml101
-rw-r--r--examples/qt3d/assimp/main.cpp14
-rw-r--r--examples/qt3d/assimp/main.qml76
-rw-r--r--examples/qt3d/basicshapes-cpp/scenemodifier.cpp65
-rw-r--r--examples/qt3d/bigmodel-qml/MyEntity.qml6
-rw-r--r--examples/qt3d/bigmodel-qml/main.qml5
-rw-r--r--examples/qt3d/bigscene-cpp/bigscene-cpp.pro6
-rw-r--r--examples/qt3d/bigscene-cpp/entity.cpp130
-rw-r--r--examples/qt3d/bigscene-cpp/entity.h (renamed from src/quick3d/quick3d/items/quick3dtransform_p.h)82
-rw-r--r--examples/qt3d/bigscene-cpp/main.cpp45
-rw-r--r--examples/qt3d/clip-planes-qml/ClipPlaneEntity.qml16
-rw-r--r--examples/qt3d/clip-planes-qml/ClippingPlanes.qml2
-rw-r--r--examples/qt3d/clip-planes-qml/main.qml5
-rw-r--r--examples/qt3d/controls/Logo.qml23
-rw-r--r--examples/qt3d/cpp_example/main.cpp20
-rw-r--r--examples/qt3d/custom-mesh-cpp/main.cpp4
-rw-r--r--examples/qt3d/custom-mesh-qml/main.qml19
-rw-r--r--examples/qt3d/cylinder-cpp/main.cpp15
-rw-r--r--examples/qt3d/cylinder-qml/main.qml15
-rw-r--r--examples/qt3d/deferred-renderer-cpp/main.cpp15
-rw-r--r--examples/qt3d/deferred-renderer-qml/main.qml45
-rw-r--r--examples/qt3d/dynamicscene-cpp/boxentity.cpp5
-rw-r--r--examples/qt3d/dynamicscene-cpp/boxentity.h4
-rw-r--r--examples/qt3d/enabled-qml/main.qml43
-rw-r--r--examples/qt3d/gltf/Wine.qml43
-rw-r--r--examples/qt3d/gltf/main.qml8
-rw-r--r--examples/qt3d/gooch-qml/MyEntity.qml11
-rw-r--r--examples/qt3d/keyboardinput-qml/SphereEntity.qml17
-rw-r--r--examples/qt3d/keyboardinput-qml/main.qml5
-rw-r--r--examples/qt3d/loader-qml/CuboidEntity.qml19
-rw-r--r--examples/qt3d/loader-qml/SphereEntity.qml10
-rw-r--r--examples/qt3d/loader-qml/main.qml35
-rw-r--r--examples/qt3d/materials-cpp/barrel.cpp2
-rw-r--r--examples/qt3d/materials-cpp/houseplant.cpp35
-rw-r--r--examples/qt3d/materials-cpp/houseplant.h8
-rw-r--r--examples/qt3d/materials-cpp/main.cpp28
-rw-r--r--examples/qt3d/materials-cpp/planeentity.cpp14
-rw-r--r--examples/qt3d/materials-cpp/planeentity.h6
-rw-r--r--examples/qt3d/materials-cpp/renderableentity.cpp22
-rw-r--r--examples/qt3d/materials-cpp/renderableentity.h7
-rw-r--r--examples/qt3d/materials-cpp/rotatingtrefoilknot.cpp8
-rw-r--r--examples/qt3d/materials-cpp/trefoilknot.cpp80
-rw-r--r--examples/qt3d/materials-cpp/trefoilknot.h37
-rw-r--r--examples/qt3d/materials/Barrel.qml7
-rw-r--r--examples/qt3d/materials/Chest.qml7
-rw-r--r--examples/qt3d/materials/HousePlant.qml7
-rw-r--r--examples/qt3d/materials/PlaneEntity.qml13
-rw-r--r--examples/qt3d/materials/RenderableEntity.qml23
-rw-r--r--examples/qt3d/materials/TrefoilKnot.qml15
-rw-r--r--examples/qt3d/materials/main.qml2
-rw-r--r--examples/qt3d/mouseinput-qml/main.qml4
-rw-r--r--examples/qt3d/multiviewport/QuadViewportFrameGraph.qml80
-rw-r--r--examples/qt3d/multiviewport/SimpleCamera.qml61
-rw-r--r--examples/qt3d/multiviewport/main.qml186
-rw-r--r--examples/qt3d/multiviewport/multiviewport.qrc2
-rw-r--r--examples/qt3d/picking-qml/main.qml26
-rw-r--r--examples/qt3d/planets-qml/SolarSystem.qml312
-rw-r--r--examples/qt3d/plasma/main.qml18
-rw-r--r--examples/qt3d/playground-qml/DetailView.qml29
-rw-r--r--examples/qt3d/playground-qml/MainView.qml34
-rw-r--r--examples/qt3d/playground-qml/MyForwardRenderer.qml14
-rw-r--r--examples/qt3d/playground-qml/main.qml6
-rw-r--r--examples/qt3d/scene3d-loader/AnimatedEntity.qml35
-rw-r--r--examples/qt3d/scene3d-loader/Scene2.qml12
-rw-r--r--examples/qt3d/scene3d/AnimatedEntity.qml33
-rw-r--r--examples/qt3d/shadow-map-qml/AdsMaterial.qml2
-rw-r--r--examples/qt3d/shadow-map-qml/GroundPlane.qml4
-rw-r--r--examples/qt3d/shadow-map-qml/Light.qml2
-rw-r--r--examples/qt3d/shadow-map-qml/ShadowMapFrameGraph.qml2
-rw-r--r--examples/qt3d/shadow-map-qml/Toyplane.qml47
-rw-r--r--examples/qt3d/shadow-map-qml/Trefoil.qml18
-rw-r--r--examples/qt3d/shadow-map-qml/main.qml1
-rw-r--r--examples/qt3d/simple-cpp/main.cpp100
-rw-r--r--examples/qt3d/simple-qml/main.qml34
-rw-r--r--examples/qt3d/simple-shaders-qml/main.qml28
-rw-r--r--examples/qt3d/skybox/Skybox.qml3
-rw-r--r--examples/qt3d/tessellation-modes/BasicCamera.qml1
-rw-r--r--examples/qt3d/tessellation-modes/TessellatedQuad.qml15
-rw-r--r--examples/qt3d/tessellation-modes/TessellatedWireframeEffect.qml1
-rw-r--r--examples/qt3d/tessellation-modes/TessellatedWireframeMaterial.qml2
-rw-r--r--examples/qt3d/tessellation-modes/main.qml2
-rw-r--r--examples/qt3d/torus-qml/main.qml12
-rw-r--r--examples/qt3d/transparency-qml-scene3d/Scene.qml4
-rw-r--r--examples/qt3d/transparency-qml-scene3d/main.qml3
-rw-r--r--examples/qt3d/transparency-qml/main.qml4
-rw-r--r--examples/qt3d/wave/Background.qml12
-rw-r--r--examples/qt3d/wave/Wave.qml15
-rw-r--r--examples/qt3d/wave/main.qml1
-rw-r--r--examples/qt3d/wireframe/TrefoilKnot.qml27
-rw-r--r--examples/qt3d/wireframe/main.qml2
-rw-r--r--src/core/core-components/qcamera.cpp91
-rw-r--r--src/core/core-components/qcamera.h14
-rw-r--r--src/core/core-components/qcamera_p.h16
-rw-r--r--src/core/transforms/qtransform.cpp72
-rw-r--r--src/core/transforms/qtransform.h16
-rw-r--r--src/core/transforms/qtransform_p.h14
-rw-r--r--src/plugins/sceneparsers/assimp/assimpparser.cpp13
-rw-r--r--src/plugins/sceneparsers/gltf/gltfparser.cpp37
-rw-r--r--src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp5
-rw-r--r--src/quick3d/imports/render/defaults/qml/SkyboxEntity.qml3
-rw-r--r--src/quick3d/quick3d/items/items.pri2
-rw-r--r--src/quick3d/quick3d/items/quick3dtransform.cpp105
-rw-r--r--src/render/defaults/qskyboxentity.cpp5
-rw-r--r--src/render/defaults/qskyboxentity_p.h1
-rw-r--r--src/render/frontend/qboundingvolumedebug.cpp17
-rw-r--r--tests/auto/render/picking/tst_picking.cpp6
-rw-r--r--tests/auto/render/raycasting/tst_raycasting.cpp10
108 files changed, 1435 insertions, 1433 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 {
diff --git a/examples/qt3d/assimp/main.cpp b/examples/qt3d/assimp/main.cpp
index f0b8b6fbc..a637d47ae 100644
--- a/examples/qt3d/assimp/main.cpp
+++ b/examples/qt3d/assimp/main.cpp
@@ -50,6 +50,7 @@ class SceneHelper : public QObject
public:
Q_INVOKABLE QObject *findEntity(Qt3DRender::QSceneLoader *loader, const QString &name);
+ Q_INVOKABLE QObject *findComponent(Qt3DCore::QEntity *entity, const QString &componentMetatype);
Q_INVOKABLE void addListEntry(const QVariant &list, QObject *entry);
};
@@ -70,6 +71,19 @@ QObject *SceneHelper::findEntity(Qt3DRender::QSceneLoader *loader, const QString
return root->findChild<Qt3DCore::QEntity *>(name);
}
+QObject *SceneHelper::findComponent(Qt3DCore::QEntity *entity, const QString &componentMetatype)
+{
+ Q_ASSERT(entity);
+ Qt3DCore::QComponentList components = entity->components();
+ Q_FOREACH (Qt3DCore::QComponent *component, components) {
+ qDebug() << component->metaObject()->className();
+ if (component->metaObject()->className() == componentMetatype) {
+ return component;
+ }
+ }
+ return Q_NULLPTR;
+}
+
void SceneHelper::addListEntry(const QVariant &list, QObject *entry)
{
QQmlListReference ref = list.value<QQmlListReference>();
diff --git a/examples/qt3d/assimp/main.qml b/examples/qt3d/assimp/main.qml
index 2b5f953ea..5210d2041 100644
--- a/examples/qt3d/assimp/main.qml
+++ b/examples/qt3d/assimp/main.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
+import QtQuick 2.0 as Quick
import Qt3D.Core 2.0
import Qt3D.Render 2.0
import Qt3D.Examples 2.0
-import QtQuick 2.0 as Quick
Entity
{
@@ -94,15 +94,12 @@ Entity
}
Quick.Component {
- id: rot90Comp
- Rotate { axis: Qt.vector3d(1, 0, 0); angle: 90 }
- }
-
- Quick.Component {
id: animRotComp
- Rotate {
- axis: Qt.vector3d(0, 0, 1)
- Quick.NumberAnimation on angle {
+ Quick.QtObject {
+ id: rotationData
+ property real userAngle: 0.0
+ property vector3d axis: Qt.vector3d(0, 0, 1)
+ Quick.NumberAnimation on userAngle {
from: 0
to: 360
duration: 5000
@@ -112,12 +109,11 @@ Entity
}
Entity {
- components : [
+ components: [
Transform {
Rotate {angle : 90; axis : Qt.vector3d(0, 1, 0)}
},
- SceneLoader
- {
+ SceneLoader {
id: sceneLoader
source: "qrc:/assets/test_scene.dae"
onStatusChanged: {
@@ -144,30 +140,54 @@ Entity
}
}
- // Add an animated rotation transform.
+ // Add an animated rotation transform to make Suzanne orbit around.
e = sceneHelper.findEntity(sceneLoader, "Suzanne");
- for (var i = 0; i < e.components.length; ++i) {
- if (e.components[i].transforms !== undefined) {
- var t = e.components[i].transforms;
- sceneHelper.addListEntry(t, rot90Comp.createObject());
- sceneHelper.addListEntry(t, animRotComp.createObject());
- break;
- }
- }
+ var t = sceneHelper.findComponent(e, "Qt3DCore::QTransform");
+ if (!t)
+ return;
+
+ // Add object with animation data as a child
+ var suzanneAnim = animRotComp.createObject(t);
+
+ // Query the existing transformation. We will use parts of this in
+ // the replacement animation
+ var origTranslation = t.translation;
+ var origRotation = t.rotation;
+ var origScale = t.scale;
+ console.log("origTranslation = " + origTranslation);
+ console.log("origRotation = " + origRotation);
+ console.log("origScale = " + origScale);
+
+ // Make a deep copy of the original translation. This will not be updated when the
+ // transformation's translation property gets updated due to the animation.
+ var constantTranslation = Qt.vector3d(origTranslation.x, origTranslation.y, origTranslation.z);
+
+ t.matrix = Qt.binding(function() {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(suzanneAnim.userAngle, suzanneAnim.axis);
+ m.translate(constantTranslation);
+ m.rotate(90, Qt.vector3d(1, 0, 0));
+ m.scale(origScale);
+ return m;
+ })
}
}
- }]
+ }
+ ]
}
Entity {
- components : [
+ components: [
Transform {
- Scale { scale: 0.2 }
- Translate { dy: -15 }
+ scale: 0.2
+ translation: Qt.vector3d(0.0, -15.0, 0.0)
},
- SceneLoader
- {
+ SceneLoader {
source: "qrc:/assets/chest/Chest.obj"
- }]
+ }
+ ]
}
}
diff --git a/examples/qt3d/basicshapes-cpp/scenemodifier.cpp b/examples/qt3d/basicshapes-cpp/scenemodifier.cpp
index d67e70902..48977fc0b 100644
--- a/examples/qt3d/basicshapes-cpp/scenemodifier.cpp
+++ b/examples/qt3d/basicshapes-cpp/scenemodifier.cpp
@@ -53,19 +53,10 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity)
// TorusMesh Transform
//! [1]
- Qt3DCore::QScaleTransform *torusScale = new Qt3DCore::QScaleTransform();
- Qt3DCore::QTranslateTransform *torusTranslation = new Qt3DCore::QTranslateTransform();
- Qt3DCore::QRotateTransform *torusRotation = new Qt3DCore::QRotateTransform();
- Qt3DCore::QTransform *torusTransforms = new Qt3DCore::QTransform();
-
- torusScale->setScale3D(QVector3D(2.0f, 2.0f, 2.0f));
- torusTranslation->setTranslation(QVector3D(1.7f, 1.7f, 0.0f));
- torusRotation->setAngleDeg(25.0f);
- torusRotation->setAxis(QVector3D(0, 1, 0));
-
- torusTransforms->addTransform(torusRotation);
- torusTransforms->addTransform(torusTranslation);
- torusTransforms->addTransform(torusScale);
+ Qt3DCore::QTransform *torusTransform = new Qt3DCore::QTransform();
+ torusTransform->setScale(2.0f);
+ torusTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(0.0f, 1.0f, 0.0f), 25.0f));
+ torusTransform->setTranslation(QVector3D(4.0f, 4.0f, 0.0f));
//! [1]
//! [2]
@@ -78,7 +69,7 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity)
m_torusEntity = new Qt3DCore::QEntity(m_rootEntity);
m_torusEntity->addComponent(m_torus);
m_torusEntity->addComponent(torusMaterial);
- m_torusEntity->addComponent(torusTransforms);
+ m_torusEntity->addComponent(torusTransform);
//! [3]
// Cylinder shape data
@@ -89,19 +80,10 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity)
cylinder->setSlices(20);
// CylinderMesh Transform
- Qt3DCore::QScaleTransform *cylinderScale = new Qt3DCore::QScaleTransform();
- Qt3DCore::QRotateTransform *cylinderRotation = new Qt3DCore::QRotateTransform();
- Qt3DCore::QTranslateTransform *cylinderTranslation = new Qt3DCore::QTranslateTransform();
- Qt3DCore::QTransform *cylinderTransforms = new Qt3DCore::QTransform();
-
- cylinderScale->setScale3D(QVector3D(1.5f, 1.5f, 1.5f));
- cylinderTranslation->setTranslation(QVector3D(-2.6f, 2.4f, -1.5));
- cylinderRotation->setAngleDeg(45.0f);
- cylinderRotation->setAxis(QVector3D(1, 0, 0));
-
- cylinderTransforms->addTransform(cylinderTranslation);
- cylinderTransforms->addTransform(cylinderRotation);
- cylinderTransforms->addTransform(cylinderScale);
+ Qt3DCore::QTransform *cylinderTransform = new Qt3DCore::QTransform();
+ cylinderTransform->setScale(1.5f);
+ cylinderTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1.0f, 0.0f, 0.0f), 45.0f));
+ cylinderTransform->setTranslation(QVector3D(-4.0f, 4.0f, -1.5));
Qt3DRender::QPhongMaterial *cylinderMaterial = new Qt3DRender::QPhongMaterial();
cylinderMaterial->setDiffuse(QColor(QRgb(0x928327)));
@@ -110,21 +92,15 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity)
m_cylinderEntity = new Qt3DCore::QEntity(m_rootEntity);
m_cylinderEntity->addComponent(cylinder);
m_cylinderEntity->addComponent(cylinderMaterial);
- m_cylinderEntity->addComponent(cylinderTransforms);
+ m_cylinderEntity->addComponent(cylinderTransform);
// Cuboid shape data
Qt3DRender::QCuboidMesh *cuboid = new Qt3DRender::QCuboidMesh();
// CuboidMesh Transform
- Qt3DCore::QScaleTransform *cuboidScale = new Qt3DCore::QScaleTransform();
- Qt3DCore::QTranslateTransform *cuboidTranslation = new Qt3DCore::QTranslateTransform();
- Qt3DCore::QTransform *cuboidTransforms = new Qt3DCore::QTransform();
-
- cuboidScale->setScale3D(QVector3D(4.0f, 4.0f, 4.0f));
- cuboidTranslation->setTranslation(QVector3D(0.9f, -0.9f, 0.0f));
-
- cuboidTransforms->addTransform(cuboidTranslation);
- cuboidTransforms->addTransform(cuboidScale);
+ Qt3DCore::QTransform *cuboidTransform = new Qt3DCore::QTransform();
+ cuboidTransform->setScale(4.0f);
+ cuboidTransform->setTranslation(QVector3D(4.0f, -4.0f, 0.0f));
Qt3DRender::QPhongMaterial *cuboidMaterial = new Qt3DRender::QPhongMaterial();
cuboidMaterial->setDiffuse(QColor(QRgb(0x665423)));
@@ -133,7 +109,7 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity)
m_cuboidEntity = new Qt3DCore::QEntity(m_rootEntity);
m_cuboidEntity->addComponent(cuboid);
m_cuboidEntity->addComponent(cuboidMaterial);
- m_cuboidEntity->addComponent(cuboidTransforms);
+ m_cuboidEntity->addComponent(cuboidTransform);
// Sphere shape data
Qt3DRender::QSphereMesh *sphereMesh = new Qt3DRender::QSphereMesh();
@@ -142,15 +118,10 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity)
sphereMesh->setRadius(2);
// Sphere mesh transform
- Qt3DCore::QScaleTransform *sphereScale = new Qt3DCore::QScaleTransform();
- Qt3DCore::QTranslateTransform *sphereTranslation = new Qt3DCore::QTranslateTransform();
- Qt3DCore::QTransform *sphereTransforms = new Qt3DCore::QTransform();
-
- sphereScale->setScale3D(QVector3D(1.3f, 1.3f, 1.3f));
- sphereTranslation->setTranslation(QVector3D(-2.9f, -2.9f, 0.0f));
+ Qt3DCore::QTransform *sphereTransform = new Qt3DCore::QTransform();
- sphereTransforms->addTransform(sphereTranslation);
- sphereTransforms->addTransform(sphereScale);
+ sphereTransform->setScale(1.3f);
+ sphereTransform->setTranslation(QVector3D(-4.0f, -4.0f, 0.0f));
Qt3DRender::QPhongMaterial *sphereMaterial = new Qt3DRender::QPhongMaterial();
sphereMaterial->setDiffuse(QColor(QRgb(0xa69929)));
@@ -159,7 +130,7 @@ SceneModifier::SceneModifier(Qt3DCore::QEntity *rootEntity)
m_sphereEntity = new Qt3DCore::QEntity(m_rootEntity);
m_sphereEntity->addComponent(sphereMesh);
m_sphereEntity->addComponent(sphereMaterial);
- m_sphereEntity->addComponent(sphereTransforms);
+ m_sphereEntity->addComponent(sphereTransform);
}
SceneModifier::~SceneModifier()
diff --git a/examples/qt3d/bigmodel-qml/MyEntity.qml b/examples/qt3d/bigmodel-qml/MyEntity.qml
index 3e30b2fd3..df0dbd13d 100644
--- a/examples/qt3d/bigmodel-qml/MyEntity.qml
+++ b/examples/qt3d/bigmodel-qml/MyEntity.qml
@@ -39,13 +39,11 @@ import Qt3D.Render 2.0
Entity {
id: root
- property alias x: translation.dx
- property alias y: translation.dy
- property alias z: translation.dz
+ property alias position: transform.translation
property alias diffuse: material.diffuse
components: [
- Transform { Translate { id: translation } },
+ Transform { id: transform },
SphereMesh { radius: 2 },
PhongMaterial { id: material }
]
diff --git a/examples/qt3d/bigmodel-qml/main.qml b/examples/qt3d/bigmodel-qml/main.qml
index efb82375a..56081055e 100644
--- a/examples/qt3d/bigmodel-qml/main.qml
+++ b/examples/qt3d/bigmodel-qml/main.qml
@@ -76,8 +76,9 @@ Entity {
id: myEntity
property real _lightness: 0.2 + 0.7 / collection._rows * Math.floor(index / collection.cols)
property real _hue: (index % collection.cols) / collection.cols
- x: collection.spacing * (index % collection.cols - 0.5 * (collection.cols - 1))
- z: collection.spacing * (Math.floor(index / collection.cols) - 0.5 * collection._rows)
+ position: Qt.vector3d(collection.spacing * (index % collection.cols - 0.5 * (collection.cols - 1)),
+ 0.0,
+ collection.spacing * (Math.floor(index / collection.cols) - 0.5 * collection._rows));
diffuse: Qt.hsla( _hue, 0.5, _lightness, 1.0 )
}
}
diff --git a/examples/qt3d/bigscene-cpp/bigscene-cpp.pro b/examples/qt3d/bigscene-cpp/bigscene-cpp.pro
index 640c9f5fc..5dcaf3d0f 100644
--- a/examples/qt3d/bigscene-cpp/bigscene-cpp.pro
+++ b/examples/qt3d/bigscene-cpp/bigscene-cpp.pro
@@ -5,5 +5,9 @@
QT += 3dcore 3drender 3dinput
SOURCES += \
- main.cpp
+ main.cpp \
+ entity.cpp
+
+HEADERS += \
+ entity.h
diff --git a/examples/qt3d/bigscene-cpp/entity.cpp b/examples/qt3d/bigscene-cpp/entity.cpp
new file mode 100644
index 000000000..f42f6a18b
--- /dev/null
+++ b/examples/qt3d/bigscene-cpp/entity.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "entity.h"
+
+#include <Qt3DRender/QCylinderMesh>
+#include <Qt3DRender/QPhongMaterial>
+#include <Qt3DCore/QTransform>
+#include <QMatrix4x4>
+
+Entity::Entity(Qt3DCore::QNode *parent)
+ : QEntity(parent)
+ , m_transform(new Qt3DCore::QTransform())
+ , m_mesh(new Qt3DRender::QCylinderMesh())
+ , m_material(new Qt3DRender::QPhongMaterial())
+{
+ m_mesh->setRings(50.0f);
+ m_mesh->setSlices(30.0f);
+ m_mesh->setRadius(2.5f);
+ m_mesh->setLength(5.0f);
+
+ m_material->setAmbient(Qt::black);
+ m_material->setSpecular(Qt::white);
+ m_material->setShininess(150.0f);
+
+ addComponent(m_mesh);
+ addComponent(m_transform);
+ addComponent(m_material);
+}
+
+void Entity::updateTransform()
+{
+ QMatrix4x4 m;
+ m.translate(m_position);
+ m.rotate(m_phi, QVector3D(1.0f, 0.0f, 0.0f));
+ m.rotate(m_theta, QVector3D(0.0f, 0.0f, 1.0f));
+ m_transform->setMatrix(m);
+}
+
+float Entity::theta() const
+{
+ return m_theta;
+}
+
+float Entity::phi() const
+{
+ return m_phi;
+}
+
+QVector3D Entity::position() const
+{
+ return m_position;
+}
+
+QColor Entity::diffuseColor() const
+{
+ return m_material->diffuse();
+}
+
+void Entity::setTheta(float theta)
+{
+ if (m_theta == theta)
+ return;
+
+ m_theta = theta;
+ emit thetaChanged(theta);
+ updateTransform();
+}
+
+void Entity::setPhi(float phi)
+{
+ if (m_phi == phi)
+ return;
+
+ m_phi = phi;
+ emit phiChanged(phi);
+ updateTransform();
+}
+
+void Entity::setPosition(QVector3D position)
+{
+ if (m_position == position)
+ return;
+
+ m_position = position;
+ emit positionChanged(position);
+ updateTransform();
+}
+
+void Entity::setDiffuseColor(QColor diffuseColor)
+{
+ if (m_material->diffuse() == diffuseColor)
+ return;
+
+ m_material->setDiffuse(diffuseColor);
+ emit diffuseColorChanged(diffuseColor);
+}
diff --git a/src/quick3d/quick3d/items/quick3dtransform_p.h b/examples/qt3d/bigscene-cpp/entity.h
index 8f1ffe282..932190324 100644
--- a/src/quick3d/quick3d/items/quick3dtransform_p.h
+++ b/examples/qt3d/bigscene-cpp/entity.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt3D module of the Qt Toolkit.
@@ -34,54 +34,64 @@
**
****************************************************************************/
-#ifndef QT3D_QUICK_QUICK3DTRANSFORM_P_H
-#define QT3D_QUICK_QUICK3DTRANSFORM_P_H
+#ifndef ENTITY_H
+#define ENTITY_H
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QtGlobal>
-#include <QQmlListProperty>
-#include <Qt3DQuick/private/qt3dquick_global_p.h>
-#include <Qt3DCore/qtransform.h>
+#include <Qt3DCore/QEntity>
+#include <QtGui/QColor>
+#include <QtGui/QVector3D>
QT_BEGIN_NAMESPACE
namespace Qt3DCore {
-
class QTransform;
+}
+
+namespace Qt3DRender {
+class QCylinderMesh;
+class QPhongMaterial;
+}
-namespace Quick {
+QT_END_NAMESPACE
-class QT3DQUICKSHARED_PRIVATE_EXPORT Quick3DTransform : public QObject
+class Entity : public Qt3DCore::QEntity
{
Q_OBJECT
- Q_PROPERTY(QQmlListProperty<Qt3DCore::QAbstractTransform> transforms READ transformList)
- Q_CLASSINFO("DefaultProperty", "transforms")
+ Q_PROPERTY(float theta READ theta WRITE setTheta NOTIFY thetaChanged)
+ Q_PROPERTY(float phi READ phi WRITE setPhi NOTIFY phiChanged)
+ Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
+ Q_PROPERTY(QColor diffuseColor READ diffuseColor WRITE setDiffuseColor NOTIFY diffuseColorChanged)
+
public:
- explicit Quick3DTransform(QObject *parent = 0);
- QQmlListProperty<Qt3DCore::QAbstractTransform> transformList();
+ Entity(Qt3DCore::QNode *parent = 0);
- inline QTransform *parentTransform() const { return qobject_cast<Qt3DCore::QTransform *>(parent()); }
+ float theta() const;
+ float phi() const;
+ QVector3D position() const;
+ QColor diffuseColor() const;
-private:
- static void qmlAppendTransform(QQmlListProperty<Qt3DCore::QAbstractTransform> *list, Qt3DCore::QAbstractTransform *bar);
- static QAbstractTransform* transformAt(QQmlListProperty<Qt3DCore::QAbstractTransform> *list, int index);
- static int transformCount(QQmlListProperty<Qt3DCore::QAbstractTransform> *list);
- static void qmlClearTransforms(QQmlListProperty<Qt3DCore::QAbstractTransform> *list);
-};
+public slots:
+ void setTheta(float theta);
+ void setPhi(float phi);
+ void setPosition(QVector3D position);
+ void setDiffuseColor(QColor diffuseColor);
-} // namespace Quick
-} // namespace Qt3DCore
+signals:
+ void thetaChanged(float theta);
+ void phiChanged(float phi);
+ void positionChanged(QVector3D position);
+ void diffuseColorChanged(QColor diffuseColor);
-QT_END_NAMESPACE
+private:
+ void updateTransform();
+
+private:
+ Qt3DCore::QTransform *m_transform;
+ Qt3DRender::QCylinderMesh *m_mesh;
+ Qt3DRender::QPhongMaterial *m_material;
+ float m_theta;
+ float m_phi;
+ QVector3D m_position;
+};
-#endif // QT3D_QUICK_QUICK3DTRANSFORM_P_H
+#endif // ENTITY_H
diff --git a/examples/qt3d/bigscene-cpp/main.cpp b/examples/qt3d/bigscene-cpp/main.cpp
index e0dfee255..26eacb0d2 100644
--- a/examples/qt3d/bigscene-cpp/main.cpp
+++ b/examples/qt3d/bigscene-cpp/main.cpp
@@ -34,6 +34,8 @@
**
****************************************************************************/
+#include "entity.h"
+
#include <QGuiApplication>
#include <window.h>
@@ -93,57 +95,34 @@ int main(int ac, char **av)
frameGraph->setActiveFrameGraph(forwardRenderer);
root->addComponent(frameGraph);
-
const float radius = 100.0f;
const int max = 1000;
const float det = 1.0f / max;
+
// Scene
for (int i = 0; i < max; i++) {
- QEntity *e = new QEntity();
- Qt3DCore::QTransform *transform = new Qt3DCore::QTransform();
- QTranslateTransform *translation = new QTranslateTransform();
- QRotateTransform *rotateX = new QRotateTransform();
- QRotateTransform *rotateZ = new QRotateTransform();
- QCylinderMesh *mesh = new QCylinderMesh();
- QPhongMaterial *material = new QPhongMaterial();
- mesh->setRings(50.0f);
- mesh->setSlices(30.0f);
- mesh->setRadius(2.5f);
- mesh->setLength(5.0f);
-
+ Entity *e = new Entity();
const float angle = M_PI * 2.0f * i * det * 10.;
- material->setDiffuse(QColor(qFabs(qCos(angle)) * 255, 204, 75));
- material->setAmbient(Qt::black);
- material->setSpecular(Qt::white);
- material->setShininess(150.0f);
-
- translation->setTranslation(QVector3D(radius * qCos(angle), 200.* i * det, radius * qSin(angle)));
- rotateX->setAxis(QVector3D(1.0f, 0.0f, 0.0f));
- rotateZ->setAxis(QVector3D(0.0f, 0.0f, 1.0f));
- rotateX->setAngleDeg(30.0f * i);
- rotateZ->setAngleDeg(45.0f * i);
+ e->setDiffuseColor(QColor(qFabs(qCos(angle)) * 255, 204, 75));
+ e->setPosition(QVector3D(radius * qCos(angle), 200.* i * det, radius * qSin(angle)));
+ e->setTheta(30.0f * i);
+ e->setPhi(45.0f * i);
- QPropertyAnimation *animX = new QPropertyAnimation(rotateX, QByteArrayLiteral("angle"));
- animX->setDuration(2400 * i);
+ QPropertyAnimation *animX = new QPropertyAnimation(e, QByteArrayLiteral("theta"));
+ animX->setDuration(2400 * (i + 1));
animX->setStartValue(QVariant::fromValue(i * 30.0f));
animX->setEndValue(QVariant::fromValue((i + 1) * 390.0f));
animX->setLoopCount(-1);
animX->start();
- QPropertyAnimation *animZ = new QPropertyAnimation(rotateZ, QByteArrayLiteral("angle"));
- animZ->setDuration(2400 * i);
+ QPropertyAnimation *animZ = new QPropertyAnimation(e, QByteArrayLiteral("phi"));
+ animZ->setDuration(2400 * (i + 1));
animZ->setStartValue(QVariant::fromValue(i * 20.0f));
animZ->setEndValue(QVariant::fromValue((i + 1) * 380.0f));
animZ->setLoopCount(-1);
animZ->start();
- transform->addTransform(rotateX);
- transform->addTransform(rotateZ);
- transform->addTransform(translation);
- e->addComponent(transform);
- e->addComponent(mesh);
- e->addComponent(material);
e->setParent(root);
}
diff --git a/examples/qt3d/clip-planes-qml/ClipPlaneEntity.qml b/examples/qt3d/clip-planes-qml/ClipPlaneEntity.qml
index fdd3f803e..cccab558c 100644
--- a/examples/qt3d/clip-planes-qml/ClipPlaneEntity.qml
+++ b/examples/qt3d/clip-planes-qml/ClipPlaneEntity.qml
@@ -40,9 +40,8 @@ import Qt3D.Render 2.0
Entity {
id: root
property Material visualMaterial;
- property alias rotateAngle: _rotate.angle
- property alias rotateAxis: _rotate.axis
-
+ property real rotateAngle: 0.0
+ property vector3d rotateAxis: Qt.vector3d(1.0, 0.0, 0.0)
property vector3d center;
property vector3d normal;
readonly property vector4d equation: Qt.vector4d(normal.x,
@@ -61,8 +60,15 @@ Entity {
Transform {
id: transform
- Rotate { id: _rotate }
- Translate { translation: root.center }
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.translate(root.center);
+ m.rotate(root.rotateAngle, root.rotateAxis);
+ return m;
+ }
}
property Layer layer: Layer {
diff --git a/examples/qt3d/clip-planes-qml/ClippingPlanes.qml b/examples/qt3d/clip-planes-qml/ClippingPlanes.qml
index a5525f667..15ab76110 100644
--- a/examples/qt3d/clip-planes-qml/ClippingPlanes.qml
+++ b/examples/qt3d/clip-planes-qml/ClippingPlanes.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
diff --git a/examples/qt3d/clip-planes-qml/main.qml b/examples/qt3d/clip-planes-qml/main.qml
index c4436a2df..b7bcd5adb 100644
--- a/examples/qt3d/clip-planes-qml/main.qml
+++ b/examples/qt3d/clip-planes-qml/main.qml
@@ -34,6 +34,7 @@
**
****************************************************************************/
+import QtQuick 2.4 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
@@ -87,8 +88,8 @@ Entity {
}
property Transform transform: Transform {
- Translate { dx: 0 }
- Scale { scale: 3 }
+ translation: Qt.vector3d( 0.0, 0.0, 0.0 )
+ scale: 3
}
property Layer layer: Layer {
diff --git a/examples/qt3d/controls/Logo.qml b/examples/qt3d/controls/Logo.qml
index 1fe45340b..d4286ca7b 100644
--- a/examples/qt3d/controls/Logo.qml
+++ b/examples/qt3d/controls/Logo.qml
@@ -76,20 +76,15 @@ Entity {
Transform {
id: logoTransform
- Rotate {
- id: rotate_x
- angle: rotation_x.value
- axis: Qt.vector3d(1, 0, 0)
- }
- Rotate {
- id: rotate_y
- angle: rotation_y.value
- axis: Qt.vector3d(0, 1, 0)
- }
- Rotate {
- id: rotate_z
- angle: rotation_z.value
- axis: Qt.vector3d(0, 0, 1)
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(rotation_z.value, Qt.vector3d(0, 0, 1));
+ m.rotate(rotation_y.value, Qt.vector3d(0, 1, 0));
+ m.rotate(rotation_x.value, Qt.vector3d(1, 0, 0));
+ return m;
}
}
diff --git a/examples/qt3d/cpp_example/main.cpp b/examples/qt3d/cpp_example/main.cpp
index f02d716cc..3e47abc59 100644
--- a/examples/qt3d/cpp_example/main.cpp
+++ b/examples/qt3d/cpp_example/main.cpp
@@ -96,36 +96,24 @@ int main(int ac, char **av)
torusEntity->addComponent(torus);
// TorusMesh Transform
- Qt3DCore::QTranslateTransform *torusTranslation = new Qt3DCore::QTranslateTransform();
- Qt3DCore::QRotateTransform *torusRotation = new Qt3DCore::QRotateTransform();
Qt3DCore::QTransform *torusTransforms = new Qt3DCore::QTransform();
-
- torusTranslation->setTranslation(QVector3D(-5.0f, 3.5f, 2.0f));
- torusRotation->setAxis(QVector3D(1, 0, 0));
- torusRotation->setAngleDeg(35.0f);
- torusTransforms->addTransform(torusTranslation);
- torusTransforms->addTransform(torusRotation);
+ torusTransforms->setTranslation(QVector3D(-5.0f, 3.5f, 2.0f));
+ torusTransforms->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), 35.0f));
torusEntity->addComponent(torusTransforms);
// Scene file
Qt3DCore::QEntity *sceneEntity = new Qt3DCore::QEntity(rootEntity);
- Qt3DRender::QSceneLoader *scene = new Qt3DRender::QSceneLoader();
+ Qt3DRender::QSceneLoader *scene = new Qt3DRender::QSceneLoader();
scene->setObjectName(QStringLiteral("scene"));
Qt3DCore::QTransform *sceneTransform = new Qt3DCore::QTransform();
- Qt3DCore::QTranslateTransform *sceneTranslateTransform = new Qt3DCore::QTranslateTransform();
- sceneTranslateTransform->setDx(2.5);
- sceneTranslateTransform->setDy(0.5);
- sceneTranslateTransform->setDz(-10);
- sceneTransform->addTransform(sceneTranslateTransform);
+ sceneTransform->setTranslation(QVector3D(2.5f, 0.5f, -10.0f));
sceneEntity->addComponent(sceneTransform);
-// scene->setSource(":/assets/gltf/wine/wine.json");
scene->setSource(QUrl("qrc:/assets/test_scene.dae"));
sceneEntity->addComponent(scene);
// Camera
Qt3DCore::QCamera *cameraEntity = new Qt3DCore::QCamera(rootEntity);
cameraEntity->setObjectName(QStringLiteral("cameraEntity"));
-
cameraEntity->lens()->setPerspectiveProjection(60.0f, 16.0f/9.0f, 0.1f, 1000.0f);
cameraEntity->setPosition(QVector3D(-5, 0, -20.0f));
cameraEntity->setViewCenter(QVector3D(11, 0, 5));
diff --git a/examples/qt3d/custom-mesh-cpp/main.cpp b/examples/qt3d/custom-mesh-cpp/main.cpp
index 61be657a4..ed94f96a5 100644
--- a/examples/qt3d/custom-mesh-cpp/main.cpp
+++ b/examples/qt3d/custom-mesh-cpp/main.cpp
@@ -104,9 +104,7 @@ int main(int argc, char* argv[])
// Transform
Qt3DCore::QTransform *transform = new Qt3DCore::QTransform;
- Qt3DCore::QScaleTransform *scaleTransform = new Qt3DCore::QScaleTransform;
- scaleTransform->setScale(8.0f);
- transform->addTransform(scaleTransform);
+ transform->setScale(8.0f);
// Custom Mesh (TetraHedron)
Qt3DRender::QGeometryRenderer *customMeshRenderer = new Qt3DRender::QGeometryRenderer;
diff --git a/examples/qt3d/custom-mesh-qml/main.qml b/examples/qt3d/custom-mesh-qml/main.qml
index 34d14aa5f..05b45f793 100644
--- a/examples/qt3d/custom-mesh-qml/main.qml
+++ b/examples/qt3d/custom-mesh-qml/main.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
+import QtQuick 2.2 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-import QtQuick 2.2 as QQ2
Entity {
id: sceneRoot
@@ -207,16 +207,21 @@ Entity {
Transform {
id: meshTransform
- Scale { scale: 10 }
- Rotate {
- id: meshRotation
- axis: Qt.vector3d(0, 1, 0)
+ property real userAngle: 0.0
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(userAngle, Qt.vector3d(0, 1, 0));
+ m.scale(10);
+ return m;
}
}
QQ2.NumberAnimation {
- target: meshRotation
- property: "angle"
+ target: meshTransform
+ property: "userAngle"
duration: 10000
from: 0
to: 360
diff --git a/examples/qt3d/cylinder-cpp/main.cpp b/examples/qt3d/cylinder-cpp/main.cpp
index e65554f92..b6441314e 100644
--- a/examples/qt3d/cylinder-cpp/main.cpp
+++ b/examples/qt3d/cylinder-cpp/main.cpp
@@ -108,21 +108,14 @@ int main(int argc, char **argv)
cylinder->setSlices(20);
// CylinderMesh Transform
- Qt3DCore::QScaleTransform *cylinderScale = new Qt3DCore::QScaleTransform();
- Qt3DCore::QRotateTransform *cylinderRotation = new Qt3DCore::QRotateTransform();
- Qt3DCore::QTransform *cylinderTransforms = new Qt3DCore::QTransform();
-
- cylinderScale->setScale3D(QVector3D(1.5f, 1.5f, 1.5f));
- cylinderRotation->setAngleDeg(45.0f);
- cylinderRotation->setAxis(QVector3D(1, 0, 0));
-
- cylinderTransforms->addTransform(cylinderScale);
- cylinderTransforms->addTransform(cylinderRotation);
+ Qt3DCore::QTransform *cylinderTransform = new Qt3DCore::QTransform;
+ cylinderTransform->setScale(1.5f);
+ cylinderTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), 45.0f));
// Cylinder
Qt3DCore::QEntity *cylinderEntity = new Qt3DCore::QEntity(rootEntity);
cylinderEntity->addComponent(cylinder);
- cylinderEntity->addComponent(cylinderTransforms);
+ cylinderEntity->addComponent(cylinderTransform);
// Setting the FrameGraph
rootEntity->addComponent(frameGraph);
diff --git a/examples/qt3d/cylinder-qml/main.qml b/examples/qt3d/cylinder-qml/main.qml
index 2eda44a26..82d535e83 100644
--- a/examples/qt3d/cylinder-qml/main.qml
+++ b/examples/qt3d/cylinder-qml/main.qml
@@ -76,17 +76,20 @@ Entity {
Transform {
id: transform
- Scale { scale3D: Qt.vector3d(1.5, 1.5, 1.5) }
- Rotate {
- angle: 45
- axis: Qt.vector3d(1, 0, 0)
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(45, Qt.vector3d(1, 0, 0));
+ m.scale(1.5);
+ return m;
}
}
Material {
id: material
- effect : Effect {
- }
+ effect: Effect {}
}
Entity {
diff --git a/examples/qt3d/deferred-renderer-cpp/main.cpp b/examples/qt3d/deferred-renderer-cpp/main.cpp
index 086ba6677..111643ac4 100644
--- a/examples/qt3d/deferred-renderer-cpp/main.cpp
+++ b/examples/qt3d/deferred-renderer-cpp/main.cpp
@@ -138,16 +138,14 @@ int main(int ac, char **av)
sphereOneMaterial->setEffect(sceneEffect);
sphereOneMaterial->addParameter(new Qt3DRender::QParameter(QStringLiteral("meshColor"), QColor(Qt::blue)));
- Qt3DCore::QTranslateTransform *sphereOneTranslate = new Qt3DCore::QTranslateTransform();
- sphereOneTranslate->setDx(-10.0f);
- sphereOneTranslate->setDy(0.0f);
- sphereOneTranslate->setDz(25.0f);
+ Qt3DCore::QTransform *sphereOneTransform = new Qt3DCore::QTransform;
+ sphereOneTransform->setTranslation(QVector3D(-10.0f, 0.0f, 25.0f));
Qt3DRender::QPointLight *light2 = new Qt3DRender::QPointLight();
light2->setColor(Qt::white);
light2->setIntensity(1.5f);
- sphereOne->addComponent(new Qt3DCore::QTransform(sphereOneTranslate));
+ sphereOne->addComponent(sphereOneTransform);
sphereOne->addComponent(sphereOneMaterial);
sphereOne->addComponent(sphereMesh);
sphereOne->addComponent(sceneLayer);
@@ -183,12 +181,11 @@ int main(int ac, char **av)
finalEffect->gl2Technique()->addParameter(new Qt3DRender::QParameter(QStringLiteral("pointLights"), QVariant::fromValue(lightsData)));
screenQuadMaterial->setEffect(finalEffect);
- Qt3DCore::QRotateTransform *screenPlaneRotation = new Qt3DCore::QRotateTransform();
- screenPlaneRotation->setAngleDeg(90);
- screenPlaneRotation->setAxis(QVector3D(1.0f, 0.0f, 0.0f));
+ Qt3DCore::QTransform *screenPlaneTransform = new Qt3DCore::QTransform;
+ screenPlaneTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1.0f, 0.0f, 0.0f), 90.0f));
screenQuad->addComponent(quadLayer);
- screenQuad->addComponent(new Qt3DCore::QTransform(screenPlaneRotation));
+ screenQuad->addComponent(screenPlaneTransform);
screenQuad->addComponent(screenQuadMaterial);
screenQuad->addComponent(planeMesh);
diff --git a/examples/qt3d/deferred-renderer-qml/main.qml b/examples/qt3d/deferred-renderer-qml/main.qml
index d58bb6fab..304320c49 100644
--- a/examples/qt3d/deferred-renderer-qml/main.qml
+++ b/examples/qt3d/deferred-renderer-qml/main.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
+import QtQuick 2.0 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-import QtQuick 2.0 as QQ2
Entity {
id : root
@@ -69,9 +69,13 @@ Entity {
meshResolution: Qt.size(2, 2)
},
Transform { // We rotate the plane so that it faces us
- Rotate {
- axis : Qt.vector3d(1.0, 0.0, 0.0)
- angle : 90
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(90, Qt.vector3d(1, 0, 0));
+ return m;
}
},
Material {
@@ -135,16 +139,17 @@ Entity {
parameters : Parameter { name : "meshColor"; value : "dodgerblue" }
}
- property Transform transform : Transform {
- Translate{ dx: -10; dy: 0; dz : 5
- id: sphere1Translate
- }
+ property Transform transform: Transform {
+ id: sphere1Transform
+ property real x: -10.0
+ translation: Qt.vector3d(x, 0, 5)
}
+
QQ2.SequentialAnimation {
loops: QQ2.Animation.Infinite
running: false
- QQ2.NumberAnimation {target: sphere1Translate; property: "dx"; to: 6; duration: 2000 }
- QQ2.NumberAnimation {target: sphere1Translate; property: "dx"; to: -10; duration: 2000 }
+ QQ2.NumberAnimation { target: sphere1Transform; property: "x"; to: 6; duration: 2000 }
+ QQ2.NumberAnimation { target: sphere1Transform; property: "x"; to: -10; duration: 2000 }
}
property PointLight light : PointLight {
@@ -174,8 +179,8 @@ Entity {
intensity : 2.0
}
- property Transform transform : Transform {
- Translate{ dx: 5; dy: 0; dz : 5}
+ property Transform transform: Transform {
+ translation: Qt.vector3d(5, 0, 5)
}
components : [
@@ -199,15 +204,17 @@ Entity {
parameters : Parameter { name : "meshColor"; value : "red" }
}
- property Transform transform : Transform {
- Translate{ id: light3Translate; dx: 2; dy: 2; dz : 7
- }
+ property Transform transform: Transform {
+ id: light3Transform
+ property real y: 2.0
+ translation: Qt.vector3d(2, y, 7)
}
+
QQ2.SequentialAnimation {
loops: QQ2.Animation.Infinite
running: true
- QQ2.NumberAnimation {target: light3Translate; property: "dy"; to: 6; duration: 1000; easing.type: QQ2.Easing.InOutQuad }
- QQ2.NumberAnimation {target: light3Translate; property: "dy"; to: -6; duration: 1000; easing.type: QQ2.Easing.InOutQuint }
+ QQ2.NumberAnimation { target: light3Transform; property: "y"; to: 6; duration: 1000; easing.type: QQ2.Easing.InOutQuad }
+ QQ2.NumberAnimation { target: light3Transform; property: "y"; to: -6; duration: 1000; easing.type: QQ2.Easing.InOutQuint }
}
components: [
@@ -225,8 +232,8 @@ Entity {
color : "white"
intensity : 3.0
}
- property Transform transform : Transform {
- Translate{ dx: 5; dy: 2; dz : 7}
+ property Transform transform: Transform {
+ translation: Qt.vector3d(5, 2, 7)
}
components: [
diff --git a/examples/qt3d/dynamicscene-cpp/boxentity.cpp b/examples/qt3d/dynamicscene-cpp/boxentity.cpp
index c6f1df33c..3ab25fed0 100644
--- a/examples/qt3d/dynamicscene-cpp/boxentity.cpp
+++ b/examples/qt3d/dynamicscene-cpp/boxentity.cpp
@@ -41,14 +41,11 @@
BoxEntity::BoxEntity(QNode *parent)
: Qt3DCore::QEntity(parent)
, m_transform(new Qt3DCore::QTransform())
- , m_translate(new Qt3DCore::QTranslateTransform())
, m_mesh(new Qt3DRender::QCuboidMesh())
, m_material(new Qt3DRender::QPhongMaterial())
, m_angle(0.0f)
, m_radius(1.0f)
{
- m_transform->addTransform(m_translate);
-
connect(m_material, SIGNAL(diffuseChanged()), this, SIGNAL(diffuseColorChanged()));
m_material->setAmbient(Qt::gray);
m_material->setSpecular(Qt::white);
@@ -101,7 +98,7 @@ float BoxEntity::radius() const
void BoxEntity::updateTransformation()
{
- m_translate->setTranslation(QVector3D(qCos(m_angle) * m_radius,
+ m_transform->setTranslation(QVector3D(qCos(m_angle) * m_radius,
1.0f,
qSin(m_angle) * m_radius));
}
diff --git a/examples/qt3d/dynamicscene-cpp/boxentity.h b/examples/qt3d/dynamicscene-cpp/boxentity.h
index 53253d038..cd12bad36 100644
--- a/examples/qt3d/dynamicscene-cpp/boxentity.h
+++ b/examples/qt3d/dynamicscene-cpp/boxentity.h
@@ -39,8 +39,6 @@
#include <Qt3DCore/QEntity>
#include <Qt3DCore/QTransform>
-#include <Qt3DCore/QTranslateTransform>
-#include <Qt3DCore/QScaleTransform>
#include <Qt3DRender/QCuboidMesh>
#include <Qt3DRender/QPhongMaterial>
@@ -73,8 +71,6 @@ private:
void updateTransformation();
Qt3DCore::QTransform *m_transform;
- Qt3DCore::QTranslateTransform *m_translate;
- Qt3DCore::QScaleTransform *m_scale;
Qt3DRender::QCuboidMesh *m_mesh;
Qt3DRender::QPhongMaterial *m_material;
float m_angle;
diff --git a/examples/qt3d/enabled-qml/main.qml b/examples/qt3d/enabled-qml/main.qml
index 379c00d36..438491936 100644
--- a/examples/qt3d/enabled-qml/main.qml
+++ b/examples/qt3d/enabled-qml/main.qml
@@ -54,7 +54,7 @@ Entity {
}
CameraSelector {
- camera: basicCamera
+ camera: camera
enabled: counter !== 7
LayerFilter {
@@ -76,28 +76,17 @@ Entity {
}
}
- Entity {
- id: basicCamera
-
- Transform {
- id: basicCameraTransform
- LookAt {
- upVector: Qt.vector3d(0, 1, 0)
- viewCenter: Qt.vector3d(0, 0, 0)
- position: Qt.vector3d(0, 10, -10)
- }
- }
- components: [basicCameraTransform, cameraLens]
- }
-
- CameraLens {
- id: cameraLens
+ Camera {
+ id: camera
projectionType: CameraLens.PerspectiveProjection
fieldOfView: 45
aspectRatio: 16/9
nearPlane : 0.1
farPlane : 1000.0
enabled: counter !== 4
+ position: Qt.vector3d(0, 10, -10)
+ viewCenter: Qt.vector3d(0, 0, 0)
+ upVector: Qt.vector3d(0, 1, 0)
}
// Sphere
@@ -123,48 +112,48 @@ Entity {
Transform {
id: transform
+ property real x: 0.0
+ property real y: 0.0
+ property real z: 0.0
+ translation: Qt.vector3d(x, y, z)
enabled: counter !== 3
-
- Translate {
- id: translate
- }
}
QQ2.SequentialAnimation {
running: true
loops: QQ2.Animation.Infinite
QQ2.NumberAnimation {
- target: translate; property: "dx"
+ target: transform; property: "x"
from: 0; to: 5;
duration: 550
easing.type: QQ2.Easing.InOutQuad
}
QQ2.NumberAnimation {
- target: translate; property: "dy"
+ target: transform; property: "y"
from: 0; to: 5;
duration: 650
easing.type: QQ2.Easing.InOutQuad
}
QQ2.NumberAnimation {
- target: translate; property: "dz"
+ target: transform; property: "z"
from: 0; to: 5;
duration: 350
easing.type: QQ2.Easing.InOutQuad
}
QQ2.NumberAnimation {
- target: translate; property: "dx"
+ target: transform; property: "x"
from: 5; to: 0;
duration: 550
easing.type: QQ2.Easing.InOutQuad
}
QQ2.NumberAnimation {
- target: translate; property: "dy"
+ target: transform; property: "y"
from: 5; to: 0;
duration: 350
easing.type: QQ2.Easing.InOutQuad
}
QQ2.NumberAnimation {
- target: translate; property: "dz"
+ target: transform; property: "z"
from: 5; to: 0;
duration: 650
easing.type: QQ2.Easing.InOutQuad
diff --git a/examples/qt3d/gltf/Wine.qml b/examples/qt3d/gltf/Wine.qml
index 6e9b1a4c9..7a1506ba5 100644
--- a/examples/qt3d/gltf/Wine.qml
+++ b/examples/qt3d/gltf/Wine.qml
@@ -40,37 +40,28 @@ import Qt3D.Render 2.0
Entity {
id: root
- property alias x: wineTranslate.dx
- property alias y: wineTranslate.dy
- property alias z: wineTranslate.dz
- property alias angleX: rotateX.angle
- property alias angleY: rotateY.angle
- property alias angleZ: rotateZ.angle
- property alias scale: wineScale.scale
+ property vector3d position: Qt.vector3d(0, 0, 0)
+ property real angleX: 0
+ property real angleY: 0
+ property real angleZ: 0
+ property real scale: 1
components: [
Transform {
- Rotate {
- id: rotateX
- axis: Qt.vector3d(1, 0, 0)
- }
- Rotate {
- id: rotateY
- axis: Qt.vector3d(0, 1, 0)
- }
- Rotate {
- id: rotateZ
- axis: Qt.vector3d(0, 0, 1)
- }
- Translate {
- id: wineTranslate
- }
- Scale {
- id: wineScale
+ 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.angleX, Qt.vector3d(1, 0, 0))
+ m.rotate(root.angleY, Qt.vector3d(0, 1, 0))
+ m.rotate(root.angleZ, Qt.vector3d(0, 0, 1))
+ m.scale(root.scale);
+ return m;
}
},
- SceneLoader
- {
+ SceneLoader {
source: "qrc:/assets/gltf/wine/wine.gltf"
}
]
diff --git a/examples/qt3d/gltf/main.qml b/examples/qt3d/gltf/main.qml
index 87a05c15d..c244c24f8 100644
--- a/examples/qt3d/gltf/main.qml
+++ b/examples/qt3d/gltf/main.qml
@@ -50,7 +50,7 @@ Entity {
farPlane : 1000.0
position: Qt.vector3d( 0.0, 20.0, -120.0 )
upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
- viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
+ viewCenter: Qt.vector3d( 0.0, 10.0, 0.0 )
}
Configuration {
@@ -79,11 +79,7 @@ Entity {
Wine {
id: wineRack
- scale: 1
- x: -60.0
- y: -20.0
- z: 0.0
+ position: Qt.vector3d(-60.0, 0.0, 50.0)
angleX: 180
}
-
}
diff --git a/examples/qt3d/gooch-qml/MyEntity.qml b/examples/qt3d/gooch-qml/MyEntity.qml
index 49c5cf143..6e057c3ed 100644
--- a/examples/qt3d/gooch-qml/MyEntity.qml
+++ b/examples/qt3d/gooch-qml/MyEntity.qml
@@ -39,18 +39,13 @@ import Qt3D.Render 2.0
Entity {
id: root
- property alias x: translation.dx
- property alias y: translation.dy
- property alias z: translation.dz
- property alias scale: scaleTransform.scale
+ property alias position: transform.translation
+ property alias scale: transform.scale
property alias material: gooch
property alias source: mesh.source
components: [
- Transform {
- Translate { id: translation }
- Scale{ id: scaleTransform }
- },
+ Transform { id: transform },
Mesh { id: mesh },
GoochMaterial { id: gooch }
]
diff --git a/examples/qt3d/keyboardinput-qml/SphereEntity.qml b/examples/qt3d/keyboardinput-qml/SphereEntity.qml
index 4ed05dcd8..3f445cc2f 100644
--- a/examples/qt3d/keyboardinput-qml/SphereEntity.qml
+++ b/examples/qt3d/keyboardinput-qml/SphereEntity.qml
@@ -41,10 +41,7 @@ import QtQuick 2.3 as QQ2
Entity {
id: root
-
- property alias x: translate.dx
- property alias y: translate.dy
- property alias z: translate.dz
+ property alias position: transform.translation
property alias color: material.diffuse
property alias input: input
@@ -54,17 +51,13 @@ Entity {
Transform {
id: transform
+ scale: root.input.focus ? 2 : 1
- Scale {
- scale: root.input.focus ? 2 : 1
-
- QQ2.Behavior on scale {
- QQ2.NumberAnimation {
- duration: 250
- }
+ QQ2.Behavior on scale {
+ QQ2.NumberAnimation {
+ duration: 250
}
}
- Translate { id: translate }
}
KeyboardInput { id: input }
diff --git a/examples/qt3d/keyboardinput-qml/main.qml b/examples/qt3d/keyboardinput-qml/main.qml
index 65fbfe1f9..e943f190c 100644
--- a/examples/qt3d/keyboardinput-qml/main.qml
+++ b/examples/qt3d/keyboardinput-qml/main.qml
@@ -67,7 +67,7 @@ Entity {
SphereEntity {
id: sphere1
- x: -5
+ position: Qt.vector3d(-5, 0, 0)
color: "red"
input.onTabPressed: sphere2.input.focus = true
input.focus: true
@@ -76,7 +76,6 @@ Entity {
SphereEntity {
id: sphere2
- x: 0
color: "green"
input.onTabPressed: sphere3.input.focus = true
input.controller: keyboardController
@@ -84,7 +83,7 @@ Entity {
SphereEntity {
id: sphere3
- x: 5
+ position: Qt.vector3d(5, 0, 0)
color: "blue"
input.onTabPressed: sphere1.input.focus = true
input.controller: keyboardController
diff --git a/examples/qt3d/loader-qml/CuboidEntity.qml b/examples/qt3d/loader-qml/CuboidEntity.qml
index 71858e0f9..f355e30d3 100644
--- a/examples/qt3d/loader-qml/CuboidEntity.qml
+++ b/examples/qt3d/loader-qml/CuboidEntity.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 {
components: [ mesh, phongMaterial, transform ]
@@ -54,10 +54,15 @@ Entity {
Transform {
id: transform
- Scale { scale: 4 }
- Rotate {
- id: _rotate
- axis: Qt.vector3d(0.0, 1.0, 0.0)
+ property real userAngle: 0.0
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(userAngle, Qt.vector3d(0, 1, 0));
+ m.scale(4);
+ return m;
}
}
@@ -72,8 +77,8 @@ Entity {
}
QQ2.NumberAnimation {
- target: _rotate
- property: "angle"
+ target: transform
+ property: "userAngle"
duration: 750
loops: QQ2.Animation.Infinite
running: true
diff --git a/examples/qt3d/loader-qml/SphereEntity.qml b/examples/qt3d/loader-qml/SphereEntity.qml
index 9bad4c3a6..56be1eb07 100644
--- a/examples/qt3d/loader-qml/SphereEntity.qml
+++ b/examples/qt3d/loader-qml/SphereEntity.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 {
components: [ mesh, material, transform ]
@@ -48,11 +48,7 @@ Entity {
Transform {
id: transform
-
- Scale {
- id: _scale
- scale: 3
- }
+ scale: 3
}
QQ2.ColorAnimation {
@@ -66,7 +62,7 @@ Entity {
}
QQ2.NumberAnimation {
- target: _scale
+ target: transform
property: "scale"
duration: 1500
loops: QQ2.Animation.Infinite
diff --git a/examples/qt3d/loader-qml/main.qml b/examples/qt3d/loader-qml/main.qml
index ee1efaf4f..b9dd2ca12 100644
--- a/examples/qt3d/loader-qml/main.qml
+++ b/examples/qt3d/loader-qml/main.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
+import QtQuick 2.2 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-import QtQuick 2.2 as QQ2
Entity {
id: sceneRoot
@@ -81,10 +81,14 @@ Entity {
Transform {
id: torusTransform
- Scale { scale3D: Qt.vector3d(1.5, 1, 0.5) }
- Rotate {
- angle: 45
- axis: Qt.vector3d(1, 0, 0)
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(45, Qt.vector3d(1, 0, 0));
+ m.scale(Qt.vector3d(1.5, 1, 0.5));
+ return m;
}
}
@@ -112,18 +116,21 @@ Entity {
Transform {
id: revolutionTransform
- Translate {
- translation: Qt.vector3d(20, 0, 0)
- }
-
- Rotate {
- id: sphereRotation
- axis: Qt.vector3d(0, 1, 0)
+ property real userAngle: 0.0
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(userAngle, Qt.vector3d(0, 1, 0));
+ m.translate(Qt.vector3d(20, 0, 0));
+ return m;
}
}
+
QQ2.NumberAnimation {
- target: sphereRotation
- property: "angle"
+ target: revolutionTransform
+ property: "userAngle"
duration: 10000
from: 0
to: 360
diff --git a/examples/qt3d/materials-cpp/barrel.cpp b/examples/qt3d/materials-cpp/barrel.cpp
index fc86a9ab2..96a5e0c35 100644
--- a/examples/qt3d/materials-cpp/barrel.cpp
+++ b/examples/qt3d/materials-cpp/barrel.cpp
@@ -71,7 +71,7 @@ Barrel::Barrel(Qt3DCore::QNode *parent)
, m_specularTextureImage(new Qt3DRender::QTextureImage())
{
mesh()->setSource(QUrl(QStringLiteral("qrc:/assets/metalbarrel/metal_barrel.obj")));
- scaleTransform()->setScale(0.03f);
+ transform()->setScale(0.03f);
m_diffuseTexture->addTextureImage(m_diffuseTextureImage);
m_normalTexture->addTextureImage(m_normalTextureImage);
diff --git a/examples/qt3d/materials-cpp/houseplant.cpp b/examples/qt3d/materials-cpp/houseplant.cpp
index 55ee27c2c..12ce2ba37 100644
--- a/examples/qt3d/materials-cpp/houseplant.cpp
+++ b/examples/qt3d/materials-cpp/houseplant.cpp
@@ -62,7 +62,6 @@ HousePlant::HousePlant(Qt3DCore::QNode *parent)
, m_plantMaterial(new Qt3DRender::QNormalDiffuseMapAlphaMaterial())
, m_coverMaterial(new Qt3DRender::QNormalDiffuseMapMaterial())
, m_potImage(new Qt3DRender::QTextureImage())
-
, m_potNormalImage(new Qt3DRender::QTextureImage())
, m_plantImage(new Qt3DRender::QTextureImage())
, m_plantNormalImage(new Qt3DRender::QTextureImage())
@@ -71,7 +70,7 @@ HousePlant::HousePlant(Qt3DCore::QNode *parent)
, m_plantType(Bamboo)
, m_potShape(Cross)
{
- m_pot->scaleTransform()->setScale(0.03f);
+ m_pot->transform()->setScale(0.03f);
m_pot->addComponent(m_potMaterial);
m_plant->addComponent(m_plantMaterial);
m_cover->addComponent(m_coverMaterial);
@@ -130,44 +129,24 @@ HousePlant::Plant HousePlant::plantType() const
return m_plantType;
}
-void HousePlant::setX(float x)
-{
- m_pot->translateTransform()->setDx(x);
-}
-
-void HousePlant::setY(float y)
-{
- m_pot->translateTransform()->setDy(y);
-}
-
-void HousePlant::setZ(float z)
+void HousePlant::setPosition(const QVector3D &pos)
{
- m_pot->translateTransform()->setDz(z);
+ m_pot->transform()->setTranslation(pos);
}
void HousePlant::setScale(float scale)
{
- m_pot->scaleTransform()->setScale(scale);
-}
-
-float HousePlant::x() const
-{
- return m_pot->translateTransform()->dx();
-}
-
-float HousePlant::y() const
-{
- return m_pot->translateTransform()->dy();
+ m_pot->transform()->setScale(scale);
}
-float HousePlant::z() const
+QVector3D HousePlant::position() const
{
- return m_pot->translateTransform()->dz();
+ return m_pot->transform()->translation();
}
float HousePlant::scale() const
{
- return m_pot->scaleTransform()->scale();
+ return m_pot->transform()->scale();
}
void HousePlant::updatePotShape()
diff --git a/examples/qt3d/materials-cpp/houseplant.h b/examples/qt3d/materials-cpp/houseplant.h
index a49326dbd..15854d30a 100644
--- a/examples/qt3d/materials-cpp/houseplant.h
+++ b/examples/qt3d/materials-cpp/houseplant.h
@@ -71,14 +71,10 @@ public:
PotShape potShape() const;
Plant plantType() const;
- void setX(float x);
- void setY(float y);
- void setZ(float z);
+ void setPosition(const QVector3D &pos);
void setScale(float scale);
- float x() const;
- float y() const;
- float z() const;
+ QVector3D position() const;
float scale() const;
private:
diff --git a/examples/qt3d/materials-cpp/main.cpp b/examples/qt3d/materials-cpp/main.cpp
index 41fcf563e..db24f96fe 100644
--- a/examples/qt3d/materials-cpp/main.cpp
+++ b/examples/qt3d/materials-cpp/main.cpp
@@ -117,7 +117,7 @@ int main(int argc, char* argv[])
// Chest
RenderableEntity *chest = new RenderableEntity(sceneRoot);
- chest->scaleTransform()->setScale(0.03f);
+ chest->transform()->setScale(0.03f);
chest->mesh()->setSource(QUrl(QStringLiteral("qrc:/assets/chest/Chest.obj")));
Qt3DRender::QDiffuseMapMaterial *diffuseMapMaterial = new Qt3DRender::QDiffuseMapMaterial();
diffuseMapMaterial->setSpecular(QColor::fromRgbF(0.2f, 0.2f, 0.2f, 1.0f));
@@ -132,8 +132,8 @@ int main(int argc, char* argv[])
// TrefoilKnot
RotatingTrefoilKnot *trefoil = new RotatingTrefoilKnot(sceneRoot);
- trefoil->translateTransform()->setDy(3.5);
- trefoil->scaleTransform()->setScale(0.5f);
+ trefoil->setPosition(QVector3D(0.0f, 3.5f, 0.0f));
+ trefoil->setScale(0.5f);
Qt3DRender::QPhongMaterial *phongMaterial = new Qt3DRender::QPhongMaterial();
phongMaterial->setDiffuse(QColor(204, 205, 75)); // Safari Yellow #cccd4b
phongMaterial->setSpecular(Qt::white);
@@ -141,58 +141,58 @@ int main(int argc, char* argv[])
// Barrels
Barrel *basicBarrel = new Barrel(sceneRoot);
- basicBarrel->translateTransform()->setDx(8.0f);
+ basicBarrel->transform()->setTranslation(QVector3D(8.0f, 0.0f, 0.0f));
Barrel *rustyBarrel = new Barrel(sceneRoot);
rustyBarrel->setDiffuse(Barrel::RustDiffuse);
rustyBarrel->setSpecular(Barrel::RustSpecular);
rustyBarrel->setBumps(Barrel::HardBumps);
- rustyBarrel->translateTransform()->setDx(10.0f);
+ rustyBarrel->transform()->setTranslation(QVector3D(10.0f, 0.0f, 0.0f));
Barrel *blueBarrel = new Barrel(sceneRoot);
blueBarrel->setDiffuse(Barrel::Blue);
blueBarrel->setBumps(Barrel::MiddleBumps);
- blueBarrel->translateTransform()->setDx(12.0f);
+ blueBarrel->transform()->setTranslation(QVector3D(12.0f, 0.0f, 0.0f));
Barrel *greenBarrel = new Barrel(sceneRoot);
greenBarrel->setDiffuse(Barrel::Green);
greenBarrel->setBumps(Barrel::SoftBumps);
- greenBarrel->translateTransform()->setDx(14.0f);
+ greenBarrel->transform()->setTranslation(QVector3D(14.0f, 0.0f, 0.0f));
Barrel *stainlessBarrel = new Barrel(sceneRoot);
stainlessBarrel->setDiffuse(Barrel::StainlessSteelDiffuse);
stainlessBarrel->setBumps(Barrel::NoBumps);
stainlessBarrel->setSpecular(Barrel::StainlessSteelSpecular);
stainlessBarrel->setShininess(150.0f);
- stainlessBarrel->translateTransform()->setDx(16);
+ stainlessBarrel->transform()->setTranslation(QVector3D(16.0f, 0.0f, 0.0f));
// Plants
HousePlant *squareBamboo = new HousePlant(sceneRoot);
squareBamboo->setPotShape(HousePlant::Square);
- squareBamboo->setX(4.0f);
+ squareBamboo->setPosition(QVector3D(4.0f, 0.0f, 0.0f));
HousePlant *trianglePalm = new HousePlant(sceneRoot);
trianglePalm->setPlantType(HousePlant::Palm);
trianglePalm->setPotShape(HousePlant::Triangle);
- trianglePalm->setZ(4.0f);
+ trianglePalm->setPosition(QVector3D(0.0f, 0.0f, 4.0f));
HousePlant *spherePine = new HousePlant(sceneRoot);
spherePine->setPlantType(HousePlant::Pine);
spherePine->setPotShape(HousePlant::Sphere);
- spherePine->setX(-4.0f);
+ spherePine->setPosition(QVector3D(-4.0f, 0.0f, 0.0f));
HousePlant *crossSpikes = new HousePlant(sceneRoot);
crossSpikes->setPlantType(HousePlant::Spikes);
- crossSpikes->setZ(-4.0f);
+ crossSpikes->setPosition(QVector3D(0.0f, 0.0f, -4.0f));
HousePlant *crossPalm = new HousePlant(sceneRoot);
crossPalm->setPlantType(HousePlant::Palm);
- crossPalm->setZ(-8.0f);
+ crossPalm->setPosition(QVector3D(0.0f, 0.0f, -8.0f));
crossPalm->setScale(0.05f);
HousePlant *crossShrub = new HousePlant(sceneRoot);
crossShrub->setPlantType(HousePlant::Shrub);
- crossShrub->setZ(8.0f);
+ crossShrub->setPosition(QVector3D(0.0f, 0.0f, 8.0f));
crossShrub->setScale(0.05f);
engine.setRootEntity(sceneRoot);
diff --git a/examples/qt3d/materials-cpp/planeentity.cpp b/examples/qt3d/materials-cpp/planeentity.cpp
index 5faa2186e..a3785bbf0 100644
--- a/examples/qt3d/materials-cpp/planeentity.cpp
+++ b/examples/qt3d/materials-cpp/planeentity.cpp
@@ -45,11 +45,7 @@ PlaneEntity::PlaneEntity(Qt3DCore::QNode *parent)
: Qt3DCore::QEntity(new Qt3DCore::QEntity(parent))
, m_mesh(new Qt3DRender::QPlaneMesh())
, m_transform(new Qt3DCore::QTransform())
- , m_scaleTransform(new Qt3DCore::QScaleTransform())
- , m_translateTransform(new Qt3DCore::QTranslateTransform())
{
- m_transform->addTransform(m_translateTransform);
- m_transform->addTransform(m_scaleTransform);
addComponent(m_mesh);
addComponent(m_transform);
}
@@ -58,16 +54,6 @@ PlaneEntity::~PlaneEntity()
{
}
-Qt3DCore::QScaleTransform *PlaneEntity::scaleTransform() const
-{
- return m_scaleTransform;
-}
-
-Qt3DCore::QTranslateTransform *PlaneEntity::translateTransform() const
-{
- return m_translateTransform;
-}
-
Qt3DRender::QPlaneMesh *PlaneEntity::mesh() const
{
return m_mesh;
diff --git a/examples/qt3d/materials-cpp/planeentity.h b/examples/qt3d/materials-cpp/planeentity.h
index 83f6b0213..768f9da5f 100644
--- a/examples/qt3d/materials-cpp/planeentity.h
+++ b/examples/qt3d/materials-cpp/planeentity.h
@@ -39,8 +39,6 @@
#include <Qt3DCore/QEntity>
#include <Qt3DCore/QTransform>
-#include <Qt3DCore/QScaleTransform>
-#include <Qt3DCore/QTranslateTransform>
#include <Qt3DRender/QPlaneMesh>
class PlaneEntity : public Qt3DCore::QEntity
@@ -49,15 +47,11 @@ public:
PlaneEntity(Qt3DCore::QNode *parent = 0);
~PlaneEntity();
- Qt3DCore::QScaleTransform *scaleTransform() const;
- Qt3DCore::QTranslateTransform *translateTransform() const;
Qt3DRender::QPlaneMesh *mesh() const;
private:
Qt3DRender::QPlaneMesh *m_mesh;
Qt3DCore::QTransform *m_transform;
- Qt3DCore::QScaleTransform *m_scaleTransform;
- Qt3DCore::QTranslateTransform *m_translateTransform;
};
#endif // PLANEENTITY_H
diff --git a/examples/qt3d/materials-cpp/renderableentity.cpp b/examples/qt3d/materials-cpp/renderableentity.cpp
index 1d100c686..8c4bad85c 100644
--- a/examples/qt3d/materials-cpp/renderableentity.cpp
+++ b/examples/qt3d/materials-cpp/renderableentity.cpp
@@ -40,20 +40,14 @@ RenderableEntity::RenderableEntity(Qt3DCore::QNode *parent)
: Qt3DCore::QEntity(parent)
, m_mesh(new Qt3DRender::QMesh())
, m_transform(new Qt3DCore::QTransform())
- , m_rotateTransform(new Qt3DCore::QRotateTransform())
- , m_scaleTransform(new Qt3DCore::QScaleTransform())
- , m_translateTransform(new Qt3DCore::QTranslateTransform())
{
- m_transform->addTransform(m_rotateTransform);
- m_transform->addTransform(m_scaleTransform);
- m_transform->addTransform(m_translateTransform);
addComponent(m_mesh);
addComponent(m_transform);
}
RenderableEntity::~RenderableEntity()
{
-
+ QNode::cleanup();
}
Qt3DRender::QMesh *RenderableEntity::mesh() const
@@ -61,17 +55,7 @@ Qt3DRender::QMesh *RenderableEntity::mesh() const
return m_mesh;
}
-Qt3DCore::QScaleTransform *RenderableEntity::scaleTransform() const
-{
- return m_scaleTransform;
-}
-
-Qt3DCore::QTranslateTransform *RenderableEntity::translateTransform() const
-{
- return m_translateTransform;
-}
-
-Qt3DCore::QRotateTransform *RenderableEntity::rotateTransform() const
+Qt3DCore::QTransform *RenderableEntity::transform() const
{
- return m_rotateTransform;
+ return m_transform;
}
diff --git a/examples/qt3d/materials-cpp/renderableentity.h b/examples/qt3d/materials-cpp/renderableentity.h
index 8d0b75215..85499226f 100644
--- a/examples/qt3d/materials-cpp/renderableentity.h
+++ b/examples/qt3d/materials-cpp/renderableentity.h
@@ -51,16 +51,11 @@ public:
~RenderableEntity();
Qt3DRender::QMesh *mesh() const;
- Qt3DCore::QScaleTransform *scaleTransform() const;
- Qt3DCore::QTranslateTransform *translateTransform() const;
- Qt3DCore::QRotateTransform *rotateTransform() const;
+ Qt3DCore::QTransform *transform() const;
private:
Qt3DRender::QMesh *m_mesh;
Qt3DCore::QTransform *m_transform;
- Qt3DCore::QRotateTransform *m_rotateTransform;
- Qt3DCore::QScaleTransform *m_scaleTransform;
- Qt3DCore::QTranslateTransform *m_translateTransform;
};
#endif // RENDERABLEENTITY_H
diff --git a/examples/qt3d/materials-cpp/rotatingtrefoilknot.cpp b/examples/qt3d/materials-cpp/rotatingtrefoilknot.cpp
index b27abcd36..bbe7f8161 100644
--- a/examples/qt3d/materials-cpp/rotatingtrefoilknot.cpp
+++ b/examples/qt3d/materials-cpp/rotatingtrefoilknot.cpp
@@ -45,16 +45,16 @@ RotatingTrefoilKnot::RotatingTrefoilKnot(Qt3DCore::QNode *parent)
m_thetaAnimation->setStartValue(0.0f);
m_thetaAnimation->setEndValue(360.0f);
m_thetaAnimation->setLoopCount(-1);
- m_thetaAnimation->setTargetObject(xaxisRotateTransform());
- m_thetaAnimation->setPropertyName("angle");
+ m_thetaAnimation->setTargetObject(this);
+ m_thetaAnimation->setPropertyName("phi");
m_thetaAnimation->start();
m_phiAnimation->setDuration(2000);
m_phiAnimation->setStartValue(0.0f);
m_phiAnimation->setEndValue(360.0f);
m_phiAnimation->setLoopCount(-1);
- m_phiAnimation->setTargetObject(yaxisRotateTransform());
- m_phiAnimation->setPropertyName("angle");
+ m_phiAnimation->setTargetObject(this);
+ m_phiAnimation->setPropertyName("theta");
m_phiAnimation->start();
}
diff --git a/examples/qt3d/materials-cpp/trefoilknot.cpp b/examples/qt3d/materials-cpp/trefoilknot.cpp
index 610a972bd..e0da64987 100644
--- a/examples/qt3d/materials-cpp/trefoilknot.cpp
+++ b/examples/qt3d/materials-cpp/trefoilknot.cpp
@@ -40,20 +40,10 @@ TrefoilKnot::TrefoilKnot(Qt3DCore::QNode *parent)
: Qt3DCore::QEntity(parent)
, m_mesh(new Qt3DRender::QMesh())
, m_transform(new Qt3DCore::QTransform())
- , m_scaleTransform(new Qt3DCore::QScaleTransform())
- , m_xaxisRotation(new Qt3DCore::QRotateTransform())
- , m_yaxisRotation(new Qt3DCore::QRotateTransform())
- , m_translateTransform(new Qt3DCore::QTranslateTransform())
+ , m_position()
+ , m_scale(1.0f)
{
m_mesh->setSource(QUrl("qrc:/assets/obj/trefoil.obj"));
- m_xaxisRotation->setAxis(QVector3D(1.0f, 0.0f, 0.0f));
- m_yaxisRotation->setAxis(QVector3D(0.0f, 1.0f, 0.0f));
-
- m_transform->addTransform(m_scaleTransform);
- m_transform->addTransform(m_xaxisRotation);
- m_transform->addTransform(m_yaxisRotation);
- m_transform->addTransform(m_translateTransform);
-
addComponent(m_mesh);
addComponent(m_transform);
}
@@ -62,22 +52,72 @@ TrefoilKnot::~TrefoilKnot()
{
}
-Qt3DCore::QScaleTransform *TrefoilKnot::scaleTransform() const
+void TrefoilKnot::updateTransform()
+{
+ QMatrix4x4 m;
+ m.translate(m_position);
+ m.rotate(m_phi, QVector3D(1.0f, 0.0f, 0.0f));
+ m.rotate(m_phi, QVector3D(0.0f, 1.0f, 0.0f));
+ m.scale(m_scale);
+ m_transform->setMatrix(m);
+}
+
+float TrefoilKnot::theta() const
{
- return m_scaleTransform;
+ return m_theta;
}
-Qt3DCore::QRotateTransform *TrefoilKnot::xaxisRotateTransform() const
+float TrefoilKnot::phi() const
{
- return m_xaxisRotation;
+ return m_phi;
}
-Qt3DCore::QRotateTransform *TrefoilKnot::yaxisRotateTransform() const
+QVector3D TrefoilKnot::position() const
{
- return m_yaxisRotation;
+ return m_position;
}
-Qt3DCore::QTranslateTransform *TrefoilKnot::translateTransform() const
+float TrefoilKnot::scale() const
{
- return m_translateTransform;
+ return m_scale;
+}
+
+void TrefoilKnot::setTheta(float theta)
+{
+ if (m_theta == theta)
+ return;
+
+ m_theta = theta;
+ emit thetaChanged(theta);
+ updateTransform();
+}
+
+void TrefoilKnot::setPhi(float phi)
+{
+ if (m_phi == phi)
+ return;
+
+ m_phi = phi;
+ emit phiChanged(phi);
+ updateTransform();
+}
+
+void TrefoilKnot::setPosition(QVector3D position)
+{
+ if (m_position == position)
+ return;
+
+ m_position = position;
+ emit positionChanged(position);
+ updateTransform();
+}
+
+void TrefoilKnot::setScale(float scale)
+{
+ if (m_scale == scale)
+ return;
+
+ m_scale = scale;
+ emit scaleChanged(scale);
+ updateTransform();
}
diff --git a/examples/qt3d/materials-cpp/trefoilknot.h b/examples/qt3d/materials-cpp/trefoilknot.h
index 1ffd1baf1..ff4e921da 100644
--- a/examples/qt3d/materials-cpp/trefoilknot.h
+++ b/examples/qt3d/materials-cpp/trefoilknot.h
@@ -46,22 +46,43 @@
class TrefoilKnot : public Qt3DCore::QEntity
{
+ Q_OBJECT
+ Q_PROPERTY(float theta READ theta WRITE setTheta NOTIFY thetaChanged)
+ Q_PROPERTY(float phi READ phi WRITE setPhi NOTIFY phiChanged)
+ Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scaleChanged)
+ Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
+
public:
explicit TrefoilKnot(Qt3DCore::QNode *parent = 0);
~TrefoilKnot();
- Qt3DCore::QScaleTransform *scaleTransform() const;
- Qt3DCore::QRotateTransform *xaxisRotateTransform() const;
- Qt3DCore::QRotateTransform *yaxisRotateTransform() const;
- Qt3DCore::QTranslateTransform *translateTransform() const;
+ float theta() const;
+ float phi() const;
+ QVector3D position() const;
+ float scale() const;
+
+public slots:
+ void setTheta(float theta);
+ void setPhi(float phi);
+ void setPosition(QVector3D position);
+ void setScale(float scale);
+
+signals:
+ void thetaChanged(float theta);
+ void phiChanged(float phi);
+ void positionChanged(QVector3D position);
+ void scaleChanged(float scale);
+
+protected:
+ void updateTransform();
private:
Qt3DRender::QMesh *m_mesh;
Qt3DCore::QTransform *m_transform;
- Qt3DCore::QScaleTransform *m_scaleTransform;
- Qt3DCore::QRotateTransform *m_xaxisRotation;
- Qt3DCore::QRotateTransform *m_yaxisRotation;
- Qt3DCore::QTranslateTransform *m_translateTransform;
+ float m_theta;
+ float m_phi;
+ QVector3D m_position;
+ float m_scale;
};
#endif // TREFOILKNOT_H
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
diff --git a/examples/qt3d/mouseinput-qml/main.qml b/examples/qt3d/mouseinput-qml/main.qml
index e05359ebf..2d9a8a138 100644
--- a/examples/qt3d/mouseinput-qml/main.qml
+++ b/examples/qt3d/mouseinput-qml/main.qml
@@ -85,9 +85,7 @@ Entity {
property real scaleFactor: 1.0
property Transform transform: Transform {
- Scale {
- scale: sphere1.scaleFactor
- }
+ scale: sphere1.scaleFactor
}
property MouseInput mouseInput : MouseInput {
diff --git a/examples/qt3d/multiviewport/QuadViewportFrameGraph.qml b/examples/qt3d/multiviewport/QuadViewportFrameGraph.qml
new file mode 100644
index 000000000..2011aaf4d
--- /dev/null
+++ b/examples/qt3d/multiviewport/QuadViewportFrameGraph.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D.Core 2.0
+import Qt3D.Render 2.0
+
+FrameGraph {
+ id: quadViewportFrameGraph
+
+ property alias topLeftCamera: cameraSelectorTopLeftViewport.camera;
+ property alias topRightCamera: cameraSelectorTopRightViewport.camera;
+ property alias bottomLeftCamera: cameraSelectorBottomLeftViewport.camera;
+ property alias bottomRightCamera: cameraSelectorBottomRightViewport.camera;
+
+ Viewport {
+ id: mainViewport
+ rect: Qt.rect(0, 0, 1, 1)
+
+ ClearBuffer {
+ buffers: ClearBuffer.ColorDepthBuffer
+ }
+
+ Viewport {
+ id: topLeftViewport
+ rect: Qt.rect(0, 0, 0.5, 0.5)
+ CameraSelector { id: cameraSelectorTopLeftViewport }
+ }
+
+ Viewport {
+ id: topRightViewport
+ rect: Qt.rect(0.5, 0, 0.5, 0.5)
+ CameraSelector { id: cameraSelectorTopRightViewport }
+ }
+
+ Viewport {
+ id: bottomLeftViewport
+ rect: Qt.rect(0, 0.5, 0.5, 0.5)
+ CameraSelector { id: cameraSelectorBottomLeftViewport }
+ }
+
+ Viewport {
+ id: bottomRightViewport
+ rect: Qt.rect(0.5, 0.5, 0.5, 0.5)
+ CameraSelector { id: cameraSelectorBottomRightViewport }
+ }
+ }
+}
diff --git a/examples/qt3d/multiviewport/SimpleCamera.qml b/examples/qt3d/multiviewport/SimpleCamera.qml
new file mode 100644
index 000000000..cb570eb7b
--- /dev/null
+++ b/examples/qt3d/multiviewport/SimpleCamera.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D.Core 2.0
+import Qt3D.Render 2.0
+
+Entity {
+ id: root
+
+ property vector3d position: Qt.vector3d(0.0, 0.0, 10.0)
+ property vector3d viewCenter: Qt.vector3d(0.0, 0.0, 0.0)
+ property vector3d upVector: Qt.vector3d(0.0, 1.0, 0.0)
+ property CameraLens lens: null
+
+ components: [lens, transform]
+
+ Transform {
+ id: transform
+ 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, root.upVector);
+ return m;
+ }
+ }
+}
diff --git a/examples/qt3d/multiviewport/main.qml b/examples/qt3d/multiviewport/main.qml
index 69d6b98ca..9c4626eb4 100644
--- a/examples/qt3d/multiviewport/main.qml
+++ b/examples/qt3d/multiviewport/main.qml
@@ -38,150 +38,98 @@ import QtQuick 2.0
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-
Entity {
- id : rootNode
+ id: rootNode
+ components: [quadViewportFrameGraph]
- CameraLens {
- id : cameraLens
- projectionType: CameraLens.PerspectiveProjection
- fieldOfView: 45
- aspectRatio: 16/9
- nearPlane : 0.01
- farPlane : 1000.0
- } // cameraLens
+ QuadViewportFrameGraph {
+ id: quadViewportFrameGraph
+ topLeftCamera: cameraSet.cameras[0]
+ topRightCamera: cameraSet.cameras[1]
+ bottomLeftCamera: cameraSet.cameras[2]
+ bottomRightCamera: cameraSet.cameras[3]
+ }
Entity {
- id : sceneRoot
- components: [frameGraph]
- property real rotationAngle : 0
-
- SequentialAnimation {
- running : true
- loops: Animation.Infinite
- NumberAnimation {target : sceneRoot; property : "rotationAngle"; to : 360; duration : 2000;}
- }
-
- property var cameras : [cameraViewport1, cameraViewport2, cameraViewport3, cameraViewport4]
+ id: cameraSet
+ property var cameras: [camera1, camera2, camera3, camera4]
Timer {
- running : true
- interval : 10000
- repeat : true
- property int count : 0
- onTriggered:
- {
- cameraSelectorTopLeftViewport.camera = sceneRoot.cameras[count++ % 4];
- cameraSelectorTopRightViewport.camera = sceneRoot.cameras[count % 4];
- cameraSelectorBottomLeftViewport.camera = sceneRoot.cameras[(count + 1) % 4];
- cameraSelectorBottomRightViewport.camera = sceneRoot.cameras[(count + 2) % 4];
+ running: true
+ interval: 10000
+ repeat: true
+ property int count: 0
+ onTriggered: {
+ quadViewportFrameGraph.topLeftCamera = cameraSet.cameras[count++ % 4];
+ quadViewportFrameGraph.topRightCamera = cameraSet.cameras[count % 4];
+ quadViewportFrameGraph.bottomLeftCamera = cameraSet.cameras[(count + 1) % 4];
+ quadViewportFrameGraph.bottomRightCamera = cameraSet.cameras[(count + 2) % 4];
}
}
- FrameGraph {
- id : frameGraph
-
- Viewport {
- id : mainViewport
- rect: Qt.rect(0, 0, 1, 1)
-
- ClearBuffer {
- buffers : ClearBuffer.ColorDepthBuffer
- }
-
- Viewport {
- id : topLeftViewport
- rect : Qt.rect(0, 0, 0.5, 0.5)
- CameraSelector {id : cameraSelectorTopLeftViewport; camera : sceneRoot.cameras[0]}
- }
-
- Viewport {
- id : topRightViewport
- rect : Qt.rect(0.5, 0, 0.5, 0.5)
- CameraSelector {id : cameraSelectorTopRightViewport; camera : sceneRoot.cameras[1]}
- }
-
- Viewport {
- id : bottomLeftViewport
- rect : Qt.rect(0, 0.5, 0.5, 0.5)
- CameraSelector {id : cameraSelectorBottomLeftViewport; camera : sceneRoot.cameras[2]}
- }
+ CameraLens {
+ id : cameraLens
+ projectionType: CameraLens.PerspectiveProjection
+ fieldOfView: 45
+ aspectRatio: 16/9
+ nearPlane : 0.01
+ farPlane : 1000.0
+ }
- Viewport {
- id : bottomRightViewport
- rect : Qt.rect(0.5, 0.5, 0.5, 0.5)
- CameraSelector {id : cameraSelectorBottomRightViewport; camera : sceneRoot.cameras[3]}
- }
+ SimpleCamera {
+ id: camera1
+ lens: cameraLens
+ position: Qt.vector3d( 0.0, 0.0, -20.0 )
+ }
- } // mainViewport
- } // frameGraph
+ SimpleCamera {
+ id: camera2
+ lens: cameraLens
+ position: Qt.vector3d( 0.0, 0.0, 20.0 )
+ viewCenter: Qt.vector3d( -3.0, 0.0, 10.0 )
+ }
- Entity {
- id : cameraViewport1
- property Transform transform : Transform {
- LookAt {
- position: Qt.vector3d( 0.0, 0.0, -20.0 )
- upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
- viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
- }
- }
- components : [cameraLens, transform]
+ SimpleCamera {
+ id: camera3
+ lens: cameraLens
+ position: Qt.vector3d( 0.0, 30.0, 30.0 )
+ viewCenter: Qt.vector3d( -5.0, -20.0, -10.0 )
}
- Entity {
- id : cameraViewport2
- property Transform transform : Transform {
- Rotate {
- angle : sceneRoot.rotationAngle
- axis : Qt.vector3d(0, 1, 0)
- }
- LookAt {
- position: Qt.vector3d( 0.0, 0.0, 20.0 )
- upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
- viewCenter: Qt.vector3d( -3.0, 0.0, 10.0 )
- }
- }
- components : [cameraLens, transform]
+ SimpleCamera {
+ id: camera4
+ lens: cameraLens
+ position: Qt.vector3d( 0.0, 15.0, 20.0 )
+ viewCenter: Qt.vector3d( 0.0, -15.0, -20.0 )
}
+ }
- Entity {
- id : cameraViewport3
- property Transform transform : Transform {
- LookAt {
- position: Qt.vector3d( 0.0, 30.0, 30.0 )
- upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
- viewCenter: Qt.vector3d( -5.0, -20.0, -10.0 )
- }
- }
- components : [cameraLens, transform]
+ Entity {
+ id: sceneRoot
+ property real rotationAngle: 0
+
+ SequentialAnimation {
+ running: true
+ loops: Animation.Infinite
+ NumberAnimation { target: sceneRoot; property: "rotationAngle"; to: 360; duration: 2000; }
}
Entity {
- components : [
+ components: [
Transform {
- Rotate {
- angle : -sceneRoot.rotationAngle
- axis : Qt.vector3d(0, 0, 1)
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(-sceneRoot.rotationAngle, Qt.vector3d(0, 0, 1));
+ return m;
}
},
SceneLoader {
source: "qrc:/assets/test_scene.dae"
- }]
- }
-
- Entity {
- id : cameraViewport4
- property Transform transform : Transform {
- LookAt {
- position: Qt.vector3d( 0.0, 15.0, 20.0 )
- upVector: Qt.vector3d( 0.0, 0.0, 1.0 )
- viewCenter: Qt.vector3d( 0.0, -15.0, -20.0 )
}
- }
- components : [cameraLens, transform]
+ ]
}
-
-
} // sceneRoot
-
} // rootNode
diff --git a/examples/qt3d/multiviewport/multiviewport.qrc b/examples/qt3d/multiviewport/multiviewport.qrc
index 5f6483ac3..bd06fb169 100644
--- a/examples/qt3d/multiviewport/multiviewport.qrc
+++ b/examples/qt3d/multiviewport/multiviewport.qrc
@@ -1,5 +1,7 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
+ <file>SimpleCamera.qml</file>
+ <file>QuadViewportFrameGraph.qml</file>
</qresource>
</RCC>
diff --git a/examples/qt3d/picking-qml/main.qml b/examples/qt3d/picking-qml/main.qml
index 644e0f306..47bb97192 100644
--- a/examples/qt3d/picking-qml/main.qml
+++ b/examples/qt3d/picking-qml/main.qml
@@ -76,12 +76,8 @@ Entity {
QQ2.Behavior on scaleFactor { QQ2.NumberAnimation { duration: 150; easing.type: QQ2.Easing.InQuad } }
property Transform transform: Transform {
- Scale {
- scale: sphere1.scaleFactor
- }
- Translate {
- dx: -8
- }
+ scale: sphere1.scaleFactor
+ translation: Qt.vector3d(-8, 0, 0)
}
property Material material: PhongMaterial {
@@ -99,8 +95,6 @@ Entity {
onExited: sphere1.material.ambient = "green"
onClicked: console.log("Clicked Sphere 1")
-
- pickAttribute: sphereMesh.geometry.positionAttribute
}
components: [sphereMesh, material, transform, objectPicker]
@@ -114,9 +108,7 @@ Entity {
}
property Transform transform: Transform {
- Scale {
- scale: 1.5
- }
+ scale: 1.5
}
property ObjectPicker objectPicker: ObjectPicker {
@@ -126,8 +118,6 @@ Entity {
onReleased: sphere2.material.diffuse = "red"
onClicked: console.log("Clicked Sphere 2")
-
- pickAttribute: sphereMesh.geometry.positionAttribute
}
components: [sphereMesh, material, transform, objectPicker]
@@ -145,12 +135,8 @@ Entity {
QQ2.Behavior on scaleFactor { QQ2.NumberAnimation { duration: 200; easing.type: QQ2.Easing.InQuad } }
property Transform transform: Transform {
- Scale {
- scale: sphere3.scaleFactor
- }
- Translate {
- dx: 8
- }
+ scale: sphere3.scaleFactor
+ translation: Qt.vector3d(8, 0, 0)
}
property ObjectPicker objectPicker: ObjectPicker {
@@ -162,8 +148,6 @@ Entity {
onExited: sphere3.material.ambient = "white"
onClicked: console.log("Clicked Sphere 3")
-
- pickAttribute: sphereMesh.geometry.positionAttribute
}
components: [sphereMesh, material, transform, objectPicker]
diff --git a/examples/qt3d/planets-qml/SolarSystem.qml b/examples/qt3d/planets-qml/SolarSystem.qml
index bef982803..dc7437028 100644
--- a/examples/qt3d/planets-qml/SolarSystem.qml
+++ b/examples/qt3d/planets-qml/SolarSystem.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
+import QtQuick 2.0 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-import QtQuick 2.0 as QQ2
import "planets.js" as Planets
@@ -467,12 +467,8 @@ Entity {
}
property Transform transformStarfield: Transform {
- Scale {
- scale: 8500000
- }
- Translate {
- translation: Qt.vector3d(0, 0, 0)
- }
+ scale: 8500000
+ translation: Qt.vector3d(0, 0, 0)
}
components: [ starfield, materialStarfield, transformStarfield ]
@@ -499,19 +495,16 @@ Entity {
}
property Transform transformSun: Transform {
- Scale {
- scale: sun.r
- }
- Rotate {
- axis: rollAxis
- angle: sun.roll
- }
- Rotate {
- axis: tiltAxis
- angle: sun.tilt
- }
- Translate {
- translation: Qt.vector3d(sun.x, sun.y, sun.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(sun.x, sun.y, sun.z));
+ m.rotate(sun.tilt, tiltAxis);
+ m.rotate(sun.roll, rollAxis);
+ m.scale(sun.r);
+ return m;
}
}
@@ -542,19 +535,16 @@ Entity {
}
property Transform transformMercury: Transform {
- Scale {
- scale: mercury.r
- }
- Rotate {
- axis: rollAxis
- angle: mercury.roll
- }
- Rotate {
- axis: tiltAxis
- angle: mercury.tilt
- }
- Translate {
- translation: Qt.vector3d(mercury.x, mercury.y, mercury.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(mercury.x, mercury.y, mercury.z));
+ m.rotate(mercury.tilt, tiltAxis);
+ m.rotate(mercury.roll, rollAxis);
+ m.scale(mercury.r);
+ return m;
}
}
@@ -581,19 +571,16 @@ Entity {
}
property Transform transformVenus: Transform {
- Scale {
- scale: venus.r
- }
- Rotate {
- axis: rollAxis
- angle: venus.roll
- }
- Rotate {
- axis: tiltAxis
- angle: venus.tilt
- }
- Translate {
- translation: Qt.vector3d(venus.x, venus.y, venus.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(venus.x, venus.y, venus.z));
+ m.rotate(venus.tilt, tiltAxis);
+ m.rotate(venus.roll, rollAxis);
+ m.scale(venus.r);
+ return m;
}
}
@@ -621,20 +608,16 @@ Entity {
}
property Transform transformEarth: Transform {
- Scale {
- scale: earth.r
- }
- Rotate {
- axis: rollAxis
- angle: earth.roll
- }
- Rotate {
- axis: tiltAxis
- angle: earth.tilt
- }
- Translate {
- id: translationEarth
- translation: Qt.vector3d(earth.x, earth.y, earth.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(earth.x, earth.y, earth.z));
+ m.rotate(earth.tilt, tiltAxis);
+ m.rotate(earth.roll, rollAxis);
+ m.scale(earth.r);
+ return m;
}
}
@@ -662,19 +645,16 @@ Entity {
}
property Transform transformEarthClouds: Transform {
- Scale {
- scale: earthClouds.r
- }
- Rotate {
- axis: rollAxis
- angle: earth.roll / 1.2
- }
- Rotate {
- axis: tiltAxis
- angle: earth.tilt
- }
- Translate {
- translation: translationEarth.translation
+ 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(earthClouds.x, earthClouds.y, earthClouds.z));
+ m.rotate(earthClouds.tilt, tiltAxis);
+ m.rotate(earthClouds.roll / 1.2, rollAxis);
+ m.scale(earthClouds.r);
+ return m;
}
}
@@ -701,19 +681,16 @@ Entity {
}
property Transform transformMoon: Transform {
- Scale {
- scale: moon.r
- }
- Rotate {
- axis: rollAxis
- angle: moon.roll
- }
- Rotate {
- axis: tiltAxis
- angle: moon.tilt
- }
- Translate {
- translation: Qt.vector3d(moon.x, moon.y, moon.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(moon.x, moon.y, moon.z));
+ m.rotate(moon.tilt, tiltAxis);
+ m.rotate(moon.roll, rollAxis);
+ m.scale(moon.r);
+ return m;
}
}
@@ -740,19 +717,16 @@ Entity {
}
property Transform transformMars: Transform {
- Scale {
- scale: mars.r
- }
- Rotate {
- axis: rollAxis
- angle: mars.roll
- }
- Rotate {
- axis: tiltAxis
- angle: mars.tilt
- }
- Translate {
- translation: Qt.vector3d(mars.x, mars.y, mars.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(mars.x, mars.y, mars.z));
+ m.rotate(mars.tilt, tiltAxis);
+ m.rotate(mars.roll, rollAxis);
+ m.scale(mars.r);
+ return m;
}
}
@@ -778,19 +752,16 @@ Entity {
}
property Transform transformJupiter: Transform {
- Scale {
- scale: jupiter.r
- }
- Rotate {
- axis: rollAxis
- angle: jupiter.roll
- }
- Rotate {
- axis: tiltAxis
- angle: jupiter.tilt
- }
- Translate {
- translation: Qt.vector3d(jupiter.x, jupiter.y, jupiter.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(jupiter.x, jupiter.y, jupiter.z));
+ m.rotate(jupiter.tilt, tiltAxis);
+ m.rotate(jupiter.roll, rollAxis);
+ m.scale(jupiter.r);
+ return m;
}
}
@@ -816,20 +787,16 @@ Entity {
}
property Transform transformSaturn: Transform {
- Scale {
- scale: saturn.r
- }
- Rotate {
- axis: rollAxis
- angle: saturn.roll
- }
- Rotate {
- axis: tiltAxis
- angle: saturn.tilt
- }
- Translate {
- id: translationSaturn
- translation: Qt.vector3d(saturn.x, saturn.y, saturn.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(saturn.x, saturn.y, saturn.z));
+ m.rotate(saturn.tilt, tiltAxis);
+ m.rotate(saturn.roll, rollAxis);
+ m.scale(saturn.r);
+ return m;
}
}
@@ -857,19 +824,16 @@ Entity {
}
property Transform transformSaturnRing: Transform {
- Scale {
- scale: (saturnRing.innerRadius + saturnRing.outerRadius) / 1.75
- }
- Rotate {
- axis: rollAxis
- angle: saturn.roll / 10
- }
- Rotate {
- axis: tiltAxis
- angle: saturn.tilt
- }
- Translate {
- translation: translationSaturn.translation
+ 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(saturn.x, saturn.y, saturn.z));
+ m.rotate(saturn.tilt, tiltAxis);
+ m.rotate(saturn.roll / 10, rollAxis);
+ m.scale((saturnRing.innerRadius + saturnRing.outerRadius) / 1.75);
+ return m;
}
}
@@ -895,20 +859,16 @@ Entity {
}
property Transform transformUranus: Transform {
- Scale {
- scale: uranus.r
- }
- Rotate {
- axis: rollAxis
- angle: uranus.roll
- }
- Rotate {
- axis: tiltAxis
- angle: uranus.tilt
- }
- Translate {
- id: translationUranus
- translation: Qt.vector3d(uranus.x, uranus.y, uranus.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(uranus.x, uranus.y, uranus.z));
+ m.rotate(uranus.tilt, tiltAxis);
+ m.rotate(uranus.roll, rollAxis);
+ m.scale(uranus.r);
+ return m;
}
}
@@ -936,19 +896,16 @@ Entity {
}
property Transform transformUranusRing: Transform {
- Scale {
- scale: (uranusRing.innerRadius + uranusRing.outerRadius) / 1.75
- }
- Rotate {
- axis: rollAxis
- angle: uranus.roll / 10
- }
- Rotate {
- axis: tiltAxis
- angle: uranus.tilt
- }
- Translate {
- translation: translationUranus.translation
+ 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(uranus.x, uranus.y, uranus.z));
+ m.rotate(uranus.tilt, tiltAxis);
+ m.rotate(uranus.roll / 10, rollAxis);
+ m.scale((uranusRing.innerRadius + uranusRing.outerRadius) / 1.75);
+ return m;
}
}
@@ -974,19 +931,16 @@ Entity {
}
property Transform transformNeptune: Transform {
- Scale {
- scale: neptune.r
- }
- Rotate {
- axis: rollAxis
- angle: neptune.roll
- }
- Rotate {
- axis: tiltAxis
- angle: neptune.tilt
- }
- Translate {
- translation: Qt.vector3d(neptune.x, neptune.y, neptune.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(neptune.x, neptune.y, neptune.z));
+ m.rotate(neptune.tilt, tiltAxis);
+ m.rotate(neptune.roll, rollAxis);
+ m.scale(neptune.r);
+ return m;
}
}
diff --git a/examples/qt3d/plasma/main.qml b/examples/qt3d/plasma/main.qml
index 1c4cb45ea..a15287b41 100644
--- a/examples/qt3d/plasma/main.qml
+++ b/examples/qt3d/plasma/main.qml
@@ -38,14 +38,12 @@ import Qt3D.Core 2.0
import Qt3D.Render 2.0
Entity {
-
components: FrameGraph {
ForwardRenderer {}
}
-
Entity {
- components : [
+ components: [
PlaneMesh {
width: 2.0
height: 2.0
@@ -53,14 +51,17 @@ Entity {
},
Transform { // Rotate the plane so that it faces us
- Rotate {
- axis: Qt.vector3d(1.0, 0.0, 0.0)
- angle: 90
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(90, Qt.vector3d(1.0, 0.0, 0.0));
+ return m;
}
},
- Material
- {
+ Material {
parameters: Parameter { name: "winsize"; value: Qt.vector2d(_window.width, _window.height) }
effect: Effect {
@@ -77,7 +78,6 @@ Entity {
shaderProgram: ShaderProgram {
vertexShaderCode: loadSource("qrc:/plasma.vert")
fragmentShaderCode: loadSource("qrc:/plasma.frag")
-
}
}
}
diff --git a/examples/qt3d/playground-qml/DetailView.qml b/examples/qt3d/playground-qml/DetailView.qml
index aa442278b..d3389bbd0 100644
--- a/examples/qt3d/playground-qml/DetailView.qml
+++ b/examples/qt3d/playground-qml/DetailView.qml
@@ -37,26 +37,15 @@
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-
Entity {
-
- property Entity camera : Entity {
- components : [
- CameraLens {
- projectionType: CameraLens.PerspectiveProjection
- fieldOfView: 60
- aspectRatio: 16/9
- nearPlane: 0.001
- farPlane: 10000.0
- },
- Transform {
- LookAt {
- position: Qt.vector3d( 10.0, 10.0, -25.0 )
- upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
- viewCenter: Qt.vector3d( 0.0, 0.0, 10.0 )
- }
- }
- ]
+ property Entity camera: Camera {
+ projectionType: CameraLens.PerspectiveProjection
+ fieldOfView: 60
+ aspectRatio: 16/9
+ nearPlane: 0.001
+ farPlane: 10000.0
+ position: Qt.vector3d( 10.0, 10.0, -25.0 )
+ upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
+ viewCenter: Qt.vector3d( 0.0, 0.0, 10.0 )
}
-
}
diff --git a/examples/qt3d/playground-qml/MainView.qml b/examples/qt3d/playground-qml/MainView.qml
index 9cfab2900..3333c28fe 100644
--- a/examples/qt3d/playground-qml/MainView.qml
+++ b/examples/qt3d/playground-qml/MainView.qml
@@ -85,16 +85,15 @@ Entity {
mesh: ballMesh
material: animatedMaterial
transform: Transform {
- Translate {
- dx: 0; dy: -10; dz : 25
- QQ2.SequentialAnimation on dz {
- running : true
- loops: QQ2.Animation.Infinite
- QQ2.NumberAnimation { to : -1000; duration : 5000 }
- QQ2.NumberAnimation { to : 1000; duration : 3000 }
- }
+ property real z: 25
+ translation: Qt.vector3d( 0, -10, z )
+ scale: 0.3
+ QQ2.SequentialAnimation on z {
+ running: true
+ loops: QQ2.Animation.Infinite
+ QQ2.NumberAnimation { to: -1000; duration: 5000 }
+ QQ2.NumberAnimation { to: 1000; duration: 3000 }
}
- Scale {scale : 0.3}
}
}
@@ -102,16 +101,15 @@ Entity {
mesh: cubeMesh
material: animatedMaterial
transform: Transform {
- Translate {
- dx: 0; dy: -10; dz : 25
- QQ2.SequentialAnimation on dx {
- running : true
- loops: QQ2.Animation.Infinite
- QQ2.NumberAnimation { to : -100; duration : 10000 }
- QQ2.NumberAnimation { to : 100; duration : 5000 }
- }
+ property real x: 0
+ translation: Qt.vector3d( x, -10, 25 )
+ scale: 0.3
+ QQ2.SequentialAnimation on x {
+ running : true
+ loops: QQ2.Animation.Infinite
+ QQ2.NumberAnimation { to : -100; duration : 10000 }
+ QQ2.NumberAnimation { to : 100; duration : 5000 }
}
- Scale {scale : 0.3}
}
}
}
diff --git a/examples/qt3d/playground-qml/MyForwardRenderer.qml b/examples/qt3d/playground-qml/MyForwardRenderer.qml
index 8ed767e84..51e9c9cf0 100644
--- a/examples/qt3d/playground-qml/MyForwardRenderer.qml
+++ b/examples/qt3d/playground-qml/MyForwardRenderer.qml
@@ -49,8 +49,8 @@ TechniqueFilter {
// Using this as a building block for a larger framegraph would
// allow a scene to be rendered multiple times to different
// viewports using different cameras for e.g.
- property alias mainCameraViewport: mainCamera.camera
- property alias detailCameraViewport: detailCamera.camera
+ property alias mainCamera: mainCameraSelector.camera
+ property alias detailCamera: detailCameraSelector.camera
property alias layerFilters: layerFilter.layers
property alias clearColor: viewport.clearColor
@@ -68,7 +68,7 @@ TechniqueFilter {
rect: Qt.rect(0.0, 0, 1.0, 1.0)
CameraSelector {
- id : mainCamera
+ id: mainCameraSelector
LayerFilter {
id: layerFilter
@@ -81,12 +81,14 @@ TechniqueFilter {
}
Viewport {
- id : detailViewport
+ id: detailViewport
rect: Qt.rect(0.75, 0.0, 0.25, 0.25)
CameraSelector {
- id: detailCamera
- RenderPassFilter { includes : [Annotation {name : "Name"; value : "ColorMaterial";}] }
+ id: detailCameraSelector
+ RenderPassFilter {
+ includes: [ Annotation { name: "Name"; value: "ColorMaterial"; } ]
+ }
}
}
}
diff --git a/examples/qt3d/playground-qml/main.qml b/examples/qt3d/playground-qml/main.qml
index 86cb0f03d..852fe03c4 100644
--- a/examples/qt3d/playground-qml/main.qml
+++ b/examples/qt3d/playground-qml/main.qml
@@ -47,8 +47,8 @@ Entity {
FrameGraph {
id : external_forward_renderer
activeFrameGraph: MyForwardRenderer {
- mainCameraViewport: mainView.camera
- detailCameraViewport: detailCamera ? detailView.camera : mainView.camera
+ mainCamera: mainView.camera
+ detailCamera: root.detailCamera ? detailView.camera : mainView.camera
clearColor: "black"
}
}
@@ -59,7 +59,7 @@ Entity {
id: keyboardInput
controller: keyboardController
focus: true
- onTabPressed: detailCamera = !detailCamera;
+ onTabPressed: root.detailCamera = !root.detailCamera;
}
components: [external_forward_renderer, keyboardInput]
diff --git a/examples/qt3d/scene3d-loader/AnimatedEntity.qml b/examples/qt3d/scene3d-loader/AnimatedEntity.qml
index bf73d6df4..5431db8ea 100644
--- a/examples/qt3d/scene3d-loader/AnimatedEntity.qml
+++ b/examples/qt3d/scene3d-loader/AnimatedEntity.qml
@@ -36,6 +36,7 @@
import Qt3D.Core 2.0
import Qt3D.Render 2.0
+
import QtQuick 2.0 as QQ2
@@ -63,7 +64,7 @@ Entity {
activeFrameGraph: Viewport {
id: viewport
rect: Qt.rect(0.0, 0.0, 1.0, 1.0) // From Top Left
- clearColor: Qt.rgba(0, 0.5, 1, 1)
+ clearColor: "transparent"
CameraSelector {
id : cameraSelector
@@ -91,10 +92,14 @@ Entity {
Transform {
id: torusTransform
- Scale { scale3D: Qt.vector3d(1.5, 1, 0.5) }
- Rotate {
- angle: 45
- axis: Qt.vector3d(1, 0, 0)
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(45, Qt.vector3d(1, 0, 0))
+ m.scale(Qt.vector3d(1.5, 1, 0.5));
+ return m;
}
}
@@ -110,19 +115,21 @@ Entity {
Transform {
id: sphereTransform
- Translate {
- translation: Qt.vector3d(20, 0, 0)
- }
-
- Rotate {
- id: sphereRotation
- axis: Qt.vector3d(0, 1, 0)
+ property real userAngle: 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(20, 0, 0));
+ m.rotate(userAngle, Qt.vector3d(0, 1, 0))
+ return m;
}
}
QQ2.NumberAnimation {
- target: sphereRotation
- property: "angle"
+ target: sphereTransform
+ property: "userAngle"
duration: 10000
from: 0
to: 360
diff --git a/examples/qt3d/scene3d-loader/Scene2.qml b/examples/qt3d/scene3d-loader/Scene2.qml
index 34e339395..8280b1bb3 100644
--- a/examples/qt3d/scene3d-loader/Scene2.qml
+++ b/examples/qt3d/scene3d-loader/Scene2.qml
@@ -82,10 +82,14 @@ Scene3D {
Transform {
id: transform
- Scale { scale3D: Qt.vector3d(1.5, 1, 0.5) }
- Rotate {
- angle: 45
- axis: Qt.vector3d(1, 0, 0)
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(45, Qt.vector3d(1, 0, 0))
+ m.scale(Qt.vector3d(1.5, 1, 0.5));
+ return m;
}
}
diff --git a/examples/qt3d/scene3d/AnimatedEntity.qml b/examples/qt3d/scene3d/AnimatedEntity.qml
index b0070db68..5431db8ea 100644
--- a/examples/qt3d/scene3d/AnimatedEntity.qml
+++ b/examples/qt3d/scene3d/AnimatedEntity.qml
@@ -92,10 +92,14 @@ Entity {
Transform {
id: torusTransform
- Scale { scale3D: Qt.vector3d(1.5, 1, 0.5) }
- Rotate {
- angle: 45
- axis: Qt.vector3d(1, 0, 0)
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(45, Qt.vector3d(1, 0, 0))
+ m.scale(Qt.vector3d(1.5, 1, 0.5));
+ return m;
}
}
@@ -111,18 +115,21 @@ Entity {
Transform {
id: sphereTransform
- Translate {
- translation: Qt.vector3d(20, 0, 0)
- }
-
- Rotate {
- id: sphereRotation
- axis: Qt.vector3d(0, 1, 0)
+ property real userAngle: 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(20, 0, 0));
+ m.rotate(userAngle, Qt.vector3d(0, 1, 0))
+ return m;
}
}
+
QQ2.NumberAnimation {
- target: sphereRotation
- property: "angle"
+ target: sphereTransform
+ property: "userAngle"
duration: 10000
from: 0
to: 360
diff --git a/examples/qt3d/shadow-map-qml/AdsMaterial.qml b/examples/qt3d/shadow-map-qml/AdsMaterial.qml
index 4e02e23e6..184189074 100644
--- a/examples/qt3d/shadow-map-qml/AdsMaterial.qml
+++ b/examples/qt3d/shadow-map-qml/AdsMaterial.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
+import QtQuick 2.1
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-import QtQuick 2.1
Material {
id: root
diff --git a/examples/qt3d/shadow-map-qml/GroundPlane.qml b/examples/qt3d/shadow-map-qml/GroundPlane.qml
index 6ccef86ae..3cade62b7 100644
--- a/examples/qt3d/shadow-map-qml/GroundPlane.qml
+++ b/examples/qt3d/shadow-map-qml/GroundPlane.qml
@@ -50,9 +50,7 @@ Entity {
Transform {
id: groundTransform
- Translate {
- dy: -5
- }
+ translation: Qt.vector3d(0, -5, 0)
}
components: [
diff --git a/examples/qt3d/shadow-map-qml/Light.qml b/examples/qt3d/shadow-map-qml/Light.qml
index 493cf6acf..a0e0306b0 100644
--- a/examples/qt3d/shadow-map-qml/Light.qml
+++ b/examples/qt3d/shadow-map-qml/Light.qml
@@ -44,7 +44,7 @@ Entity {
property vector3d lightIntensity: Qt.vector3d(1.0, 1.0, 1.0)
readonly property Camera lightCamera: lightCamera
- readonly property matrix4x4 lightViewProjection: lightCamera.projectionMatrix.times(lightCamera.matrix)
+ readonly property matrix4x4 lightViewProjection: lightCamera.projectionMatrix.times(lightCamera.viewMatrix)
Camera {
id: lightCamera
diff --git a/examples/qt3d/shadow-map-qml/ShadowMapFrameGraph.qml b/examples/qt3d/shadow-map-qml/ShadowMapFrameGraph.qml
index 2038d9f9c..63cbfae82 100644
--- a/examples/qt3d/shadow-map-qml/ShadowMapFrameGraph.qml
+++ b/examples/qt3d/shadow-map-qml/ShadowMapFrameGraph.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
+import QtQuick 2.2 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-import QtQuick 2.2 as QQ2
FrameGraph {
id: root
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;
}
}
diff --git a/examples/qt3d/shadow-map-qml/Trefoil.qml b/examples/qt3d/shadow-map-qml/Trefoil.qml
index 68a334ef8..4691adbd3 100644
--- a/examples/qt3d/shadow-map-qml/Trefoil.qml
+++ b/examples/qt3d/shadow-map-qml/Trefoil.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
@@ -49,20 +49,24 @@ Entity {
Transform {
id: trefoilMeshTransform
-
- Rotate {
- id: trefoilMeshRotation
- axis: Qt.vector3d(0, 1, 0)
+ property real userAngle: 0.0
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(userAngle, Qt.vector3d(0, 1, 0));
+ return m;
}
}
QQ2.NumberAnimation {
- target: trefoilMeshRotation
+ target: trefoilMeshTransform
running: true
loops: QQ2.Animation.Infinite
- property: "angle"
+ property: "userAngle"
duration: 5000
from: 360
to: 0
diff --git a/examples/qt3d/shadow-map-qml/main.qml b/examples/qt3d/shadow-map-qml/main.qml
index 3b79213a8..f05bbbc8a 100644
--- a/examples/qt3d/shadow-map-qml/main.qml
+++ b/examples/qt3d/shadow-map-qml/main.qml
@@ -34,6 +34,7 @@
**
****************************************************************************/
+import QtQuick 2.1 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
diff --git a/examples/qt3d/simple-cpp/main.cpp b/examples/qt3d/simple-cpp/main.cpp
index cb01cac8a..3a24867e7 100644
--- a/examples/qt3d/simple-cpp/main.cpp
+++ b/examples/qt3d/simple-cpp/main.cpp
@@ -60,6 +60,76 @@
#include <QPropertyAnimation>
+class OrbitTransformController : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt3DCore::QTransform* target READ target WRITE setTarget NOTIFY targetChanged)
+ Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged)
+ Q_PROPERTY(float angle READ angle WRITE setAngle NOTIFY angleChanged)
+
+public:
+ OrbitTransformController(QObject *parent = 0)
+ : QObject(parent)
+ , m_target(Q_NULLPTR)
+ , m_matrix()
+ , m_radius(1.0f)
+ , m_angle(0.0f)
+ {
+ }
+
+ void setTarget(Qt3DCore::QTransform *target)
+ {
+ if (m_target != target) {
+ m_target = target;
+ emit targetChanged();
+ }
+ }
+
+ Qt3DCore::QTransform *target() const { return m_target; }
+
+ void setRadius(float radius)
+ {
+ if (!qFuzzyCompare(radius, m_radius)) {
+ m_radius = radius;
+ updateMatrix();
+ emit radiusChanged();
+ }
+ }
+
+ float radius() const { return m_radius; }
+
+ void setAngle(float angle)
+ {
+ if (!qFuzzyCompare(angle, m_angle)) {
+ m_angle = angle;
+ updateMatrix();
+ emit angleChanged();
+ }
+ }
+
+ float angle() const { return m_angle; }
+
+signals:
+ void targetChanged();
+ void radiusChanged();
+ void angleChanged();
+
+protected:
+ void updateMatrix()
+ {
+ m_matrix.setToIdentity();
+ m_matrix.rotate(m_angle, QVector3D(0.0f, 1.0f, 0.0f));
+ m_matrix.translate(m_radius, 0.0f, 0.0f);
+ m_target->setMatrix(m_matrix);
+ }
+
+private:
+ Qt3DCore::QTransform *m_target;
+ QMatrix4x4 m_matrix;
+ float m_radius;
+ float m_angle;
+};
+
int main(int argc, char* argv[])
{
QGuiApplication app(argc, argv);
@@ -91,16 +161,8 @@ int main(int argc, char* argv[])
torusMesh->setSlices(20);
Qt3DCore::QTransform *torusTransform = new Qt3DCore::QTransform;
- Qt3DCore::QScaleTransform *torusScaleTransform = new Qt3DCore::QScaleTransform;
- torusScaleTransform->setScale3D(QVector3D(1.5, 1, 0.5));
-
- Qt3DCore::QRotateTransform *torusRotateTransform = new Qt3DCore::QRotateTransform;
- torusRotateTransform->setAxis(QVector3D(1, 0, 0));
- torusRotateTransform->setAngleDeg(45);
-
- torusTransform->addTransform(torusScaleTransform);
- torusTransform->addTransform(torusRotateTransform);
-
+ torusTransform->setScale3D(QVector3D(1.5, 1, 0.5));
+ torusTransform->setRotation(QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), 45.0f));
torusEntity->addComponent(torusMesh);
torusEntity->addComponent(torusTransform);
@@ -112,12 +174,12 @@ int main(int argc, char* argv[])
sphereMesh->setRadius(3);
Qt3DCore::QTransform *sphereTransform = new Qt3DCore::QTransform;
- Qt3DCore::QTranslateTransform *sphereTranslateTransform = new Qt3DCore::QTranslateTransform;
- sphereTranslateTransform->setTranslation(QVector3D(20, 0, 0));
+ OrbitTransformController *controller = new OrbitTransformController(sphereTransform);
+ controller->setTarget(sphereTransform);
+ controller->setRadius(20.0f);
- Qt3DCore::QRotateTransform *sphereRotateTransform = new Qt3DCore::QRotateTransform;
- QPropertyAnimation *sphereRotateTransformAnimation = new QPropertyAnimation(sphereRotateTransform);
- sphereRotateTransformAnimation->setTargetObject(sphereRotateTransform);
+ QPropertyAnimation *sphereRotateTransformAnimation = new QPropertyAnimation(sphereTransform);
+ sphereRotateTransformAnimation->setTargetObject(controller);
sphereRotateTransformAnimation->setPropertyName("angle");
sphereRotateTransformAnimation->setStartValue(QVariant::fromValue(0));
sphereRotateTransformAnimation->setEndValue(QVariant::fromValue(360));
@@ -125,12 +187,6 @@ int main(int argc, char* argv[])
sphereRotateTransformAnimation->setLoopCount(-1);
sphereRotateTransformAnimation->start();
- sphereRotateTransform->setAxis(QVector3D(0, 1, 0));
- sphereRotateTransform->setAngleDeg(0);
-
- sphereTransform->addTransform(sphereTranslateTransform);
- sphereTransform->addTransform(sphereRotateTransform);
-
sphereEntity->addComponent(sphereMesh);
sphereEntity->addComponent(sphereTransform);
sphereEntity->addComponent(material);
@@ -140,3 +196,5 @@ int main(int argc, char* argv[])
return app.exec();
}
+
+#include "main.moc"
diff --git a/examples/qt3d/simple-qml/main.qml b/examples/qt3d/simple-qml/main.qml
index 517ffa3a5..559aec1e8 100644
--- a/examples/qt3d/simple-qml/main.qml
+++ b/examples/qt3d/simple-qml/main.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
+import QtQuick 2.2 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-import QtQuick 2.2 as QQ2
Entity {
id: sceneRoot
@@ -80,10 +80,14 @@ Entity {
Transform {
id: torusTransform
- Scale { scale3D: Qt.vector3d(1.5, 1, 0.5) }
- Rotate {
- angle: 45
- axis: Qt.vector3d(1, 0, 0)
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.scale(Qt.vector3d(1.5, 1, 0.5));
+ m.rotate(45, Qt.vector3d(1, 0, 0));
+ return m;
}
}
@@ -99,19 +103,21 @@ Entity {
Transform {
id: sphereTransform
- Translate {
- translation: Qt.vector3d(20, 0, 0)
- }
-
- Rotate {
- id: sphereRotation
- axis: Qt.vector3d(0, 1, 0)
+ property real userAngle: 0.0
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(userAngle, Qt.vector3d(0, 1, 0));
+ m.translate(Qt.vector3d(20, 0, 0));
+ return m;
}
}
QQ2.NumberAnimation {
- target: sphereRotation
- property: "angle"
+ target: sphereTransform
+ property: "userAngle"
duration: 10000
from: 0
to: 360
diff --git a/examples/qt3d/simple-shaders-qml/main.qml b/examples/qt3d/simple-shaders-qml/main.qml
index ce83c01a9..93f7d031c 100644
--- a/examples/qt3d/simple-shaders-qml/main.qml
+++ b/examples/qt3d/simple-shaders-qml/main.qml
@@ -34,9 +34,9 @@
**
****************************************************************************/
+import QtQuick 2.2 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-import QtQuick 2.2 as QQ2
Entity {
id: sceneRoot
@@ -78,10 +78,14 @@ Entity {
id: torusEntityInlineShader
property Transform transform: Transform {
- Translate { translation: Qt.vector3d(-2.0, 0.0, 0.0) }
- Rotate {
- angle: 45
- axis: Qt.vector3d(1, 0, 0)
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(45, Qt.vector3d(1, 0, 0));
+ m.translate(Qt.vector3d(-2.0, 0.0, 0.0));
+ return m;
}
}
@@ -157,11 +161,15 @@ Entity {
Entity {
id: torusEntitySeparateShader
- property Transform transform: Transform {
- Translate { translation: Qt.vector3d(2.0, 0.0, 0.0) }
- Rotate {
- angle: 15
- axis: Qt.vector3d(1, 0, 0)
+ property Transform transform: Transform {
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(15, Qt.vector3d(1, 0, 0));
+ m.translate(Qt.vector3d(2.0, 0.0, 0.0));
+ return m;
}
}
diff --git a/examples/qt3d/skybox/Skybox.qml b/examples/qt3d/skybox/Skybox.qml
index 0d69c3434..f040ba5a7 100644
--- a/examples/qt3d/skybox/Skybox.qml
+++ b/examples/qt3d/skybox/Skybox.qml
@@ -39,7 +39,7 @@ import Qt3D.Render 2.0
Entity {
- property alias cameraPosition: cameraTranslate.translation;
+ property alias cameraPosition: transform.translation;
property string sourceDirectory: "";
property string extension: ".webp"
@@ -80,7 +80,6 @@ Entity {
Transform {
id: transform
- Translate { id: cameraTranslate }
}
Material {
diff --git a/examples/qt3d/tessellation-modes/BasicCamera.qml b/examples/qt3d/tessellation-modes/BasicCamera.qml
index a06f1562c..79ff51822 100644
--- a/examples/qt3d/tessellation-modes/BasicCamera.qml
+++ b/examples/qt3d/tessellation-modes/BasicCamera.qml
@@ -36,7 +36,6 @@
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-import QtQuick 2.1 as QQ2
Camera {
id: mainCamera
diff --git a/examples/qt3d/tessellation-modes/TessellatedQuad.qml b/examples/qt3d/tessellation-modes/TessellatedQuad.qml
index 63962edb9..b5945ed6c 100644
--- a/examples/qt3d/tessellation-modes/TessellatedQuad.qml
+++ b/examples/qt3d/tessellation-modes/TessellatedQuad.qml
@@ -34,10 +34,10 @@
**
****************************************************************************/
+import QtQuick 2.1 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
import Qt3D.Examples 1.0
-import QtQuick 2.1 as QQ2
Entity {
id: root
@@ -53,9 +53,16 @@ Entity {
Transform {
id: transform
- Translate { dx: root.x; dy: root.y; dz: root.z }
- Scale { scale: root.scale }
- Rotate{ angle: root.theta; axis: Qt.vector3d(0.0, 1.0, 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(root.x, root.y, root.z));
+ m.rotate(root.theta, Qt.vector3d(0, 1, 0));
+ m.scale(root.scale)
+ return m;
+ }
}
TessellatedQuadMesh {
diff --git a/examples/qt3d/tessellation-modes/TessellatedWireframeEffect.qml b/examples/qt3d/tessellation-modes/TessellatedWireframeEffect.qml
index f3cfb942c..9a4a5002c 100644
--- a/examples/qt3d/tessellation-modes/TessellatedWireframeEffect.qml
+++ b/examples/qt3d/tessellation-modes/TessellatedWireframeEffect.qml
@@ -36,7 +36,6 @@
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-import QtQuick 2.1
Effect {
id: root
diff --git a/examples/qt3d/tessellation-modes/TessellatedWireframeMaterial.qml b/examples/qt3d/tessellation-modes/TessellatedWireframeMaterial.qml
index fcaa37d58..98c5b4a7d 100644
--- a/examples/qt3d/tessellation-modes/TessellatedWireframeMaterial.qml
+++ b/examples/qt3d/tessellation-modes/TessellatedWireframeMaterial.qml
@@ -36,7 +36,6 @@
import Qt3D.Core 2.0
import Qt3D.Render 2.0
-import QtQuick 2.1 as QQ2
Material {
id: root
@@ -50,7 +49,6 @@ Material {
property var innerTessLevel: [1.0, 1.0 ]
property var outerTessLevel: [1.0, 1.0, 1.0, 1.0]
-
parameters: [
Parameter { name: "ambient"; value: Qt.vector3d(root.ambient.r, root.ambient.g, root.ambient.b) },
Parameter { name: "diffuse"; value: Qt.vector3d(root.diffuse.r, root.diffuse.g, root.diffuse.b) },
diff --git a/examples/qt3d/tessellation-modes/main.qml b/examples/qt3d/tessellation-modes/main.qml
index 33cfd3732..e75664364 100644
--- a/examples/qt3d/tessellation-modes/main.qml
+++ b/examples/qt3d/tessellation-modes/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
diff --git a/examples/qt3d/torus-qml/main.qml b/examples/qt3d/torus-qml/main.qml
index e7c4cc32e..59023189d 100644
--- a/examples/qt3d/torus-qml/main.qml
+++ b/examples/qt3d/torus-qml/main.qml
@@ -76,10 +76,14 @@ Entity {
Transform {
id: transform
- Scale { scale3D: Qt.vector3d(1.5, 1, 0.5) }
- Rotate {
- angle: 45
- axis: Qt.vector3d(1, 0, 0)
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(45, Qt.vector3d(1, 0, 0));
+ m.scale(Qt.vector3d(1.5, 1, 0.5))
+ return m;
}
}
diff --git a/examples/qt3d/transparency-qml-scene3d/Scene.qml b/examples/qt3d/transparency-qml-scene3d/Scene.qml
index 51cc79d7a..6b9b4683d 100644
--- a/examples/qt3d/transparency-qml-scene3d/Scene.qml
+++ b/examples/qt3d/transparency-qml-scene3d/Scene.qml
@@ -72,12 +72,12 @@ Entity {
Transform {
id: sphereTransform
- Translate { dx: 10 }
+ translation: Qt.vector3d(10, 0, 0)
}
Transform {
id: cylinderTransform
- Translate { dx: -10 }
+ translation: Qt.vector3d(-10, 0, 0)
}
Entity {
diff --git a/examples/qt3d/transparency-qml-scene3d/main.qml b/examples/qt3d/transparency-qml-scene3d/main.qml
index 14b69a40a..d1460c8fe 100644
--- a/examples/qt3d/transparency-qml-scene3d/main.qml
+++ b/examples/qt3d/transparency-qml-scene3d/main.qml
@@ -38,8 +38,7 @@ import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Scene3D 2.0
-Window
-{
+Window {
visible: true
width: 800
height: 600
diff --git a/examples/qt3d/transparency-qml/main.qml b/examples/qt3d/transparency-qml/main.qml
index d9639f819..8d104ab76 100644
--- a/examples/qt3d/transparency-qml/main.qml
+++ b/examples/qt3d/transparency-qml/main.qml
@@ -72,12 +72,12 @@ Entity {
Transform {
id: sphereTransform
- Translate { dx: 10 }
+ translation: Qt.vector3d(10, 0, 0)
}
Transform {
id: cylinderTransform
- Translate { dx: -10 }
+ translation: Qt.vector3d(-10, 0, 0)
}
Entity {
diff --git a/examples/qt3d/wave/Background.qml b/examples/qt3d/wave/Background.qml
index 64468209b..7c6ed4952 100644
--- a/examples/qt3d/wave/Background.qml
+++ b/examples/qt3d/wave/Background.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
@@ -72,9 +72,13 @@ Entity {
Transform {
// Rotate the plane so that it faces us
- Rotate {
- axis: Qt.vector3d( 1.0, 0.0, 0.0 )
- angle: 90
+ matrix: {
+ var m = Qt.matrix4x4(1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+ m.rotate(90, Qt.vector3d(1, 0, 0));
+ return m;
}
},
diff --git a/examples/qt3d/wave/Wave.qml b/examples/qt3d/wave/Wave.qml
index 708e35775..9bbb707a9 100644
--- a/examples/qt3d/wave/Wave.qml
+++ b/examples/qt3d/wave/Wave.qml
@@ -59,10 +59,17 @@ Entity {
Transform {
id: transform
- Translate { dx: root.x; dy: root.y; dz: root.z }
- 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) }
+ 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(root.phi, Qt.vector3d(0, 1, 0));
+ m.rotate(root.theta, Qt.vector3d(1, 0, 0));
+ m.scale(root.scale);
+ return m;
+ }
}
WaveMaterial {
diff --git a/examples/qt3d/wave/main.qml b/examples/qt3d/wave/main.qml
index a81a6c38a..6f7aaddb9 100644
--- a/examples/qt3d/wave/main.qml
+++ b/examples/qt3d/wave/main.qml
@@ -34,6 +34,7 @@
**
****************************************************************************/
+import QtQuick 2.1 as QQ2
import Qt3D.Core 2.0
import Qt3D.Render 2.0
import Qt3D.Input 2.0
diff --git a/examples/qt3d/wireframe/TrefoilKnot.qml b/examples/qt3d/wireframe/TrefoilKnot.qml
index 8b05c8ab9..4d51e067b 100644
--- a/examples/qt3d/wireframe/TrefoilKnot.qml
+++ b/examples/qt3d/wireframe/TrefoilKnot.qml
@@ -40,22 +40,29 @@ import Qt3D.Render 2.0
Entity {
id: root
- property alias x: translation.dx
- property alias y: translation.dy
- property alias z: translation.dz
- property alias scale: scaleTransform.scale
- property alias theta: thetaRotation.angle
- property alias phi: phiRotation.angle
+ property real x: 0.0
+ property real y: 0.0
+ property real z: 0.0
+ property real scale: 1.0
+ property real theta: 0.0
+ property real phi: 0.0
property Material material
components: [ transform, mesh, root.material ]
Transform {
id: transform
- Translate { id: translation }
- Scale { id: scaleTransform }
- Rotate{ id: thetaRotation; axis: Qt.vector3d( 1.0, 0.0, 0.0 ) }
- Rotate{ id: phiRotation; axis: Qt.vector3d( 0.0, 1.0, 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(root.x, root.y, root.z));
+ m.rotate(root.phi, Qt.vector3d(0, 1, 0));
+ m.rotate(root.theta, Qt.vector3d(1, 0, 0));
+ m.scale(root.scale);
+ return m;
+ }
}
Mesh {
diff --git a/examples/qt3d/wireframe/main.qml b/examples/qt3d/wireframe/main.qml
index 8e06a8b19..ed3f2899f 100644
--- a/examples/qt3d/wireframe/main.qml
+++ b/examples/qt3d/wireframe/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
diff --git a/src/core/core-components/qcamera.cpp b/src/core/core-components/qcamera.cpp
index 8812235ac..bfbe90d26 100644
--- a/src/core/core-components/qcamera.cpp
+++ b/src/core/core-components/qcamera.cpp
@@ -47,9 +47,13 @@ namespace Qt3DCore {
*/
QCameraPrivate::QCameraPrivate()
: QEntityPrivate()
+ , m_position(0.0f, 0.0f, 0.0f)
+ , m_viewCenter(0.0f, 0.0f, -100.0f)
+ , m_upVector(0.0f, 1.0f, 0.0f)
+ , m_cameraToCenter(m_viewCenter - m_position)
+ , m_viewMatrixDirty(false)
, m_lens(new QCameraLens())
, m_transform(new QTransform())
- , m_lookAt(new QLookAtTransform())
{
}
@@ -61,8 +65,8 @@ QCameraPrivate::QCameraPrivate()
\since 5.5
*/
-QCamera::QCamera(QNode *parent) :
- QEntity(*new QCameraPrivate, parent)
+QCamera::QCamera(QNode *parent)
+ : QEntity(*new QCameraPrivate, parent)
{
QObject::connect(d_func()->m_lens, SIGNAL(projectionTypeChanged()), this, SIGNAL(projectionMatrixChanged()));
QObject::connect(d_func()->m_lens, SIGNAL(nearPlaneChanged()), this, SIGNAL(nearPlaneChanged()));
@@ -74,11 +78,7 @@ QCamera::QCamera(QNode *parent) :
QObject::connect(d_func()->m_lens, SIGNAL(bottomChanged()), this, SIGNAL(bottomChanged()));
QObject::connect(d_func()->m_lens, SIGNAL(topChanged()), this, SIGNAL(topChanged()));
QObject::connect(d_func()->m_lens, SIGNAL(projectionMatrixChanged()), this, SIGNAL(projectionMatrixChanged()));
- QObject::connect(d_func()->m_lookAt, SIGNAL(positionChanged()), this, SIGNAL(positionChanged()));
- QObject::connect(d_func()->m_lookAt, SIGNAL(upVectorChanged()), this, SIGNAL(upVectorChanged()));
- QObject::connect(d_func()->m_lookAt, SIGNAL(viewCenterChanged()), this, SIGNAL(viewCenterChanged()));
- QObject::connect(d_func()->m_transform, SIGNAL(matrixChanged()), this, SIGNAL(matrixChanged()));
- d_func()->m_transform->addTransform(d_func()->m_lookAt);
+ QObject::connect(d_func()->m_transform, SIGNAL(matrixChanged()), this, SIGNAL(viewMatrixChanged()));
addComponent(d_func()->m_lens);
addComponent(d_func()->m_transform);
}
@@ -102,11 +102,7 @@ QCamera::QCamera(QCameraPrivate &dd, QNode *parent)
QObject::connect(d_func()->m_lens, SIGNAL(bottomChanged()), this, SIGNAL(bottomChanged()));
QObject::connect(d_func()->m_lens, SIGNAL(topChanged()), this, SIGNAL(topChanged()));
QObject::connect(d_func()->m_lens, SIGNAL(projectionMatrixChanged()), this, SIGNAL(projectionMatrixChanged()));
- QObject::connect(d_func()->m_lookAt, SIGNAL(positionChanged()), this, SIGNAL(positionChanged()));
- QObject::connect(d_func()->m_lookAt, SIGNAL(upVectorChanged()), this, SIGNAL(upVectorChanged()));
- QObject::connect(d_func()->m_lookAt, SIGNAL(viewCenterChanged()), this, SIGNAL(viewCenterChanged()));
- QObject::connect(d_func()->m_transform, SIGNAL(matrixChanged()), this, SIGNAL(matrixChanged()));
- d_func()->m_transform->addTransform(d_func()->m_lookAt);
+ QObject::connect(d_func()->m_transform, SIGNAL(matrixChanged()), this, SIGNAL(viewMatrixChanged()));
addComponent(d_func()->m_lens);
addComponent(d_func()->m_transform);
}
@@ -123,20 +119,13 @@ QTransform *QCamera::transform() const
return d->m_transform;
}
-QLookAtTransform *QCamera::lookAt() const
-{
- Q_D(const QCamera);
- return d->m_lookAt;
-}
-
-void QCamera::translate( const QVector3D& vLocal, CameraTranslationOption option )
+void QCamera::translate(const QVector3D &vLocal, CameraTranslationOption option)
{
QVector3D viewVector = viewCenter() - position(); // From "camera" position to view center
// Calculate the amount to move by in world coordinates
QVector3D vWorld;
- if (!qFuzzyIsNull(vLocal.x()))
- {
+ if (!qFuzzyIsNull(vLocal.x())) {
// Calculate the vector for the local x axis
const QVector3D x = QVector3D::crossProduct(viewVector, upVector()).normalized();
vWorld += vLocal.x() * x;
@@ -168,19 +157,19 @@ void QCamera::translate( const QVector3D& vLocal, CameraTranslationOption option
setUpVector(QVector3D::crossProduct(x, viewVector).normalized());
}
-void QCamera::translateWorld(const QVector3D& vWorld , CameraTranslationOption option )
+void QCamera::translateWorld(const QVector3D &vWorld, CameraTranslationOption option)
{
// Update the camera position using the calculated world vector
setPosition(position() + vWorld);
// May be also update the view center coordinates
- if ( option == TranslateViewCenter )
+ if (option == TranslateViewCenter)
setViewCenter(viewCenter() + vWorld);
}
QQuaternion QCamera::tiltRotation(float angle) const
{
- const QVector3D viewVector = viewCenter() - position();
+ const QVector3D viewVector = viewCenter() - position();
const QVector3D xBasis = QVector3D::crossProduct(upVector(), viewVector.normalized()).normalized();
return QQuaternion::fromAxisAndAngle(xBasis, -angle);
}
@@ -280,7 +269,6 @@ void QCamera::setProjectionType(QCameraLens::ProjectionType type)
\value CameraLens.OrthographicProjection Orthographic projection
\value CameraLens.PerspectiveProjection Perspective projection
*/
-
QCameraLens::ProjectionType QCamera::projectionType() const
{
Q_D(const QCamera);
@@ -296,7 +284,6 @@ void QCamera::setNearPlane(float nearPlane)
/*!
\qmlproperty float Qt3DCore::Camera::nearPlane
*/
-
float QCamera::nearPlane() const
{
Q_D(const QCamera);
@@ -312,7 +299,6 @@ void QCamera::setFarPlane(float farPlane)
/*!
\qmlproperty float Qt3DCore::Camera::farPlane
*/
-
float QCamera::farPlane() const
{
Q_D(const QCamera);
@@ -328,7 +314,6 @@ void QCamera::setFieldOfView(float fieldOfView)
/*!
\qmlproperty float Qt3DCore::Camera::fieldOfView
*/
-
float QCamera::fieldOfView() const
{
Q_D(const QCamera);
@@ -344,7 +329,6 @@ void QCamera::setAspectRatio(float aspectRatio)
/*!
\qmlproperty float Qt3DCore::Camera::aspectRatio
*/
-
float QCamera::aspectRatio() const
{
Q_D(const QCamera);
@@ -360,7 +344,6 @@ void QCamera::setLeft(float left)
/*!
\qmlproperty float Qt3DCore::Camera::left
*/
-
float QCamera::left() const
{
Q_D(const QCamera);
@@ -376,7 +359,6 @@ void QCamera::setRight(float right)
/*!
\qmlproperty float Qt3DCore::Camera::right
*/
-
float QCamera::right() const
{
Q_D(const QCamera);
@@ -392,7 +374,6 @@ void QCamera::setBottom(float bottom)
/*!
\qmlproperty float Qt3DCore::Camera::bottom
*/
-
float QCamera::bottom() const
{
Q_D(const QCamera);
@@ -408,7 +389,6 @@ void QCamera::setTop(float top)
/*!
\qmlproperty float Qt3DCore::Camera::top
*/
-
float QCamera::top() const
{
Q_D(const QCamera);
@@ -419,7 +399,6 @@ float QCamera::top() const
\qmlproperty matrix4x4 Qt3DCore::Camera::projectionMatrix
\readonly
*/
-
QMatrix4x4 QCamera::projectionMatrix() const
{
Q_D(const QCamera);
@@ -429,56 +408,74 @@ QMatrix4x4 QCamera::projectionMatrix() const
void QCamera::setPosition(const QVector3D &position)
{
Q_D(QCamera);
- d->m_lookAt->setPosition(position);
+ d->m_position = position;
+ d->m_cameraToCenter = d->m_viewCenter - position;
+ d->m_viewMatrixDirty = true;
+ emit positionChanged();
+ emit viewVectorChanged();
+ d->updateViewMatrix();
}
/*!
\qmlproperty vector3d Qt3DCore::Camera::position
*/
-
QVector3D QCamera::position() const
{
Q_D(const QCamera);
- return d->m_lookAt->position();
-
+ return d->m_position;
}
void QCamera::setUpVector(const QVector3D &upVector)
{
Q_D(QCamera);
- d->m_lookAt->setUpVector(upVector);
+ d->m_upVector = upVector;
+ d->m_viewMatrixDirty = true;
+ emit upVectorChanged();
+ d->updateViewMatrix();
}
/*!
\qmlproperty vector3d Qt3DCore::Camera::upVector
*/
-
QVector3D QCamera::upVector() const
{
Q_D(const QCamera);
- return d->m_lookAt->upVector();
+ return d->m_upVector;
}
void QCamera::setViewCenter(const QVector3D &viewCenter)
{
Q_D(QCamera);
- d->m_lookAt->setViewCenter(viewCenter);
+ d->m_viewCenter = viewCenter;
+ d->m_cameraToCenter = viewCenter - d->m_position;
+ d->m_viewMatrixDirty = true;
+ emit viewCenterChanged();
+ emit viewVectorChanged();
+ d->updateViewMatrix();
}
/*!
\qmlproperty vector3d Qt3DCore::Camera::viewCenter
*/
-
QVector3D QCamera::viewCenter() const
{
Q_D(const QCamera);
- return d->m_lookAt->viewCenter();
+ return d->m_viewCenter;
+}
+
+/*!
+ \qmlproperty vector3d Qt3DCore::Camera::viewVector
+*/
+QVector3D QCamera::viewVector() const
+{
+ Q_D(const QCamera);
+ return d->m_cameraToCenter;
}
/*!
- \qmlproperty matrix4x4 Qt3DCore::Camera::matrix
+ \qmlproperty matrix4x4 Qt3DCore::Camera::viewMatrix
*/
-QMatrix4x4 QCamera::matrix() const
+QMatrix4x4 QCamera::viewMatrix() const
{
Q_D(const QCamera);
return d->m_transform->matrix();
diff --git a/src/core/core-components/qcamera.h b/src/core/core-components/qcamera.h
index 305cae930..e44f0778c 100644
--- a/src/core/core-components/qcamera.h
+++ b/src/core/core-components/qcamera.h
@@ -69,7 +69,8 @@ class QT3DCORESHARED_EXPORT QCamera : public QEntity
Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
Q_PROPERTY(QVector3D upVector READ upVector WRITE setUpVector NOTIFY upVectorChanged)
Q_PROPERTY(QVector3D viewCenter READ viewCenter WRITE setViewCenter NOTIFY viewCenterChanged)
- Q_PROPERTY(QMatrix4x4 matrix READ matrix NOTIFY matrixChanged)
+ Q_PROPERTY(QVector3D viewVector READ viewVector NOTIFY viewVectorChanged)
+ Q_PROPERTY(QMatrix4x4 viewMatrix READ viewMatrix NOTIFY viewMatrixChanged)
public:
explicit QCamera(QNode *parent = 0);
@@ -83,7 +84,6 @@ public:
QCameraLens *lens() const;
QTransform *transform() const;
- QLookAtTransform *lookAt() const;
QQuaternion tiltRotation(float angle) const;
QQuaternion panRotation(float angle) const;
@@ -91,10 +91,10 @@ public:
QQuaternion rotation(float angle, const QVector3D &axis) const;
// Translate relative to camera orientation axes
- Q_INVOKABLE void translate(const QVector3D& vLocal, CameraTranslationOption option = TranslateViewCenter );
+ Q_INVOKABLE void translate(const QVector3D& vLocal, CameraTranslationOption option = TranslateViewCenter);
// Translate relative to world axes
- Q_INVOKABLE void translateWorld(const QVector3D& vWorld, CameraTranslationOption option = TranslateViewCenter );
+ Q_INVOKABLE void translateWorld(const QVector3D& vWorld, CameraTranslationOption option = TranslateViewCenter);
Q_INVOKABLE void tilt(float angle);
Q_INVOKABLE void pan(float angle);
@@ -147,7 +147,8 @@ public:
void setViewCenter(const QVector3D &viewCenter);
QVector3D viewCenter() const;
- QMatrix4x4 matrix() const;
+ QVector3D viewVector() const;
+ QMatrix4x4 viewMatrix() const;
Q_SIGNALS:
void projectionTypeChanged();
@@ -163,7 +164,8 @@ Q_SIGNALS:
void positionChanged();
void upVectorChanged();
void viewCenterChanged();
- void matrixChanged();
+ void viewVectorChanged();
+ void viewMatrixChanged();
protected:
Q_DECLARE_PRIVATE(QCamera)
diff --git a/src/core/core-components/qcamera_p.h b/src/core/core-components/qcamera_p.h
index 995ec7277..bb73a3f4e 100644
--- a/src/core/core-components/qcamera_p.h
+++ b/src/core/core-components/qcamera_p.h
@@ -64,9 +64,23 @@ public:
Q_DECLARE_PUBLIC(QCamera)
+ void updateViewMatrix()
+ {
+ QMatrix4x4 m;
+ m.lookAt(m_position, m_viewCenter, m_upVector);
+ m_transform->setMatrix(m);
+ }
+
+ QVector3D m_position;
+ QVector3D m_viewCenter;
+ QVector3D m_upVector;
+
+ QVector3D m_cameraToCenter; // The vector from the camera position to the view center
+ bool m_viewMatrixDirty;
+
+ // Components
QCameraLens *m_lens;
QTransform *m_transform;
- QLookAtTransform *m_lookAt;
};
} // namespace Qt3DCore
diff --git a/src/core/transforms/qtransform.cpp b/src/core/transforms/qtransform.cpp
index 0ca9f61de..2e177e3b2 100644
--- a/src/core/transforms/qtransform.cpp
+++ b/src/core/transforms/qtransform.cpp
@@ -51,56 +51,18 @@ namespace Qt3DCore {
*/
QTransformPrivate::QTransformPrivate()
: QComponentPrivate()
- , m_transformsDirty(false)
, m_rotation()
, m_scale(1.0f, 1.0f, 1.0f)
, m_translation()
+ , m_matrixDirty(false)
{
}
-void QTransformPrivate::_q_transformDestroyed(QObject *obj)
-{
- QAbstractTransform *transform = static_cast<QAbstractTransform *>(obj);
- if (m_transforms.removeOne(transform)) {
- emit q_func()->transformsChanged();
- _q_update();
- }
-}
-
-void QTransformPrivate::_q_update()
-{
- if (!m_transformsDirty)
- m_transformsDirty = true;
- emit q_func()->matrixChanged();
-}
-
-QMatrix4x4 QTransformPrivate::applyTransforms() const
-{
- QMatrix4x4 matrix;
- Q_FOREACH (const QAbstractTransform *t, m_transforms)
- matrix = t->transformMatrix() * matrix;
- return matrix;
-}
-
-
QTransform::QTransform(QNode *parent)
: QComponent(*new QTransformPrivate, parent)
{
}
-QTransform::QTransform(QList<QAbstractTransform *> transforms, QNode *parent)
- : QComponent(*new QTransformPrivate, parent)
-{
- Q_FOREACH (QAbstractTransform *t, transforms)
- addTransform(t);
-}
-
-QTransform::QTransform(QAbstractTransform *transform, QNode *parent)
- : QComponent(*new QTransformPrivate, parent)
-{
- addTransform(transform);
-}
-
/*! \internal */
QTransform::QTransform(QTransformPrivate &dd, QNode *parent)
: QComponent(dd, parent)
@@ -110,9 +72,6 @@ QTransform::QTransform(QTransformPrivate &dd, QNode *parent)
QTransform::~QTransform()
{
QNode::cleanup();
- Q_D(QTransform);
- // boost destruction by avoiding _q_update()-s
- d->m_transforms.clear();
}
void QTransform::copy(const QNode *ref)
@@ -127,35 +86,6 @@ void QTransform::copy(const QNode *ref)
d_func()->m_translation = transform->translation();
}
-QList<QAbstractTransform *> QTransform::transforms() const
-{
- Q_D(const QTransform);
- return d->m_transforms;
-}
-
-void QTransform::addTransform(QAbstractTransform *transform)
-{
- Q_D(QTransform);
- if (transform == Q_NULLPTR || d->m_transforms.contains(transform))
- return;
- d->m_transforms.append(transform);
- QObject::connect(transform, SIGNAL(transformMatrixChanged()), this, SLOT(_q_update()));
- QObject::connect(transform, SIGNAL(destroyed(QObject*)), this, SLOT(_q_transformDestroyed(QObject*)));
- emit transformsChanged();
- d->_q_update();
-}
-
-void QTransform::removeTransform(QAbstractTransform *transform)
-{
- Q_D(QTransform);
- if (!d->m_transforms.removeOne(transform))
- return;
- QObject::disconnect(transform, SIGNAL(transformMatrixChanged()), this, SLOT(_q_update()));
- QObject::disconnect(transform, SIGNAL(destroyed(QObject*)), this, SLOT(_q_transformDestroyed(QObject*)));
- emit transformsChanged();
- d->_q_update();
-}
-
void QTransform::setMatrix(const QMatrix4x4 &m)
{
Q_D(QTransform);
diff --git a/src/core/transforms/qtransform.h b/src/core/transforms/qtransform.h
index 7a08d272e..80d680b7e 100644
--- a/src/core/transforms/qtransform.h
+++ b/src/core/transforms/qtransform.h
@@ -47,8 +47,6 @@ QT_BEGIN_NAMESPACE
namespace Qt3DCore {
-class QAbstractTransform;
-
class QTransformPrivate;
class QT3DCORESHARED_EXPORT QTransform : public QComponent
{
@@ -61,8 +59,6 @@ class QT3DCORESHARED_EXPORT QTransform : public QComponent
public:
explicit QTransform(QNode *parent = 0);
- QTransform(QList<QAbstractTransform *> transforms, QNode *parent = 0);
- QTransform(QAbstractTransform *transform, QNode *parent = 0);
~QTransform();
float scale() const;
@@ -84,27 +80,19 @@ public:
QMatrix4x4 matrix() const;
- QList<QAbstractTransform *> transforms() const;
- void addTransform(QAbstractTransform *xform);
- void removeTransform(QAbstractTransform *xform);
-
-
public Q_SLOTS:
void setScale(float scale);
void setScale3D(const QVector3D &scale);
void setRotation(const QQuaternion &rotation);
void setTranslation(const QVector3D &translation);
-
void setMatrix(const QMatrix4x4 &matrix);
Q_SIGNALS:
- void matrixChanged();
- void transformsChanged();
-
void scaleChanged();
void scale3DChanged();
void rotationChanged();
void translationChanged();
+ void matrixChanged();
protected:
QTransform(QTransformPrivate &dd, QNode *parent = 0);
@@ -113,8 +101,6 @@ protected:
private:
Q_DECLARE_PRIVATE(QTransform)
QT3D_CLONEABLE(QTransform)
- Q_PRIVATE_SLOT(d_func(), void _q_transformDestroyed(QObject *obj))
- Q_PRIVATE_SLOT(d_func(), void _q_update())
};
} // namespace Qt3DCore
diff --git a/src/core/transforms/qtransform_p.h b/src/core/transforms/qtransform_p.h
index 523842d6e..1d98d901e 100644
--- a/src/core/transforms/qtransform_p.h
+++ b/src/core/transforms/qtransform_p.h
@@ -54,7 +54,6 @@ QT_BEGIN_NAMESPACE
namespace Qt3DCore {
-class QTransform;
class QTransformPrivate : public QComponentPrivate
{
Q_DECLARE_PUBLIC(QTransform)
@@ -62,22 +61,15 @@ class QTransformPrivate : public QComponentPrivate
public:
QTransformPrivate();
- void _q_transformDestroyed(QObject *obj);
- void _q_update();
- QMatrix4x4 applyTransforms() const;
-
- mutable bool m_transformsDirty;
- QList<QAbstractTransform*> m_transforms;
-
- mutable bool m_matrixDirty;
- mutable QMatrix4x4 m_matrix;
-
// Stored in this order as QQuaternion is bigger than QVector3D
// Operations are applied in the order of:
// scale, rotation, translation
QQuaternion m_rotation;
QVector3D m_scale;
QVector3D m_translation;
+
+ mutable QMatrix4x4 m_matrix;
+ mutable bool m_matrixDirty;
};
} // namespace Qt3DCore
diff --git a/src/plugins/sceneparsers/assimp/assimpparser.cpp b/src/plugins/sceneparsers/assimp/assimpparser.cpp
index 4c98e8c1e..6955bfc47 100644
--- a/src/plugins/sceneparsers/assimp/assimpparser.cpp
+++ b/src/plugins/sceneparsers/assimp/assimpparser.cpp
@@ -415,7 +415,8 @@ Qt3DCore::QEntity *AssimpParser::node(aiNode *node)
// Add Transformations
const QMatrix4x4 qTransformMatrix = aiMatrix4x4ToQMatrix4x4(node->mTransformation);
- Qt3DCore::QTransform *transform = new Qt3DCore::QTransform(new QMatrixTransform(qTransformMatrix));
+ Qt3DCore::QTransform *transform = new Qt3DCore::QTransform;
+ transform->setMatrix(qTransformMatrix);
entityNode->addComponent(transform);
// Add Camera
@@ -724,12 +725,12 @@ void AssimpParser::loadCamera(uint cameraIndex)
assimpCamera->mClipPlaneFar);
camera->addComponent(lens);
+ QMatrix4x4 m;
+ m.lookAt(QVector3D(assimpCamera->mPosition.x, assimpCamera->mPosition.y, assimpCamera->mPosition.z),
+ QVector3D(assimpCamera->mLookAt.x, assimpCamera->mLookAt.y, assimpCamera->mLookAt.z),
+ QVector3D(assimpCamera->mUp.x, assimpCamera->mUp.y, assimpCamera->mUp.z));
Qt3DCore::QTransform *transform = new Qt3DCore::QTransform();
- QLookAtTransform *lookAt = new QLookAtTransform();
- lookAt->setPosition(QVector3D(assimpCamera->mPosition.x, assimpCamera->mPosition.y, assimpCamera->mPosition.z));
- lookAt->setViewCenter(QVector3D(assimpCamera->mLookAt.x, assimpCamera->mLookAt.y, assimpCamera->mLookAt.z));
- lookAt->setUpVector(QVector3D(assimpCamera->mUp.x, assimpCamera->mUp.y, assimpCamera->mUp.z));
- transform->addTransform(lookAt);
+ transform->setMatrix(m);
camera->addComponent(transform);
m_scene->m_cameras[cameraNode] = camera;
diff --git a/src/plugins/sceneparsers/gltf/gltfparser.cpp b/src/plugins/sceneparsers/gltf/gltfparser.cpp
index c35a08fb6..be1e08ebb 100644
--- a/src/plugins/sceneparsers/gltf/gltfparser.cpp
+++ b/src/plugins/sceneparsers/gltf/gltfparser.cpp
@@ -293,15 +293,14 @@ Qt3DCore::QEntity* GLTFParser::node(const QString &id)
}
// ADD MATRIX TRANSFORM COMPONENT TO ENTITY
- if ( trans == Q_NULLPTR)
+ if (trans == Q_NULLPTR)
trans = new Qt3DCore::QTransform;
- trans->addTransform(new QMatrixTransform(m));
-
+ trans->setMatrix(m);
}
// Rotation quaternion
if (jsonObj.contains(KEY_ROTATION)) {
- if ( trans == Q_NULLPTR)
+ if (trans == Q_NULLPTR)
trans = new Qt3DCore::QTransform;
QJsonArray quaternionValues = jsonObj.value(KEY_ROTATION).toArray();
@@ -309,41 +308,29 @@ Qt3DCore::QEntity* GLTFParser::node(const QString &id)
quaternionValues[1].toDouble(),
quaternionValues[2].toDouble(),
quaternionValues[3].toDouble());
-
- QVector3D axis;
- float angle;
- quaternion.getAxisAndAngle(&axis, &angle);
-
- Qt3DCore::QRotateTransform *rotateTransform = new Qt3DCore::QRotateTransform;
- rotateTransform->setAxis(axis);
- rotateTransform->setAngleDeg(angle);
- trans->addTransform(rotateTransform);
+ trans->setRotation(quaternion);
}
// Translation
if (jsonObj.contains(KEY_TRANSLATION)) {
- if ( trans == Q_NULLPTR)
+ if (trans == Q_NULLPTR)
trans = new Qt3DCore::QTransform;
QJsonArray translationValues = jsonObj.value(KEY_TRANSLATION).toArray();
- Qt3DCore::QTranslateTransform *translateTransform = new Qt3DCore::QTranslateTransform;
- translateTransform->setDx(translationValues[0].toDouble());
- translateTransform->setDy(translationValues[1].toDouble());
- translateTransform->setDz(translationValues[2].toDouble());
- trans->addTransform(translateTransform);
+ trans->setTranslation(QVector3D(translationValues[0].toDouble(),
+ translationValues[1].toDouble(),
+ translationValues[2].toDouble()));
}
// Scale
if (jsonObj.contains(KEY_SCALE)) {
- if ( trans == Q_NULLPTR)
+ if (trans == Q_NULLPTR)
trans = new Qt3DCore::QTransform;
QJsonArray scaleValues = jsonObj.value(KEY_SCALE).toArray();
- Qt3DCore::QScaleTransform *scaleTransform = new Qt3DCore::QScaleTransform;
- scaleTransform->setScale3D(QVector3D(scaleValues[0].toDouble(),
- scaleValues[1].toDouble(),
- scaleValues[2].toDouble()));
- trans->addTransform(scaleTransform);
+ trans->setScale3D(QVector3D(scaleValues[0].toDouble(),
+ scaleValues[1].toDouble(),
+ scaleValues[2].toDouble()));
}
// Add the Transform component
diff --git a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp
index ef724b3eb..b2b4245e7 100644
--- a/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp
+++ b/src/quick3d/imports/core/qt3dquick3dcoreplugin.cpp
@@ -43,9 +43,9 @@
#include <Qt3DCore/qtranslatetransform.h>
#include <Qt3DCore/qrotatetransform.h>
#include <Qt3DCore/qabstractattribute.h>
+#include <Qt3DCore/qtransform.h>
#include <private/quick3dentity_p.h>
#include <private/quick3dentityloader_p.h>
-#include <private/quick3dtransform_p.h>
#include <private/quick3dconfiguration_p.h>
#include <private/quick3dnodeinstantiator_p.h>
#include <private/qt3dquick_global_p.h>
@@ -63,7 +63,8 @@ void Qt3DQuick3DCorePlugin::registerTypes(const char *uri)
Qt3DCore::Quick::registerExtendedType<Qt3DCore::QEntity, Qt3DCore::Quick::Quick3DEntity>("QEntity", "Qt3D.Core/Entity", uri, 2, 0, "Entity");
qmlRegisterType<Qt3DCore::Quick::Quick3DEntityLoader>(uri, 2, 0, "EntityLoader");
qmlRegisterType<Qt3DCore::Quick::Quick3DNodeInstantiator>(uri, 2, 0, "NodeInstantiator");
- Qt3DCore::Quick::registerExtendedType<Qt3DCore::QTransform, Qt3DCore::Quick::Quick3DTransform>("QTransform", "Qt3D.Core/Transform", uri, 2, 0, "Transform");
+ qmlRegisterType<Qt3DCore::QTransform>(uri, 2, 0, "Transform");
+
// Ideally we want to make Node an uncreatable type
// We would need qmlRegisterUncreatableExtendedType for that
qmlRegisterExtendedUncreatableType<Qt3DCore::QNode, Qt3DCore::Quick::Quick3DNode>(uri, 2, 0, "Node", QStringLiteral("Node is a base class"));
diff --git a/src/quick3d/imports/render/defaults/qml/SkyboxEntity.qml b/src/quick3d/imports/render/defaults/qml/SkyboxEntity.qml
index bc1afc237..fac8ae8a9 100644
--- a/src/quick3d/imports/render/defaults/qml/SkyboxEntity.qml
+++ b/src/quick3d/imports/render/defaults/qml/SkyboxEntity.qml
@@ -39,7 +39,7 @@ import Qt3D.Render 2.0
Entity {
- property alias cameraPosition: cameraTranslate.translation;
+ property alias cameraPosition: transform.translation;
property string baseName: "";
property string extension: ".png"
@@ -80,7 +80,6 @@ Entity {
Transform {
id: transform
- Translate { id: cameraTranslate }
}
Material {
diff --git a/src/quick3d/quick3d/items/items.pri b/src/quick3d/quick3d/items/items.pri
index 6891b1e6a..17668085e 100644
--- a/src/quick3d/quick3d/items/items.pri
+++ b/src/quick3d/quick3d/items/items.pri
@@ -1,6 +1,5 @@
HEADERS += \
$$PWD/quick3dnodeinstantiator_p.h \
- $$PWD/quick3dtransform_p.h \
$$PWD/quick3dconfiguration_p.h \
$$PWD/quick3dentity_p.h \
$$PWD/quick3dentityloader_p_p.h \
@@ -11,7 +10,6 @@ SOURCES += \
$$PWD/quick3dnode.cpp \
$$PWD/quick3dentity.cpp \
$$PWD/quick3dentityloader.cpp \
- $$PWD/quick3dtransform.cpp \
$$PWD/quick3dconfiguration.cpp \
$$PWD/quick3dnodeinstantiator.cpp
diff --git a/src/quick3d/quick3d/items/quick3dtransform.cpp b/src/quick3d/quick3d/items/quick3dtransform.cpp
deleted file mode 100644
index e708cb04f..000000000
--- a/src/quick3d/quick3d/items/quick3dtransform.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt3D module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "quick3dtransform_p.h"
-#include <Qt3DCore/qabstracttransform.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DCore {
-namespace Quick {
-
-/*!
- \qmltype Transform
- \inqmlmodule Qt3D.Core
- \since 5.5
-*/
-Quick3DTransform::Quick3DTransform(QObject *parent)
- : QObject(parent)
-{
- Q_ASSERT(qobject_cast<Qt3DCore::QTransform *>(parent) != Q_NULLPTR);
-}
-
-/*!
- \qmlproperty matrix4x4 Qt3DCore::Transform::matrix
- \readonly
-*/
-
-/*!
- \qmlproperty list<QAbstractTransform> Qt3DCore::Transform::transforms
- \default
-*/
-QQmlListProperty<QAbstractTransform> Quick3DTransform::transformList()
-{
- return QQmlListProperty<QAbstractTransform>(this, 0,
- Quick3DTransform::qmlAppendTransform,
- Quick3DTransform::transformCount,
- Quick3DTransform::transformAt,
- Quick3DTransform::qmlClearTransforms);
-}
-
-void Quick3DTransform::qmlAppendTransform(QQmlListProperty<QAbstractTransform> *list, QAbstractTransform *obj )
-{
- if ( !obj )
- return;
-
- Quick3DTransform *self = static_cast<Quick3DTransform *>(list->object);
- self->parentTransform()->addTransform(obj);
-}
-
-QAbstractTransform* Quick3DTransform::transformAt(QQmlListProperty<QAbstractTransform> *list, int index)
-{
- Quick3DTransform *self = static_cast<Quick3DTransform *>(list->object);
- return self->parentTransform()->transforms().at(index);
-}
-
-int Quick3DTransform::transformCount(QQmlListProperty<QAbstractTransform> *list)
-{
- Quick3DTransform *self = static_cast<Quick3DTransform *>(list->object);
- return self->parentTransform()->transforms().count();
-}
-
-void Quick3DTransform::qmlClearTransforms(QQmlListProperty<QAbstractTransform> *list)
-{
- Quick3DTransform *self = static_cast<Quick3DTransform *>(list->object);
- Q_FOREACH (QAbstractTransform *trans, self->parentTransform()->transforms())
- self->parentTransform()->removeTransform(trans);
-}
-
-} // namespace Quick
-} // namespace Qt3DCore
-
-QT_END_NAMESPACE
diff --git a/src/render/defaults/qskyboxentity.cpp b/src/render/defaults/qskyboxentity.cpp
index 8c9169f42..7834ec2aa 100644
--- a/src/render/defaults/qskyboxentity.cpp
+++ b/src/render/defaults/qskyboxentity.cpp
@@ -76,7 +76,6 @@ QSkyboxEntityPrivate::QSkyboxEntityPrivate()
, m_gl3RenderPass(new QRenderPass())
, m_mesh(new QCuboidMesh())
, m_transform(new Qt3DCore::QTransform())
- , m_translate(new QTranslateTransform())
, m_textureParameter(new QParameter(QStringLiteral("skyboxTexture"), m_skyboxTexture))
, m_posXImage(new QTextureImage())
, m_posYImage(new QTextureImage())
@@ -140,8 +139,6 @@ void QSkyboxEntityPrivate::init()
m_material->setEffect(m_effect);
m_material->addParameter(m_textureParameter);
- m_transform->addTransform(m_translate);
-
m_mesh->setXYMeshResolution(QSize(2, 2));
m_mesh->setXZMeshResolution(QSize(2, 2));
m_mesh->setYZMeshResolution(QSize(2, 2));
@@ -268,7 +265,7 @@ void QSkyboxEntity::setCameraPosition(const QVector3D &cameraPosition)
Q_D(QSkyboxEntity);
if (cameraPosition != d->m_position) {
d->m_position = cameraPosition;
- d->m_translate->setTranslation(d->m_position);
+ d->m_transform->setTranslation(d->m_position);
emit cameraPositionChanged();
}
}
diff --git a/src/render/defaults/qskyboxentity_p.h b/src/render/defaults/qskyboxentity_p.h
index f81bdc21d..b1ee4a506 100644
--- a/src/render/defaults/qskyboxentity_p.h
+++ b/src/render/defaults/qskyboxentity_p.h
@@ -93,7 +93,6 @@ class QSkyboxEntityPrivate : public Qt3DCore::QEntityPrivate
QRenderPass *m_gl3RenderPass;
QCuboidMesh *m_mesh;
Qt3DCore::QTransform *m_transform;
- Qt3DCore::QTranslateTransform *m_translate;
QParameter *m_textureParameter;
QTextureImage *m_posXImage;
QTextureImage *m_posYImage;
diff --git a/src/render/frontend/qboundingvolumedebug.cpp b/src/render/frontend/qboundingvolumedebug.cpp
index 029f42272..e31897265 100644
--- a/src/render/frontend/qboundingvolumedebug.cpp
+++ b/src/render/frontend/qboundingvolumedebug.cpp
@@ -40,8 +40,6 @@
#include <Qt3DCore/qbackendscenepropertychange.h>
#include <Qt3DRender/qspheremesh.h>
#include <Qt3DCore/qtransform.h>
-#include <Qt3DCore/qtranslatetransform.h>
-#include <Qt3DCore/qscaletransform.h>
#include <Qt3DRender/qphongalphamaterial.h>
#include <Qt3DRender/qlayer.h>
@@ -60,7 +58,6 @@ public:
, m_debugSubtree(Q_NULLPTR)
, m_sphereMesh(Q_NULLPTR)
, m_transform(Q_NULLPTR)
- , m_translate(Q_NULLPTR)
, m_material(Q_NULLPTR)
, m_layer(Q_NULLPTR)
, m_bvRadius(0.0f)
@@ -74,8 +71,6 @@ public:
Qt3DCore::QEntity *m_debugSubtree;
Qt3DRender::QSphereMesh *m_sphereMesh;
Qt3DCore::QTransform *m_transform;
- Qt3DCore::QTranslateTransform *m_translate;
- Qt3DCore::QScaleTransform *m_scale;
Qt3DRender::QMaterial *m_material;
Qt3DRender::QLayer *m_layer;
@@ -152,9 +147,7 @@ void QBoundingVolumeDebugPrivate::updateSubtree()
m_debugSubtree = new Qt3DCore::QEntity();
m_sphereMesh = new Qt3DRender::QSphereMesh();
m_transform = new Qt3DCore::QTransform();
- m_translate = new Qt3DCore::QTranslateTransform();
m_material = new Qt3DRender::QPhongAlphaMaterial();
- m_scale = new Qt3DCore::QScaleTransform();
m_layer = new Qt3DRender::QLayer();
static_cast<QPhongAlphaMaterial *>(m_material)->setAlpha(0.3);
@@ -162,15 +155,13 @@ void QBoundingVolumeDebugPrivate::updateSubtree()
m_layer->setNames(QStringList() << QStringLiteral("debug"));
- m_transform->addTransform(m_scale);
- m_transform->addTransform(m_translate);
m_debugSubtree->addComponent(m_sphereMesh);
m_debugSubtree->addComponent(m_transform);
m_debugSubtree->addComponent(m_material);
m_debugSubtree->addComponent(m_layer);
- m_translate->setTranslation(m_bvCenter);
- m_scale->setScale(m_bvRadius * 2.0f);
+ m_transform->setTranslation(m_bvCenter);
+ m_transform->setScale(m_bvRadius * 2.0f);
m_sphereMesh->setRadius(0.5f);
m_sphereMesh->setRings(100);
m_sphereMesh->setSlices(100);
@@ -182,8 +173,8 @@ void QBoundingVolumeDebugPrivate::updateSubtree()
}
} else {
// Just update the mesh
- m_translate->setTranslation(m_bvCenter);
- m_scale->setScale(m_bvRadius * 2.0f);
+ m_transform->setTranslation(m_bvCenter);
+ m_transform->setScale(m_bvRadius * 2.0f);
}
}
diff --git a/tests/auto/render/picking/tst_picking.cpp b/tests/auto/render/picking/tst_picking.cpp
index 42e7bd49e..54036fc74 100644
--- a/tests/auto/render/picking/tst_picking.cpp
+++ b/tests/auto/render/picking/tst_picking.cpp
@@ -38,7 +38,6 @@
#include <Qt3DCore/qentity.h>
#include <Qt3DCore/qtransform.h>
#include <Qt3DCore/QScenePropertyChange>
-#include <Qt3DCore/qtranslatetransform.h>
#include <Qt3DCore/qboundingvolumeprovider.h>
#include <Qt3DRender/private/pickboundingvolumejob_p.h>
#include <Qt3DRender/private/objectpicker_p.h>
@@ -78,7 +77,6 @@ public:
, picker(new MyObjectPicker(this))
, mesh(new QSphereMesh(this))
, transform(new Qt3DCore::QTransform(this))
- , translate(new QTranslateTransform(transform))
, acceptsEvents(true)
, pressedCalled(0)
, releasedCalled(0)
@@ -93,8 +91,7 @@ public:
const QByteArray data = (*vertexBuffer->bufferFunctor())();
vertexBuffer->setData(data);
- translate->setTranslation(position);
- transform->addTransform(translate);
+ transform->setTranslation(position);
addComponent(picker);
addComponent(mesh);
@@ -108,7 +105,6 @@ public:
MyObjectPicker *picker;
QSphereMesh *mesh;
Qt3DCore::QTransform *transform;
- QTranslateTransform *translate;
bool acceptsEvents;
int pressedCalled;
diff --git a/tests/auto/render/raycasting/tst_raycasting.cpp b/tests/auto/render/raycasting/tst_raycasting.cpp
index 0c7110edc..57a22a8ee 100644
--- a/tests/auto/render/raycasting/tst_raycasting.cpp
+++ b/tests/auto/render/raycasting/tst_raycasting.cpp
@@ -322,7 +322,7 @@ void tst_RayCasting::mousePicking()
// Window center on near plane
Qt3DCore::QRay3D ray = Qt3DRender::Render::PickBoundingVolumeJob::intersectionRay(viewport.center().toPoint(),
- camera.matrix(),
+ camera.viewMatrix(),
camera.projectionMatrix(),
viewport.toRect());
Qt3DRender::Render::Sphere s(QVector3D(0.0f, 0.5f, 0.0f), 1.0f);
@@ -335,7 +335,7 @@ void tst_RayCasting::mousePicking()
// WHEN
ray = Qt3DRender::Render::PickBoundingVolumeJob::intersectionRay(viewport.topLeft().toPoint(),
- camera.matrix(),
+ camera.viewMatrix(),
camera.projectionMatrix(),
viewport.toRect());
intersects = s.intersects(ray, Q_NULLPTR);
@@ -345,7 +345,7 @@ void tst_RayCasting::mousePicking()
// WHEN
ray = Qt3DRender::Render::PickBoundingVolumeJob::intersectionRay(viewport.topRight().toPoint(),
- camera.matrix(),
+ camera.viewMatrix(),
camera.projectionMatrix(),
viewport.toRect());
intersects = s.intersects(ray, Q_NULLPTR);
@@ -355,7 +355,7 @@ void tst_RayCasting::mousePicking()
// WHEN
ray = Qt3DRender::Render::PickBoundingVolumeJob::intersectionRay(viewport.bottomLeft().toPoint(),
- camera.matrix(),
+ camera.viewMatrix(),
camera.projectionMatrix(),
viewport.toRect());
intersects = s.intersects(ray, Q_NULLPTR);
@@ -365,7 +365,7 @@ void tst_RayCasting::mousePicking()
// WHEN
ray = Qt3DRender::Render::PickBoundingVolumeJob::intersectionRay(viewport.bottomRight().toPoint(),
- camera.matrix(),
+ camera.viewMatrix(),
camera.projectionMatrix(),
viewport.toRect());
intersects = s.intersects(ray, Q_NULLPTR);