mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-22 02:57:16 +02:00
[ui] Viewer3D: TransformGizmo - drawing gizmo on top of the object
- Special entity acting as an object container: we can add the entities we want to control with a gizmo inside it. - Drawing the gizmo always on top of the object to make sure to see it every time.
This commit is contained in:
parent
bdf9d74ec8
commit
85ebbba14f
4 changed files with 55 additions and 7 deletions
|
@ -23,6 +23,8 @@ Entity {
|
|||
property alias windowSize: trackball.windowSize
|
||||
property alias trackballSize: trackball.trackballSize
|
||||
|
||||
property bool loseMouseFocus: false // Must be changed by other entities when they want to take mouse focus
|
||||
|
||||
readonly property alias pressed: mouseHandler._pressed
|
||||
signal mousePressed(var mouse)
|
||||
signal mouseReleased(var mouse, var moved)
|
||||
|
@ -166,6 +168,8 @@ Entity {
|
|||
components: [
|
||||
FrameAction {
|
||||
onTriggered: {
|
||||
if(loseMouseFocus) return
|
||||
|
||||
if(panning) { // translate
|
||||
var d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.03;
|
||||
var tx = axisMX.value * root.translateSpeed * d;
|
||||
|
|
32
meshroom/ui/qml/Viewer3D/EntityWithGizmo.qml
Normal file
32
meshroom/ui/qml/Viewer3D/EntityWithGizmo.qml
Normal file
|
@ -0,0 +1,32 @@
|
|||
import Qt3D.Core 2.0
|
||||
import Qt3D.Render 2.9
|
||||
import Qt3D.Input 2.0
|
||||
import Qt3D.Extras 2.10
|
||||
import QtQuick 2.9
|
||||
import Qt3D.Logic 2.0
|
||||
|
||||
Entity {
|
||||
id: root
|
||||
property DefaultCameraController cameraController
|
||||
property Layer frontLayerComponent
|
||||
|
||||
readonly property Camera camera : cameraController.camera
|
||||
readonly property var windowSize: cameraController.windowSize
|
||||
readonly property alias objectTransform : transformGizmo.objectTransform // The Transform the object should use
|
||||
|
||||
signal pickedChanged(bool pressed)
|
||||
|
||||
onPickedChanged: {
|
||||
cameraController.loseMouseFocus = pressed // Notify the camera if the transform takes/releases the focus
|
||||
}
|
||||
|
||||
TransformGizmo {
|
||||
id: transformGizmo
|
||||
camera: root.camera
|
||||
windowSize: root.windowSize
|
||||
frontLayerComponent: root.frontLayerComponent
|
||||
onPickedChanged: {
|
||||
root.pickedChanged(pressed)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,14 +7,15 @@ import Qt3D.Logic 2.0
|
|||
|
||||
Entity {
|
||||
id: root
|
||||
property real gizmoScale: 0.20
|
||||
property real gizmoScale: 0.15
|
||||
property Camera camera
|
||||
property var windowSize
|
||||
property var frontLayerComponent
|
||||
readonly property Transform objectTransform : Transform {}
|
||||
|
||||
signal pickedChanged(bool pressed)
|
||||
|
||||
components: [gizmoDisplayTransform, mouseHandler]
|
||||
components: [gizmoDisplayTransform, mouseHandler, frontLayerComponent]
|
||||
|
||||
|
||||
/***** ENUMS *****/
|
||||
|
@ -194,7 +195,7 @@ Entity {
|
|||
|
||||
Entity {
|
||||
id: centerSphereEntity
|
||||
components: [centerSphereMesh, centerSphereMaterial]
|
||||
components: [centerSphereMesh, centerSphereMaterial, frontLayerComponent]
|
||||
|
||||
SphereMesh {
|
||||
id: centerSphereMesh
|
||||
|
@ -238,7 +239,7 @@ Entity {
|
|||
|
||||
Entity {
|
||||
id: axisCylinder
|
||||
components: [cylinderMesh, cylinderTransform, scaleMaterial]
|
||||
components: [cylinderMesh, cylinderTransform, scaleMaterial, frontLayerComponent]
|
||||
|
||||
CylinderMesh {
|
||||
id: cylinderMesh
|
||||
|
@ -275,7 +276,7 @@ Entity {
|
|||
|
||||
Entity {
|
||||
id: axisScaleBox
|
||||
components: [cubeScaleMesh, cubeScaleTransform, scaleMaterial, scalePicker]
|
||||
components: [cubeScaleMesh, cubeScaleTransform, scaleMaterial, scalePicker, frontLayerComponent]
|
||||
|
||||
CuboidMesh {
|
||||
id: cubeScaleMesh
|
||||
|
@ -334,7 +335,7 @@ Entity {
|
|||
// POSITION ENTITY
|
||||
Entity {
|
||||
id: positionEntity
|
||||
components: [coneMesh, coneTransform, positionMaterial, positionPicker]
|
||||
components: [coneMesh, coneTransform, positionMaterial, positionPicker, frontLayerComponent]
|
||||
|
||||
ConeMesh {
|
||||
id: coneMesh
|
||||
|
@ -394,7 +395,7 @@ Entity {
|
|||
// ROTATION ENTITY
|
||||
Entity {
|
||||
id: rotationEntity
|
||||
components: [torusMesh, torusTransform, rotationMaterial, rotationPicker]
|
||||
components: [torusMesh, torusTransform, rotationMaterial, rotationPicker, frontLayerComponent]
|
||||
|
||||
TorusMesh {
|
||||
id: torusMesh
|
||||
|
|
|
@ -207,6 +207,17 @@ FocusScope {
|
|||
]
|
||||
}
|
||||
}
|
||||
LayerFilter {
|
||||
filterMode: LayerFilter.DiscardAnyMatchingLayers
|
||||
layers: Layer {id: drawOnFront}
|
||||
}
|
||||
LayerFilter {
|
||||
filterMode: LayerFilter.AcceptAnyMatchingLayers
|
||||
layers: [drawOnFront]
|
||||
RenderStateSet {
|
||||
renderStates: DepthTest { depthFunction: DepthTest.Equal }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue