summaryrefslogtreecommitdiffstats
path: root/examples/qt3d/picking-qml/main.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qt3d/picking-qml/main.qml')
-rw-r--r--examples/qt3d/picking-qml/main.qml249
1 files changed, 118 insertions, 131 deletions
diff --git a/examples/qt3d/picking-qml/main.qml b/examples/qt3d/picking-qml/main.qml
index bc2b501a5..e0b446449 100644
--- a/examples/qt3d/picking-qml/main.qml
+++ b/examples/qt3d/picking-qml/main.qml
@@ -56,62 +56,50 @@ import QtQuick 2.0 as QQ2
import QtQuick.Window 2.2 as W
import QtQuick.Scene3D 2.0
-W.Window
-{
- id: _view
- visible: true
- width: 1024
- height: 768
-
- Scene3D {
-// anchors.fill: parent
- id: sceneItem
- x: parent.width / 2 - width / 2
- y: parent.height / 2 - height / 2
- width: parent.width / 2
- height: parent.height / 2
- focus: true
- aspects: "input"
+Entity {
+ id: sceneRoot
+
+ Camera {
+ id: camera
+ projectionType: CameraLens.PerspectiveProjection
+ fieldOfView: 45
+ aspectRatio: _view.width * 0.5 / _view.height
+ nearPlane : 0.1
+ farPlane : 1000.0
+ position: Qt.vector3d( 0.0, 0.0, -40.0 )
+ upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
+ viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
+ }
- Entity {
- id: sceneRoot
-
- Camera {
- id: camera
- projectionType: CameraLens.PerspectiveProjection
- fieldOfView: 45
- aspectRatio: _view.width * 0.5 / _view.height
- nearPlane : 0.1
- farPlane : 1000.0
- position: Qt.vector3d( 0.0, 0.0, -40.0 )
- upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
- viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
- }
+ Camera {
+ id: camera2
+ projectionType: CameraLens.PerspectiveProjection
+ fieldOfView: 45
+ aspectRatio: _view.width * 0.5 / _view.height
+ nearPlane : 0.1
+ farPlane : 1000.0
+ position: Qt.vector3d( 40.0, 5.0, -20.0 )
+ upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
+ viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
+ }
- Camera {
- id: camera2
- projectionType: CameraLens.PerspectiveProjection
- fieldOfView: 45
- aspectRatio: _view.width * 0.5 / _view.height
- nearPlane : 0.1
- farPlane : 1000.0
- position: Qt.vector3d( 40.0, 5.0, -20.0 )
- upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
- viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
- }
+ FirstPersonCameraController {
+ camera: camera
+ }
- FirstPersonCameraController {
- camera: camera
- }
+ // Draw 2 viewports
+ // one with the content, the other with content + debug volumes
+ components: [
+ RenderSettings {
+ Viewport {
+ normalizedRect: Qt.rect(0.0, 0.0, 1.0, 1.0)
- // Draw 2 viewports
- // one with the content, the other with content + debug volumes
- components: FrameGraph {
- Viewport {
+ RenderSurfaceSelector {
ClearBuffer {
buffers : ClearBuffer.ColorDepthBuffer
NoDraw {}
}
+
Viewport {
normalizedRect: Qt.rect(0.0, 0.0, 0.5, 1.0)
CameraSelector {
@@ -119,6 +107,7 @@ W.Window
LayerFilter { layers: "content"}
}
}
+
Viewport {
normalizedRect: Qt.rect(0.5, 0.0, 0.5, 1.0)
CameraSelector {
@@ -131,103 +120,101 @@ W.Window
}
}
}
+ },
+ InputSettings {}
+ ]
+
+ CuboidMesh { id: cubeMesh }
+
+ PickableEntity {
+ id: cube1
+ property real scaleFactor: isPressed ? 3.0 : 1.0
+ QQ2.Behavior on scaleFactor { QQ2.NumberAnimation { duration: 150; easing.type: QQ2.Easing.InQuad } }
+
+ mesh: cubeMesh
+ scale: cube1.scaleFactor
+ x: -8
+
+ ambientColor: "green"
+ diffuseColor: "green"
+
+ hoverEnabled: true
+ onPressed: cube1.diffuseColor = "orange"
+ onReleased: cube1.diffuseColor = "green"
+ onEntered: cube1.ambientColor = "blue"
+ onExited: cube1.ambientColor = "green"
+ onClicked: console.log("Clicked cube 1")
+ }
- CuboidMesh { id: cubeMesh }
-
- PickableEntity {
- id: cube1
- property real scaleFactor: isPressed ? 3.0 : 1.0
- QQ2.Behavior on scaleFactor { QQ2.NumberAnimation { duration: 150; easing.type: QQ2.Easing.InQuad } }
+ PickableEntity {
+ id: cube2
+ mesh: cubeMesh
- mesh: cubeMesh
- scale: cube1.scaleFactor
- x: -8
+ ambientColor: cube2.containsMouse ? "blue" : "red"
+ scale: 1.5
+ hoverEnabled: true
- ambientColor: "green"
- diffuseColor: "green"
+ onPressed: cube2.diffuseColor = "white"
+ onReleased: cube2.diffuseColor = "red"
- hoverEnabled: true
- onPressed: cube1.diffuseColor = "orange"
- onReleased: cube1.diffuseColor = "green"
- onEntered: cube1.ambientColor = "blue"
- onExited: cube1.ambientColor = "green"
- onClicked: console.log("Clicked cube 1")
- }
+ property bool toggled: false
+ onClicked: {
+ console.log("Clicked cube 2")
+ toggled = !toggled
+ sceneItem.width = _view.width * (toggled ? .7 : .5)
+ sceneItem.height = _view.height * (toggled ? .7 : .5)
+ console.log(sceneItem.width, sceneItem.height)
+ }
+ }
+ PickableEntity {
+ id: cube3
+ mesh: cubeMesh
- PickableEntity {
- id: cube2
- mesh: cubeMesh
+ diffuseColor: "yellow"
- ambientColor: cube2.containsMouse ? "blue" : "red"
- scale: 1.5
- hoverEnabled: true
+ property bool toggled: false
+ property real scaleFactor: toggled ? 5.0 : 0.5
+ QQ2.Behavior on scaleFactor { QQ2.NumberAnimation { duration: 200; easing.type: QQ2.Easing.InQuad } }
- onPressed: cube2.diffuseColor = "white"
- onReleased: cube2.diffuseColor = "red"
+ scale: cube3.scaleFactor
+ x: 8
- property bool toggled: false
- onClicked: {
- console.log("Clicked cube 2")
- toggled = !toggled
- sceneItem.width = _view.width * (toggled ? .7 : .5)
- sceneItem.height = _view.height * (toggled ? .7 : .5)
- console.log(sceneItem.width, sceneItem.height)
- }
- }
- PickableEntity {
- id: cube3
- mesh: cubeMesh
+ onPressed: cube3.toggled = !cube3.toggled
+ onEntered: cube3.ambientColor = "black"
+ onExited: cube3.ambientColor = "white"
+ onClicked: console.log("Clicked cube 3")
+ }
- diffuseColor: "yellow"
+ Entity {
+ readonly property ObjectPicker objectPicker: ObjectPicker {
+ hoverEnabled: true
+ onPressed: cube4.toggled = !cube4.toggled
+ onClicked: console.log("Clicked cube 4's parent Entity")
+ onEntered: cube4.material.diffuse = "white"
+ onExited: cube4.material.diffuse = "blue"
+ }
- property bool toggled: false
- property real scaleFactor: toggled ? 5.0 : 0.5
- QQ2.Behavior on scaleFactor { QQ2.NumberAnimation { duration: 200; easing.type: QQ2.Easing.InQuad } }
+ readonly property BoundingVolumeDebug debugVolume: BoundingVolumeDebug {
+ recursive: true
+ }
- scale: cube3.scaleFactor
- x: 8
+ components: [objectPicker, debugVolume]
- onPressed: cube3.toggled = !cube3.toggled
- onEntered: cube3.ambientColor = "black"
- onExited: cube3.ambientColor = "white"
- onClicked: console.log("Clicked cube 3")
+ Entity {
+ id: cube4
+ property bool toggled: false
+ property real scaleFactor: toggled ? 2.0 : 1.0
+ QQ2.Behavior on scaleFactor { QQ2.NumberAnimation { duration: 200; easing.type: QQ2.Easing.InQuad } }
+
+ readonly property Transform transform: Transform {
+ scale: cube4.scaleFactor
+ translation: Qt.vector3d(3, 4, 0)
}
+ readonly property Layer layer: Layer { names: "content" }
+ readonly property BoundingVolumeDebug debugVolume: BoundingVolumeDebug {}
+ readonly property PhongMaterial material: PhongMaterial { diffuse: "red" }
- Entity {
- readonly property ObjectPicker objectPicker: ObjectPicker {
- hoverEnabled: true
- onPressed: cube4.toggled = !cube4.toggled
- onClicked: console.log("Clicked cube 4's parent Entity")
- onEntered: cube4.material.diffuse = "white"
- onExited: cube4.material.diffuse = "blue"
- }
-
- readonly property BoundingVolumeDebug debugVolume: BoundingVolumeDebug {
- recursive: true
- }
-
- components: [objectPicker, debugVolume]
-
- Entity {
- id: cube4
- property bool toggled: false
- property real scaleFactor: toggled ? 2.0 : 1.0
- QQ2.Behavior on scaleFactor { QQ2.NumberAnimation { duration: 200; easing.type: QQ2.Easing.InQuad } }
-
- readonly property Transform transform: Transform {
- scale: cube4.scaleFactor
- translation: Qt.vector3d(3, 4, 0)
- }
- readonly property Layer layer: Layer { names: "content" }
- readonly property BoundingVolumeDebug debugVolume: BoundingVolumeDebug {}
- readonly property PhongMaterial material: PhongMaterial { diffuse: "red" }
-
- components: [cubeMesh, transform, material, debugVolume, layer]
- }
- }
+ components: [cubeMesh, transform, material, debugVolume, layer]
}
-
- QQ2.Behavior on width { QQ2.NumberAnimation { duration: 200 } }
- QQ2.Behavior on height { QQ2.NumberAnimation { duration: 200 } }
}
}