forked from qt-creator/qt-creator
QmlDesigner: Port Edit 3D View to 5.15
Qt 5.15.0 is now the minimum version to enable Edit 3D view. Change-Id: I15cee59e6a7665477825caa0ae412fc6ac7b570a Fixes: QDS-1694 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
committed by
Norihito Tohge
parent
59560fb817
commit
a77ef4ca7f
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
|
||||
DirectionalDraggable {
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
|
||||
Node {
|
||||
@@ -45,12 +45,12 @@ Node {
|
||||
|
||||
Connections {
|
||||
target: camera
|
||||
onSceneTransformChanged: updateScale()
|
||||
function onSceneTransformChanged() { updateScale() }
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: _generalHelper
|
||||
onOverlayUpdateNeeded: updateScale()
|
||||
function onOverlayUpdateNeeded() { updateScale() }
|
||||
}
|
||||
|
||||
function getScale(baseScale)
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
|
||||
View3D {
|
||||
id: axisHelperView
|
||||
@@ -37,7 +37,7 @@ View3D {
|
||||
Node {
|
||||
OrthographicCamera {
|
||||
id: axisHelperCamera
|
||||
rotation: editCameraCtrl.camera ? editCameraCtrl.camera.rotation : Qt.vector3d(0, 0, 0)
|
||||
rotation: editCameraCtrl.camera ? editCameraCtrl.camera.rotation : Qt.quaternion(1, 0, 0, 0)
|
||||
position: editCameraCtrl.camera ? editCameraCtrl.camera.position.minus(editCameraCtrl._lookAtPoint)
|
||||
.normalized().times(600) : Qt.vector3d(0, 0, 0)
|
||||
}
|
||||
@@ -54,7 +54,7 @@ View3D {
|
||||
|
||||
AxisHelperArm {
|
||||
id: armX
|
||||
rotation: Qt.vector3d(0, 0, -90)
|
||||
eulerRotation: Qt.vector3d(0, 0, -90)
|
||||
color: Qt.rgba(1, 0, 0, 1)
|
||||
hoverColor: Qt.lighter(Qt.rgba(1, 0, 0, 1))
|
||||
view3D: axisHelperView
|
||||
@@ -64,7 +64,7 @@ View3D {
|
||||
|
||||
AxisHelperArm {
|
||||
id: armY
|
||||
rotation: Qt.vector3d(0, 0, 0)
|
||||
eulerRotation: Qt.vector3d(0, 0, 0)
|
||||
color: Qt.rgba(0, 0.6, 0, 1)
|
||||
hoverColor: Qt.lighter(Qt.rgba(0, 0.6, 0, 1))
|
||||
view3D: axisHelperView
|
||||
@@ -74,7 +74,7 @@ View3D {
|
||||
|
||||
AxisHelperArm {
|
||||
id: armZ
|
||||
rotation: Qt.vector3d(90, 0, 0)
|
||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
||||
color: Qt.rgba(0, 0, 1, 1)
|
||||
hoverColor: Qt.lighter(Qt.rgba(0, 0, 1, 1))
|
||||
view3D: axisHelperView
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
|
||||
Node {
|
||||
id: armRoot
|
||||
|
61
share/qtcreator/qml/qmlpuppet/mockfiles/CameraFrustum.qml
Normal file
61
share/qtcreator/qml/qmlpuppet/mockfiles/CameraFrustum.qml
Normal file
@@ -0,0 +1,61 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.15
|
||||
import CameraGeometry 1.0
|
||||
|
||||
Model {
|
||||
id: cameraFrustum
|
||||
|
||||
property alias geometryName: cameraGeometry.name // Name must be unique for each geometry
|
||||
property alias viewPortRect: cameraGeometry.viewPortRect
|
||||
property Node targetNode: null
|
||||
property Node scene: null
|
||||
property bool selected: false
|
||||
|
||||
function updateGeometry()
|
||||
{
|
||||
cameraGeometry.update();
|
||||
}
|
||||
|
||||
position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0)
|
||||
rotation: targetNode ? targetNode.sceneRotation : Qt.quaternion(1, 0, 0, 0)
|
||||
|
||||
geometry: cameraGeometry
|
||||
materials: [
|
||||
DefaultMaterial {
|
||||
id: defaultMaterial
|
||||
emissiveColor: cameraFrustum.selected ? "#FF0000" : "#555555"
|
||||
lighting: DefaultMaterial.NoLighting
|
||||
cullingMode: Material.DisableCulling
|
||||
}
|
||||
]
|
||||
|
||||
CameraGeometry {
|
||||
id: cameraGeometry
|
||||
camera: cameraFrustum.scene && cameraFrustum.targetNode ? cameraFrustum.targetNode : null
|
||||
}
|
||||
}
|
@@ -24,37 +24,33 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import CameraGeometry 1.0
|
||||
|
||||
IconGizmo {
|
||||
id: cameraGizmo
|
||||
|
||||
property var frustumModel: null
|
||||
|
||||
iconSource: "qrc:///qtquickplugin/mockfiles/images/editor_camera.png"
|
||||
property alias geometryName: cameraGeometry.name // Name must be unique for each geometry
|
||||
property alias viewPortRect: cameraGeometry.viewPortRect
|
||||
|
||||
function connectFrustum(frustum)
|
||||
{
|
||||
frustumModel = frustum;
|
||||
|
||||
frustum.selected = selected;
|
||||
frustum.selected = Qt.binding(function() {return selected;});
|
||||
|
||||
frustum.scene = scene;
|
||||
frustum.scene = Qt.binding(function() {return scene;});
|
||||
|
||||
frustum.targetNode = targetNode;
|
||||
frustum.targetNode = Qt.binding(function() {return targetNode;});
|
||||
|
||||
frustum.visible = visible;
|
||||
frustum.visible = Qt.binding(function() {return visible;});
|
||||
}
|
||||
|
||||
onActiveSceneChanged: {
|
||||
if (activeScene == scene)
|
||||
cameraGeometry.update();
|
||||
}
|
||||
|
||||
Model {
|
||||
id: gizmoModel
|
||||
geometry: cameraGeometry
|
||||
visible: cameraGizmo.visible
|
||||
materials: [
|
||||
DefaultMaterial {
|
||||
id: defaultMaterial
|
||||
emissiveColor: cameraGizmo.selected ? "#FF0000" : "#555555"
|
||||
lighting: DefaultMaterial.NoLighting
|
||||
cullingMode: Material.DisableCulling
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
CameraGeometry {
|
||||
id: cameraGeometry
|
||||
camera: cameraGizmo.scene && cameraGizmo.targetNode ? cameraGizmo.targetNode : null
|
||||
if (frustumModel && activeScene == scene)
|
||||
frustumModel.updateGeometry();
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
|
||||
Model {
|
||||
@@ -61,8 +61,6 @@ Model {
|
||||
var maskedPosition = Qt.vector3d(planePos.x, 0, 0);
|
||||
_posPressed = planePos.x;
|
||||
_scenePosPressed = mouseArea.dragHelper.mapPositionToScene(maskedPosition);
|
||||
if (targetNode.orientation === Node.RightHanded)
|
||||
_scenePosPressed.z = -_scenePosPressed.z;
|
||||
_targetStartPos = mouseArea.pivotScenePosition(targetNode);
|
||||
pressed(mouseArea);
|
||||
}
|
||||
@@ -71,8 +69,6 @@ Model {
|
||||
{
|
||||
var maskedPosition = Qt.vector3d(planePos.x, 0, 0);
|
||||
var scenePointerPos = mouseArea.dragHelper.mapPositionToScene(maskedPosition);
|
||||
if (targetNode.orientation === Node.RightHanded)
|
||||
scenePointerPos.z = -scenePointerPos.z;
|
||||
return scenePointerPos.minus(_scenePosPressed);
|
||||
}
|
||||
|
||||
@@ -99,7 +95,7 @@ Model {
|
||||
y: -1.5
|
||||
width: 12
|
||||
height: 3
|
||||
rotation: Qt.vector3d(0, 0, 90)
|
||||
eulerRotation: Qt.vector3d(0, 0, 90)
|
||||
grabsMouse: targetNode
|
||||
active: rootModel.active
|
||||
dragHelper: rootModel.dragHelper
|
||||
@@ -116,7 +112,7 @@ Model {
|
||||
y: -1.5
|
||||
width: 12
|
||||
height: 3
|
||||
rotation: Qt.vector3d(0, 90, 90)
|
||||
eulerRotation: Qt.vector3d(0, 90, 90)
|
||||
grabsMouse: targetNode
|
||||
active: rootModel.active
|
||||
dragHelper: rootModel.dragHelper
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
|
||||
Item {
|
||||
id: cameraCtrl
|
||||
@@ -43,8 +43,8 @@ Item {
|
||||
property int _button
|
||||
property real _zoomFactor: 1
|
||||
property Camera _prevCamera: null
|
||||
readonly property vector3d _defaultCameraPosition: Qt.vector3d(0, 600, -600)
|
||||
readonly property vector3d _defaultCameraRotation: Qt.vector3d(45, 0, 0)
|
||||
readonly property vector3d _defaultCameraPosition: Qt.vector3d(0, 600, 600)
|
||||
readonly property vector3d _defaultCameraRotation: Qt.vector3d(-45, 0, 0)
|
||||
readonly property real _defaultCameraLookAtDistance: _defaultCameraPosition.length()
|
||||
|
||||
function restoreCameraState(cameraState)
|
||||
@@ -68,7 +68,7 @@ Item {
|
||||
_lookAtPoint = Qt.vector3d(0, 0, 0);
|
||||
_zoomFactor = 1;
|
||||
camera.position = _defaultCameraPosition;
|
||||
camera.rotation = _defaultCameraRotation;
|
||||
camera.eulerRotation = _defaultCameraRotation;
|
||||
_generalHelper.zoomCamera(camera, 0, _defaultCameraLookAtDistance, _lookAtPoint,
|
||||
_zoomFactor, false);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ Item {
|
||||
if (!camera)
|
||||
return;
|
||||
|
||||
camera.rotation = rotation;
|
||||
camera.eulerRotation = rotation;
|
||||
var newLookAtAndZoom = _generalHelper.focusObjectToCamera(
|
||||
camera, _defaultCameraLookAtDistance, targetObject, view3d, _zoomFactor, updateZoom);
|
||||
_lookAtPoint = newLookAtAndZoom.toVector3d();
|
||||
@@ -151,7 +151,7 @@ Item {
|
||||
onPressed: {
|
||||
if (cameraCtrl.camera && mouse.modifiers === Qt.AltModifier) {
|
||||
cameraCtrl._dragging = true;
|
||||
cameraCtrl._startRotation = cameraCtrl.camera.rotation;
|
||||
cameraCtrl._startRotation = cameraCtrl.camera.eulerRotation;
|
||||
cameraCtrl._startPosition = cameraCtrl.camera.position;
|
||||
cameraCtrl._startLookAtPoint = _lookAtPoint;
|
||||
cameraCtrl._pressPoint = Qt.vector3d(mouse.x, mouse.y, 0);
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Window 2.12
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import QtQuick.Controls 2.0
|
||||
import QtGraphicalEffects 1.0
|
||||
import MouseArea3D 1.0
|
||||
@@ -111,7 +111,7 @@ Item {
|
||||
if (editView) {
|
||||
var targetNode = selectedNodes.length > 0
|
||||
? selectionBoxes[0].model : null;
|
||||
cameraControl.focusObject(targetNode, editView.camera.rotation, true);
|
||||
cameraControl.focusObject(targetNode, editView.camera.eulerRotation, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ Item {
|
||||
// No free gizmos available, create a new one
|
||||
var component = Qt.createComponent("LightGizmo.qml");
|
||||
if (component.status === Component.Ready) {
|
||||
var gizmo = component.createObject(overlayScene,
|
||||
var gizmo = component.createObject(overlayView,
|
||||
{"view3D": overlayView, "targetNode": obj,
|
||||
"selectedNodes": selectedNodes, "scene": scene,
|
||||
"activeScene": activeScene});
|
||||
@@ -274,19 +274,24 @@ Item {
|
||||
}
|
||||
}
|
||||
// No free gizmos available, create a new one
|
||||
var component = Qt.createComponent("CameraGizmo.qml");
|
||||
if (component.status === Component.Ready) {
|
||||
var gizmoComponent = Qt.createComponent("CameraGizmo.qml");
|
||||
var frustumComponent = Qt.createComponent("CameraFrustum.qml");
|
||||
if (gizmoComponent.status === Component.Ready && frustumComponent.status === Component.Ready) {
|
||||
var geometryName = _generalHelper.generateUniqueName("CameraGeometry");
|
||||
var gizmo = component.createObject(
|
||||
var frustum = frustumComponent.createObject(
|
||||
overlayScene,
|
||||
{"view3D": overlayView, "targetNode": obj, "geometryName": geometryName,
|
||||
"viewPortRect": viewPortRect, "selectedNodes": selectedNodes,
|
||||
"scene": scene, "activeScene": activeScene});
|
||||
{"geometryName": geometryName, "viewPortRect": viewPortRect});
|
||||
var gizmo = gizmoComponent.createObject(
|
||||
overlayView,
|
||||
{"view3D": overlayView, "targetNode": obj,
|
||||
"selectedNodes": selectedNodes, "scene": scene, "activeScene": activeScene});
|
||||
|
||||
cameraGizmos[cameraGizmos.length] = gizmo;
|
||||
gizmo.clicked.connect(handleObjectClicked);
|
||||
gizmo.viewPortRect = Qt.binding(function() {return viewPortRect;});
|
||||
gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;});
|
||||
gizmo.activeScene = Qt.binding(function() {return activeScene;});
|
||||
frustum.viewPortRect = Qt.binding(function() {return viewPortRect;});
|
||||
gizmo.connectFrustum(frustum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,7 +355,7 @@ Item {
|
||||
clipFar: viewRoot.editView ? viewRoot.editView.perpectiveCamera.clipFar : 1000
|
||||
clipNear: viewRoot.editView ? viewRoot.editView.perpectiveCamera.clipNear : 1
|
||||
position: viewRoot.editView ? viewRoot.editView.perpectiveCamera.position : Qt.vector3d(0, 0, 0)
|
||||
rotation: viewRoot.editView ? viewRoot.editView.perpectiveCamera.rotation : Qt.vector3d(0, 0, 0)
|
||||
rotation: viewRoot.editView ? viewRoot.editView.perpectiveCamera.rotation : Qt.quaternion(1, 0, 0, 0)
|
||||
}
|
||||
|
||||
OrthographicCamera {
|
||||
@@ -358,7 +363,7 @@ Item {
|
||||
clipFar: viewRoot.editView ? viewRoot.editView.orthoCamera.clipFar : 1000
|
||||
clipNear: viewRoot.editView ? viewRoot.editView.orthoCamera.clipNear : 1
|
||||
position: viewRoot.editView ? viewRoot.editView.orthoCamera.position : Qt.vector3d(0, 0, 0)
|
||||
rotation: viewRoot.editView ? viewRoot.editView.orthoCamera.rotation : Qt.vector3d(0, 0, 0)
|
||||
rotation: viewRoot.editView ? viewRoot.editView.orthoCamera.rotation : Qt.quaternion(1, 0, 0, 0)
|
||||
scale: viewRoot.editView ? viewRoot.editView.orthoCamera.scale : Qt.vector3d(0, 0, 0)
|
||||
}
|
||||
|
||||
@@ -404,15 +409,14 @@ Item {
|
||||
view3D: overlayView
|
||||
dragHelper: gizmoDragHelper
|
||||
|
||||
onRotateCommit: viewRoot.commitObjectProperty(viewRoot.selectedNode, "rotation")
|
||||
onRotateChange: viewRoot.changeObjectProperty(viewRoot.selectedNode, "rotation")
|
||||
onRotateCommit: viewRoot.commitObjectProperty(viewRoot.selectedNode, "eulerRotation")
|
||||
onRotateChange: viewRoot.changeObjectProperty(viewRoot.selectedNode, "eulerRotation")
|
||||
}
|
||||
|
||||
AutoScaleHelper {
|
||||
id: autoScale
|
||||
view3D: overlayView
|
||||
position: moveGizmo.scenePosition
|
||||
orientation: moveGizmo.orientation
|
||||
}
|
||||
|
||||
Line3D {
|
||||
@@ -421,27 +425,20 @@ Item {
|
||||
name: "3D Edit View Pivot Line"
|
||||
color: "#ddd600"
|
||||
|
||||
function flipIfNeeded(vec) {
|
||||
if (!viewRoot.selectedNode || viewRoot.selectedNode.orientation === Node.LeftHanded)
|
||||
return vec;
|
||||
else
|
||||
return Qt.vector3d(vec.x, vec.y, -vec.z);
|
||||
}
|
||||
|
||||
startPos: viewRoot.selectedNode ? flipIfNeeded(viewRoot.selectedNode.scenePosition)
|
||||
startPos: viewRoot.selectedNode ? viewRoot.selectedNode.scenePosition
|
||||
: Qt.vector3d(0, 0, 0)
|
||||
Connections {
|
||||
target: viewRoot
|
||||
onSelectedNodeChanged: {
|
||||
pivotLine.endPos = pivotLine.flipIfNeeded(gizmoDragHelper.pivotScenePosition(
|
||||
viewRoot.selectedNode));
|
||||
function onSelectedNodeChanged()
|
||||
{
|
||||
pivotLine.endPos = gizmoDragHelper.pivotScenePosition(viewRoot.selectedNode);
|
||||
}
|
||||
}
|
||||
Connections {
|
||||
target: viewRoot.selectedNode
|
||||
onSceneTransformChanged: {
|
||||
pivotLine.endPos = pivotLine.flipIfNeeded(gizmoDragHelper.pivotScenePosition(
|
||||
viewRoot.selectedNode));
|
||||
function onSceneTransformChanged()
|
||||
{
|
||||
pivotLine.endPos = gizmoDragHelper.pivotScenePosition(viewRoot.selectedNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,6 +535,32 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: rotateGizmoLabel
|
||||
color: "white"
|
||||
x: rotateGizmo.currentMousePos.x - (10 + width)
|
||||
y: rotateGizmo.currentMousePos.y - (10 + height)
|
||||
width: rotateGizmoLabelText.width + 4
|
||||
height: rotateGizmoLabelText.height + 4
|
||||
border.width: 1
|
||||
visible: rotateGizmo.dragging
|
||||
parent: rotateGizmo.view3D
|
||||
|
||||
Text {
|
||||
id: rotateGizmoLabelText
|
||||
text: {
|
||||
var l = Qt.locale();
|
||||
if (rotateGizmo.targetNode) {
|
||||
var degrees = rotateGizmo.currentAngle * (180 / Math.PI);
|
||||
return qsTr(Number(degrees).toLocaleString(l, 'f', 1));
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
|
||||
EditCameraController {
|
||||
id: cameraControl
|
||||
camera: viewRoot.editView ? viewRoot.editView.camera : null
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import GridGeometry 1.0
|
||||
|
||||
Node {
|
||||
@@ -34,7 +34,7 @@ Node {
|
||||
property alias step: gridGeometry.step
|
||||
property alias subdivAlpha: subGridMaterial.opacity
|
||||
|
||||
rotation.x: 90
|
||||
eulerRotation.x: 90
|
||||
|
||||
// Note: Only one instance of HelperGrid is supported, as the geometry names are fixed
|
||||
|
||||
@@ -89,7 +89,7 @@ Node {
|
||||
]
|
||||
}
|
||||
Model { // X Axis
|
||||
rotation.z: 90
|
||||
eulerRotation.z: 90
|
||||
geometry: GridGeometry {
|
||||
lines: gridGeometry.lines
|
||||
step: gridGeometry.step
|
||||
|
@@ -24,10 +24,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import QtGraphicalEffects 1.12
|
||||
|
||||
Node {
|
||||
Item {
|
||||
id: iconGizmo
|
||||
|
||||
property Node activeScene: null
|
||||
@@ -50,16 +50,13 @@ Node {
|
||||
signal positionCommit()
|
||||
signal clicked(Node node, bool multi)
|
||||
|
||||
position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0)
|
||||
rotation: targetNode ? targetNode.sceneRotation : Qt.vector3d(0, 0, 0)
|
||||
visible: activeScene === scene && (targetNode ? targetNode.visible : false)
|
||||
|
||||
Overlay2D {
|
||||
id: iconOverlay
|
||||
targetNode: iconGizmo
|
||||
targetNode: iconGizmo.targetNode
|
||||
targetView: view3D
|
||||
visible: iconGizmo.visible && !isBehindCamera
|
||||
parent: view3D
|
||||
|
||||
Rectangle {
|
||||
id: iconRect
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
|
||||
IconGizmo {
|
||||
id: lightGizmo
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import LineGeometry 1.0
|
||||
|
||||
Node {
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
|
||||
Node {
|
||||
@@ -40,13 +40,13 @@ Node {
|
||||
property MouseArea3D dragHelper: null
|
||||
|
||||
position: dragHelper.pivotScenePosition(targetNode)
|
||||
orientation: targetNode ? targetNode.orientation : Node.LeftHanded
|
||||
|
||||
onTargetNodeChanged: position = dragHelper.pivotScenePosition(targetNode)
|
||||
|
||||
Connections {
|
||||
target: moveGizmo.targetNode
|
||||
onSceneTransformChanged: {
|
||||
function onSceneTransformChanged()
|
||||
{
|
||||
moveGizmo.position = moveGizmo.dragHelper.pivotScenePosition(moveGizmo.targetNode);
|
||||
}
|
||||
}
|
||||
@@ -55,14 +55,11 @@ Node {
|
||||
signal positionMove()
|
||||
|
||||
Node {
|
||||
rotation: globalOrientation || !moveGizmo.targetNode ? Qt.vector3d(0, 0, 0)
|
||||
rotation: globalOrientation || !moveGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0)
|
||||
: moveGizmo.targetNode.sceneRotation
|
||||
rotationOrder: moveGizmo.targetNode ? moveGizmo.targetNode.rotationOrder : Node.YXZ
|
||||
orientation: moveGizmo.orientation
|
||||
|
||||
Arrow {
|
||||
id: arrowX
|
||||
rotation: Qt.vector3d(0, 0, -90)
|
||||
eulerRotation: Qt.vector3d(0, 0, -90)
|
||||
targetNode: moveGizmo.targetNode
|
||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1))
|
||||
: Qt.rgba(1, 0, 0, 1)
|
||||
@@ -76,7 +73,7 @@ Node {
|
||||
|
||||
Arrow {
|
||||
id: arrowY
|
||||
rotation: Qt.vector3d(0, 0, 0)
|
||||
eulerRotation: Qt.vector3d(0, 0, 0)
|
||||
targetNode: moveGizmo.targetNode
|
||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1))
|
||||
: Qt.rgba(0, 0.6, 0, 1)
|
||||
@@ -90,7 +87,7 @@ Node {
|
||||
|
||||
Arrow {
|
||||
id: arrowZ
|
||||
rotation: Qt.vector3d(90, 0, 0)
|
||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
||||
targetNode: moveGizmo.targetNode
|
||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1))
|
||||
: Qt.rgba(0, 0, 1, 1)
|
||||
@@ -108,7 +105,7 @@ Node {
|
||||
y: 10
|
||||
z: 10
|
||||
|
||||
rotation: Qt.vector3d(0, 90, 0)
|
||||
eulerRotation: Qt.vector3d(0, 90, 0)
|
||||
targetNode: moveGizmo.targetNode
|
||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1))
|
||||
: Qt.rgba(1, 0, 0, 1)
|
||||
@@ -126,7 +123,7 @@ Node {
|
||||
x: 10
|
||||
z: 10
|
||||
|
||||
rotation: Qt.vector3d(90, 0, 0)
|
||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
||||
targetNode: moveGizmo.targetNode
|
||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1))
|
||||
: Qt.rgba(0, 0.6, 0, 1)
|
||||
@@ -144,7 +141,7 @@ Node {
|
||||
x: 10
|
||||
y: 10
|
||||
|
||||
rotation: Qt.vector3d(0, 0, 0)
|
||||
eulerRotation: Qt.vector3d(0, 0, 0)
|
||||
targetNode: moveGizmo.targetNode
|
||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1))
|
||||
: Qt.rgba(0, 0, 1, 1)
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
|
||||
Item {
|
||||
id: root
|
||||
@@ -39,29 +39,26 @@ Item {
|
||||
|
||||
Connections {
|
||||
target: targetNode
|
||||
onSceneTransformChanged: updateOverlay()
|
||||
function onSceneTransformChanged() { updateOverlay() }
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: targetView.camera
|
||||
onSceneTransformChanged: updateOverlay()
|
||||
function onSceneTransformChanged() { updateOverlay() }
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: _generalHelper
|
||||
onOverlayUpdateNeeded: updateOverlay()
|
||||
function onOverlayUpdateNeeded() { updateOverlay() }
|
||||
}
|
||||
|
||||
function updateOverlay()
|
||||
{
|
||||
var scenePos = targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0);
|
||||
// Need separate variable as scenePos is reference to read-only property
|
||||
var scenePosZ = scenePos.z
|
||||
if (targetNode && targetNode.orientation === Node.RightHanded)
|
||||
scenePosZ = -scenePosZ;
|
||||
var scenePosWithOffset = Qt.vector3d(scenePos.x + offset.x,
|
||||
scenePos.y + offset.y,
|
||||
scenePosZ + offset.z);
|
||||
scenePos.z + offset.z);
|
||||
var viewPos = targetView ? targetView.mapFrom3DScene(scenePosWithOffset)
|
||||
: Qt.vector3d(0, 0, 0);
|
||||
root.x = viewPos.x;
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
|
||||
Model {
|
||||
@@ -48,7 +48,6 @@ Model {
|
||||
signal dragged(var mouseArea, vector3d sceneRelativeDistance, vector2d relativeDistance)
|
||||
signal released(var mouseArea, vector3d sceneRelativeDistance, vector2d relativeDistance)
|
||||
|
||||
rotationOrder: Node.XYZr
|
||||
source: "#Rectangle"
|
||||
|
||||
DefaultMaterial {
|
||||
@@ -66,8 +65,6 @@ Model {
|
||||
|
||||
_planePosPressed = planePos;
|
||||
_scenePosPressed = mouseArea.dragHelper.mapPositionToScene(planePos.toVector3d());
|
||||
if (targetNode.orientation === Node.RightHanded)
|
||||
_scenePosPressed.z = -_scenePosPressed.z;
|
||||
_targetStartPos = mouseArea.pivotScenePosition(targetNode);
|
||||
pressed(mouseArea);
|
||||
}
|
||||
@@ -75,8 +72,6 @@ Model {
|
||||
function calcRelativeDistance(mouseArea, planePos)
|
||||
{
|
||||
var scenePointerPos = mouseArea.dragHelper.mapPositionToScene(planePos.toVector3d());
|
||||
if (targetNode.orientation === Node.RightHanded)
|
||||
scenePointerPos.z = -scenePointerPos.z;
|
||||
return scenePointerPos.minus(_scenePosPressed);
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
|
||||
PlanarDraggable {
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
|
||||
PlanarDraggable {
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
|
||||
Node {
|
||||
@@ -41,13 +41,13 @@ Node {
|
||||
property point currentMousePos
|
||||
|
||||
position: dragHelper.pivotScenePosition(targetNode)
|
||||
orientation: targetNode ? targetNode.orientation : Node.LeftHanded
|
||||
|
||||
onTargetNodeChanged: position = dragHelper.pivotScenePosition(targetNode)
|
||||
|
||||
Connections {
|
||||
target: rotateGizmo.targetNode
|
||||
onSceneTransformChanged: {
|
||||
function onSceneTransformChanged()
|
||||
{
|
||||
rotateGizmo.position = rotateGizmo.dragHelper.pivotScenePosition(rotateGizmo.targetNode);
|
||||
}
|
||||
}
|
||||
@@ -70,44 +70,16 @@ Node {
|
||||
copyRingProperties(rotRingZ)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: angleLabel
|
||||
color: "white"
|
||||
x: rotateGizmo.currentMousePos.x - (10 + width)
|
||||
y: rotateGizmo.currentMousePos.y - (10 + height)
|
||||
width: gizmoLabelText.width + 4
|
||||
height: gizmoLabelText.height + 4
|
||||
border.width: 1
|
||||
visible: rotateGizmo.dragging
|
||||
parent: rotateGizmo.view3D
|
||||
|
||||
Text {
|
||||
id: gizmoLabelText
|
||||
text: {
|
||||
var l = Qt.locale();
|
||||
if (rotateGizmo.targetNode) {
|
||||
var degrees = currentAngle * (180 / Math.PI);
|
||||
return qsTr(Number(degrees).toLocaleString(l, 'f', 1));
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
|
||||
Node {
|
||||
id: rotNode
|
||||
rotation: globalOrientation || !rotateGizmo.targetNode ? Qt.vector3d(0, 0, 0)
|
||||
rotation: globalOrientation || !rotateGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0)
|
||||
: rotateGizmo.targetNode.sceneRotation
|
||||
rotationOrder: rotateGizmo.targetNode ? rotateGizmo.targetNode.rotationOrder : Node.YXZ
|
||||
orientation: rotateGizmo.orientation
|
||||
visible: !rotateGizmo.dragging && !freeRotator.dragging
|
||||
|
||||
RotateRing {
|
||||
id: rotRingX
|
||||
objectName: "Rotate Ring X"
|
||||
rotation: Qt.vector3d(0, 90, 0)
|
||||
eulerRotation: Qt.vector3d(0, 90, 0)
|
||||
targetNode: rotateGizmo.targetNode
|
||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1))
|
||||
: Qt.rgba(1, 0, 0, 1)
|
||||
@@ -125,7 +97,7 @@ Node {
|
||||
RotateRing {
|
||||
id: rotRingY
|
||||
objectName: "Rotate Ring Y"
|
||||
rotation: Qt.vector3d(90, 0, 0)
|
||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
||||
targetNode: rotateGizmo.targetNode
|
||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1))
|
||||
: Qt.rgba(0, 0.6, 0, 1)
|
||||
@@ -145,7 +117,7 @@ Node {
|
||||
RotateRing {
|
||||
id: rotRingZ
|
||||
objectName: "Rotate Ring Z"
|
||||
rotation: Qt.vector3d(0, 0, 0)
|
||||
eulerRotation: Qt.vector3d(0, 0, 0)
|
||||
targetNode: rotateGizmo.targetNode
|
||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1))
|
||||
: Qt.rgba(0, 0, 1, 1)
|
||||
@@ -174,7 +146,6 @@ Node {
|
||||
view3D: rotateGizmo.view3D
|
||||
active: false
|
||||
visible: rotRingX.dragging || rotRingY.dragging || rotRingZ.dragging
|
||||
orientation: rotateGizmo.orientation
|
||||
}
|
||||
|
||||
RotateRing {
|
||||
@@ -223,16 +194,14 @@ Node {
|
||||
// Need to recreate vector as we need to adjust it and we can't do that on reference of
|
||||
// scenePosition, which is read-only property
|
||||
var scenePos = rotateGizmo.dragHelper.pivotScenePosition(rotateGizmo.targetNode);
|
||||
if (rotateGizmo.targetNode && rotateGizmo.targetNode.orientation === Node.RightHanded)
|
||||
scenePos.z = -scenePos.z
|
||||
_targetPosOnScreen = view3D.mapFrom3DScene(scenePos);
|
||||
_targetPosOnScreen.z = 0;
|
||||
_pointerPosPressed = Qt.vector3d(screenPos.x, screenPos.y, 0);
|
||||
|
||||
// Recreate vector so we don't follow the changes in targetNode.rotation
|
||||
_startRotation = Qt.vector3d(rotateGizmo.targetNode.rotation.x,
|
||||
rotateGizmo.targetNode.rotation.y,
|
||||
rotateGizmo.targetNode.rotation.z);
|
||||
_startRotation = Qt.vector3d(rotateGizmo.targetNode.eulerRotation.x,
|
||||
rotateGizmo.targetNode.eulerRotation.y,
|
||||
rotateGizmo.targetNode.eulerRotation.z);
|
||||
dragging = true;
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
|
||||
Model {
|
||||
@@ -80,18 +80,16 @@ Model {
|
||||
// Need to recreate vector as we need to adjust it and we can't do that on reference of
|
||||
// scenePosition, which is read-only property
|
||||
var scenePos = mouseAreaMain.pivotScenePosition(targetNode);
|
||||
if (targetNode && targetNode.orientation === Node.RightHanded)
|
||||
scenePos.z = -scenePos.z
|
||||
|
||||
_targetPosOnScreen = view3D.mapFrom3DScene(scenePos);
|
||||
_targetPosOnScreen.z = 0;
|
||||
_pointerPosPressed = Qt.vector3d(screenPos.x, screenPos.y, 0);
|
||||
_trackBall = angle < 0.1;
|
||||
|
||||
// Recreate vector so we don't follow the changes in targetNode.rotation
|
||||
_startRotation = Qt.vector3d(targetNode.rotation.x,
|
||||
targetNode.rotation.y,
|
||||
targetNode.rotation.z);
|
||||
// Recreate vector so we don't follow the changes in targetNode.eulerRotation
|
||||
_startRotation = Qt.vector3d(targetNode.eulerRotation.x,
|
||||
targetNode.eulerRotation.y,
|
||||
targetNode.eulerRotation.z);
|
||||
currentAngle = 0;
|
||||
currentMousePos = screenPos;
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
|
||||
Node {
|
||||
@@ -39,13 +39,13 @@ Node {
|
||||
property MouseArea3D dragHelper: null
|
||||
|
||||
position: dragHelper.pivotScenePosition(targetNode)
|
||||
orientation: targetNode ? targetNode.orientation : Node.LeftHanded
|
||||
|
||||
onTargetNodeChanged: position = dragHelper.pivotScenePosition(targetNode)
|
||||
|
||||
Connections {
|
||||
target: scaleGizmo.targetNode
|
||||
onSceneTransformChanged: {
|
||||
function onSceneTransformChanged()
|
||||
{
|
||||
scaleGizmo.position = scaleGizmo.dragHelper.pivotScenePosition(scaleGizmo.targetNode);
|
||||
}
|
||||
}
|
||||
@@ -54,13 +54,11 @@ Node {
|
||||
signal scaleChange()
|
||||
|
||||
Node {
|
||||
rotation: !targetNode ? Qt.vector3d(0, 0, 0) : targetNode.sceneRotation
|
||||
rotationOrder: scaleGizmo.targetNode ? scaleGizmo.targetNode.rotationOrder : Node.YXZ
|
||||
orientation: scaleGizmo.orientation
|
||||
rotation: !targetNode ? Qt.quaternion(1, 0, 0, 0) : targetNode.sceneRotation
|
||||
|
||||
ScaleRod {
|
||||
id: scaleRodX
|
||||
rotation: Qt.vector3d(0, 0, -90)
|
||||
eulerRotation: Qt.vector3d(0, 0, -90)
|
||||
axis: Qt.vector3d(1, 0, 0)
|
||||
targetNode: scaleGizmo.targetNode
|
||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1))
|
||||
@@ -75,7 +73,7 @@ Node {
|
||||
|
||||
ScaleRod {
|
||||
id: scaleRodY
|
||||
rotation: Qt.vector3d(0, 0, 0)
|
||||
eulerRotation: Qt.vector3d(0, 0, 0)
|
||||
axis: Qt.vector3d(0, 1, 0)
|
||||
targetNode: scaleGizmo.targetNode
|
||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1))
|
||||
@@ -90,7 +88,7 @@ Node {
|
||||
|
||||
ScaleRod {
|
||||
id: scaleRodZ
|
||||
rotation: Qt.vector3d(90, 0, 0)
|
||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
||||
axis: Qt.vector3d(0, 0, 1)
|
||||
targetNode: scaleGizmo.targetNode
|
||||
color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1))
|
||||
@@ -109,7 +107,7 @@ Node {
|
||||
y: 10
|
||||
z: 10
|
||||
|
||||
rotation: Qt.vector3d(0, 90, 0)
|
||||
eulerRotation: Qt.vector3d(0, 90, 0)
|
||||
axisX: Qt.vector3d(0, 0, -1)
|
||||
axisY: Qt.vector3d(0, 1, 0)
|
||||
targetNode: scaleGizmo.targetNode
|
||||
@@ -129,7 +127,7 @@ Node {
|
||||
x: 10
|
||||
z: 10
|
||||
|
||||
rotation: Qt.vector3d(90, 0, 0)
|
||||
eulerRotation: Qt.vector3d(90, 0, 0)
|
||||
axisX: Qt.vector3d(1, 0, 0)
|
||||
axisY: Qt.vector3d(0, 0, 1)
|
||||
targetNode: scaleGizmo.targetNode
|
||||
@@ -149,7 +147,7 @@ Node {
|
||||
x: 10
|
||||
y: 10
|
||||
|
||||
rotation: Qt.vector3d(0, 0, 0)
|
||||
eulerRotation: Qt.vector3d(0, 0, 0)
|
||||
axisX: Qt.vector3d(1, 0, 0)
|
||||
axisY: Qt.vector3d(0, 1, 0)
|
||||
targetNode: scaleGizmo.targetNode
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
|
||||
DirectionalDraggable {
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick3D 1.14
|
||||
import QtQuick3D 1.15
|
||||
|
||||
View3D {
|
||||
id: sceneView
|
||||
@@ -74,18 +74,18 @@ View3D {
|
||||
// point.
|
||||
PerspectiveCamera {
|
||||
id: scenePerspectiveCamera
|
||||
z: -600
|
||||
z: 600
|
||||
y: 600
|
||||
rotation.x: 45
|
||||
eulerRotation.x: -45
|
||||
clipFar: 100000
|
||||
clipNear: 1
|
||||
}
|
||||
|
||||
OrthographicCamera {
|
||||
id: sceneOrthoCamera
|
||||
z: -600
|
||||
z: 600
|
||||
y: 600
|
||||
rotation.x: 45
|
||||
eulerRotation.x: -45
|
||||
clipFar: 100000
|
||||
clipNear: -10000
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick3D 1.15
|
||||
import SelectionBoxGeometry 1.0
|
||||
|
||||
Node {
|
||||
@@ -48,11 +48,9 @@ Node {
|
||||
geometry: selectionBoxGeometry
|
||||
|
||||
scale: selectionBox.targetNode ? selectionBox.targetNode.scale : Qt.vector3d(1, 1, 1)
|
||||
rotation: selectionBox.targetNode ? selectionBox.targetNode.rotation : Qt.vector3d(0, 0, 0)
|
||||
rotation: selectionBox.targetNode ? selectionBox.targetNode.rotation : Qt.quaternion(1, 0, 0, 0)
|
||||
position: selectionBox.targetNode ? selectionBox.targetNode.position : Qt.vector3d(0, 0, 0)
|
||||
pivot: selectionBox.targetNode ? selectionBox.targetNode.pivot : Qt.vector3d(0, 0, 0)
|
||||
orientation: selectionBox.targetNode ? selectionBox.targetNode.orientation : Node.LeftHanded
|
||||
rotationOrder: selectionBox.targetNode ? selectionBox.targetNode.rotationOrder : Node.YXZ
|
||||
|
||||
visible: selectionBox.targetNode && !selectionBoxGeometry.isEmpty
|
||||
|
||||
|
@@ -28,9 +28,9 @@
|
||||
|
||||
#include "selectionboxgeometry.h"
|
||||
|
||||
#include <QtQuick3D/qquick3dobject.h>
|
||||
#include <QtQuick3D/private/qquick3dorthographiccamera_p.h>
|
||||
#include <QtQuick3D/private/qquick3dperspectivecamera_p.h>
|
||||
#include <QtQuick3D/private/qquick3dobject_p_p.h>
|
||||
#include <QtQuick3D/private/qquick3dcamera_p.h>
|
||||
#include <QtQuick3D/private/qquick3dnode_p.h>
|
||||
#include <QtQuick3D/private/qquick3dmodel_p.h>
|
||||
@@ -85,17 +85,17 @@ void GeneralHelper::orbitCamera(QQuick3DCamera *camera, const QVector3D &startRo
|
||||
if (dragVector.length() < 0.001f)
|
||||
return;
|
||||
|
||||
camera->setRotation(startRotation);
|
||||
QVector3D newRotation(dragVector.y(), dragVector.x(), 0.f);
|
||||
camera->setEulerRotation(startRotation);
|
||||
QVector3D newRotation(-dragVector.y(), -dragVector.x(), 0.f);
|
||||
newRotation *= 0.5f; // Emprically determined multiplier for nice drag
|
||||
newRotation += startRotation;
|
||||
|
||||
camera->setRotation(newRotation);
|
||||
camera->setEulerRotation(newRotation);
|
||||
|
||||
const QVector3D oldLookVector = camera->position() - lookAtPoint;
|
||||
QMatrix4x4 m = camera->sceneTransform();
|
||||
const float *dataPtr(m.data());
|
||||
QVector3D newLookVector(-dataPtr[8], -dataPtr[9], -dataPtr[10]);
|
||||
QVector3D newLookVector(dataPtr[8], dataPtr[9], dataPtr[10]);
|
||||
newLookVector.normalize();
|
||||
newLookVector *= oldLookVector.length();
|
||||
|
||||
@@ -187,7 +187,6 @@ QVector4D GeneralHelper::focusObjectToCamera(QQuick3DCamera *camera, float defau
|
||||
|
||||
// Adjust lookAt to look directly at the center of the object bounds
|
||||
lookAt = renderModel->globalTransform.map(center);
|
||||
lookAt.setZ(-lookAt.z()); // Render node transforms have inverted z
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,7 +195,7 @@ QVector4D GeneralHelper::focusObjectToCamera(QQuick3DCamera *camera, float defau
|
||||
// Reset camera position to default zoom
|
||||
QMatrix4x4 m = camera->sceneTransform();
|
||||
const float *dataPtr(m.data());
|
||||
QVector3D newLookVector(-dataPtr[8], -dataPtr[9], -dataPtr[10]);
|
||||
QVector3D newLookVector(dataPtr[8], dataPtr[9], dataPtr[10]);
|
||||
newLookVector.normalize();
|
||||
newLookVector *= defaultLookAtDistance;
|
||||
|
||||
|
@@ -81,10 +81,10 @@ QSSGRenderGraphObject *LineGeometry::updateSpatialNode(QSSGRenderGraphObject *no
|
||||
|
||||
dataPtr[0] = m_startPos[0];
|
||||
dataPtr[1] = m_startPos[1];
|
||||
dataPtr[2] = -m_startPos[2];
|
||||
dataPtr[2] = m_startPos[2];
|
||||
dataPtr[3] = m_endPos[0];
|
||||
dataPtr[4] = m_endPos[1];
|
||||
dataPtr[5] = -m_endPos[2];
|
||||
dataPtr[5] = m_endPos[2];
|
||||
|
||||
geometry->addAttribute(QSSGRenderGeometry::Attribute::PositionSemantic, 0,
|
||||
QSSGRenderGeometry::Attribute::ComponentType::F32Type);
|
||||
|
@@ -396,16 +396,12 @@ qreal QmlDesigner::Internal::MouseArea3D::getNewRotationAngle(
|
||||
if (dragVector.length() < 0.001f)
|
||||
return prevAngle;
|
||||
|
||||
// Get camera to node direction in node orientation
|
||||
// Get camera to node direction
|
||||
QVector3D cameraToNodeDir = getCameraToNodeDir(node);
|
||||
if (trackBall) {
|
||||
// Only the distance in plane direction is relevant in trackball drag
|
||||
QVector3D dragDir = QVector3D::crossProduct(getNormal(), cameraToNodeDir).normalized();
|
||||
QVector3D scenePos = pivotScenePosition(node);
|
||||
if (node->orientation() == QQuick3DNode::RightHanded) {
|
||||
scenePos.setZ(-scenePos.z());
|
||||
dragDir = -dragDir;
|
||||
}
|
||||
QVector3D screenDragDir = m_view3D->mapFrom3DScene(scenePos + dragDir);
|
||||
screenDragDir.setZ(0);
|
||||
dragDir = (screenDragDir - nodePos).normalized();
|
||||
@@ -420,12 +416,10 @@ qreal QmlDesigner::Internal::MouseArea3D::getNewRotationAngle(
|
||||
|
||||
// Determine drag direction left/right
|
||||
QVector3D dragNormal = QVector3D::crossProduct(nodeToPress, nodeToCurrent).normalized();
|
||||
if (node->orientation() == QQuick3DNode::RightHanded)
|
||||
dragNormal = -dragNormal;
|
||||
angle *= QVector3D::dotProduct(QVector3D(0.f, 0.f, 1.f), dragNormal) < 0 ? -1.0 : 1.0;
|
||||
|
||||
// Determine drag ring orientation relative to camera
|
||||
angle *= QVector3D::dotProduct(getNormal(), cameraToNodeDir) < 0 ? 1.0 : -1.0;
|
||||
angle *= QVector3D::dotProduct(getNormal(), cameraToNodeDir) < 0 ? -1.0 : 1.0;
|
||||
|
||||
qreal adjustedPrevAngle = prevAngle;
|
||||
const qreal PI_2 = M_PI * 2.0;
|
||||
@@ -451,10 +445,8 @@ void QmlDesigner::Internal::MouseArea3D::applyRotationAngleToNode(
|
||||
QQuick3DNode *node, const QVector3D &startRotation, qreal angle)
|
||||
{
|
||||
if (!qFuzzyIsNull(angle)) {
|
||||
node->setRotation(startRotation);
|
||||
node->setEulerRotation(startRotation);
|
||||
QVector3D normal = getNormal();
|
||||
if (orientation() != node->orientation())
|
||||
normal.setZ(-normal.z());
|
||||
node->rotate(qRadiansToDegrees(angle), normal, QQuick3DNode::SceneSpace);
|
||||
}
|
||||
}
|
||||
@@ -468,20 +460,15 @@ void MouseArea3D::applyFreeRotation(QQuick3DNode *node, const QVector3D &startRo
|
||||
return;
|
||||
|
||||
const float *dataPtr(sceneTransform().data());
|
||||
QVector3D xAxis = QVector3D(-dataPtr[0], -dataPtr[1], -dataPtr[2]).normalized();
|
||||
QVector3D yAxis = QVector3D(-dataPtr[4], -dataPtr[5], -dataPtr[6]).normalized();
|
||||
if (node->orientation() == QQuick3DNode::RightHanded) {
|
||||
xAxis = QVector3D(-xAxis.x(), -xAxis.y(), xAxis.z());
|
||||
yAxis = QVector3D(-yAxis.x(), -yAxis.y(), yAxis.z());
|
||||
}
|
||||
|
||||
QVector3D xAxis = QVector3D(dataPtr[0], dataPtr[1], dataPtr[2]).normalized();
|
||||
QVector3D yAxis = QVector3D(dataPtr[4], dataPtr[5], dataPtr[6]).normalized();
|
||||
QVector3D finalAxis = (dragVector.x() * yAxis + dragVector.y() * xAxis);
|
||||
|
||||
qreal degrees = qRadiansToDegrees(qreal(finalAxis.length()) * mouseDragMultiplier());
|
||||
|
||||
finalAxis.normalize();
|
||||
|
||||
node->setRotation(startRotation);
|
||||
node->setEulerRotation(startRotation);
|
||||
node->rotate(degrees, finalAxis, QQuick3DNode::SceneSpace);
|
||||
}
|
||||
|
||||
@@ -513,8 +500,6 @@ double MouseArea3D::getRelativeScale(QQuick3DNode *node) const
|
||||
// view and scene, will tell us what the distance independent scale should be.
|
||||
|
||||
QVector3D nodePos(node->scenePosition());
|
||||
if (orientation() == QQuick3DNode::RightHanded)
|
||||
nodePos.setZ(-nodePos.z());
|
||||
|
||||
DoubleVec3D posInView1(m_view3D->mapFrom3DScene(nodePos));
|
||||
|
||||
@@ -718,12 +703,9 @@ QVector3D MouseArea3D::getCameraToNodeDir(QQuick3DNode *node) const
|
||||
QVector3D dir;
|
||||
if (qobject_cast<QQuick3DOrthographicCamera *>(m_view3D->camera())) {
|
||||
dir = -m_view3D->camera()->cameraNode()->getDirection();
|
||||
dir.setZ(-dir.z());
|
||||
} else {
|
||||
QVector3D camPos = m_view3D->camera()->scenePosition();
|
||||
QVector3D nodePos = pivotScenePosition(node);
|
||||
if (node->orientation() == QQuick3DNode::RightHanded)
|
||||
nodePos.setZ(-nodePos.z());
|
||||
dir = (nodePos - camPos).normalized();
|
||||
}
|
||||
return dir;
|
||||
|
@@ -32,7 +32,7 @@
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h>
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h>
|
||||
#include <QtQuick3D/private/qquick3dmodel_p.h>
|
||||
#include <QtQuick3D/private/qquick3dobject_p_p.h>
|
||||
#include <QtQuick3D/qquick3dobject.h>
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
#include <QtCore/qvector.h>
|
||||
|
||||
@@ -367,10 +367,6 @@ void SelectionBoxGeometry::trackNodeChanges(QQuick3DNode *node)
|
||||
this, &SelectionBoxGeometry::update, Qt::QueuedConnection);
|
||||
m_connections << QObject::connect(node, &QQuick3DNode::pivotChanged,
|
||||
this, &SelectionBoxGeometry::update, Qt::QueuedConnection);
|
||||
m_connections << QObject::connect(node, &QQuick3DNode::orientationChanged,
|
||||
this, &SelectionBoxGeometry::update, Qt::QueuedConnection);
|
||||
m_connections << QObject::connect(node, &QQuick3DNode::rotationOrderChanged,
|
||||
this, &SelectionBoxGeometry::update, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
INCLUDEPATH += $$PWD/
|
||||
|
||||
qtHaveModule(quick3d) {
|
||||
versionAtLeast(QT_VERSION, 5.15.0):qtHaveModule(quick3d) {
|
||||
QT *= quick3d-private
|
||||
DEFINES *= QUICK3D_MODULE
|
||||
}
|
||||
|
@@ -174,6 +174,7 @@ void Qt5InformationNodeInstanceServer::createEditView3D()
|
||||
#ifdef QUICK3D_MODULE
|
||||
static bool showEditView = qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_SHOW_EDIT_WINDOW");
|
||||
|
||||
qmlRegisterRevision<QQuick3DNode, 1>("MouseArea3D", 1, 0);
|
||||
qmlRegisterType<QmlDesigner::Internal::MouseArea3D>("MouseArea3D", 1, 0, "MouseArea3D");
|
||||
qmlRegisterType<QmlDesigner::Internal::CameraGeometry>("CameraGeometry", 1, 0, "CameraGeometry");
|
||||
qmlRegisterType<QmlDesigner::Internal::GridGeometry>("GridGeometry", 1, 0, "GridGeometry");
|
||||
|
@@ -129,7 +129,7 @@ void Quick3DNodeInstance::setPickable(bool enable, bool checkParent, bool applyT
|
||||
checkChildren(node);
|
||||
}
|
||||
}
|
||||
if (nodeType == QQuick3DObject::Model)
|
||||
if (nodeType == QQuick3DObject::Type::Model)
|
||||
setPropertyVariant("pickable", enable); // allow 3D objects to receive mouse clicks
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@
|
||||
<file>mockfiles/Arrow.qml</file>
|
||||
<file>mockfiles/AutoScaleHelper.qml</file>
|
||||
<file>mockfiles/MoveGizmo.qml</file>
|
||||
<file>mockfiles/CameraFrustum.qml</file>
|
||||
<file>mockfiles/CameraGizmo.qml</file>
|
||||
<file>mockfiles/LightGizmo.qml</file>
|
||||
<file>mockfiles/IconGizmo.qml</file>
|
||||
|
@@ -93,7 +93,7 @@ extend_qtc_executable(qml2puppet
|
||||
nodeinstanceclientproxy.cpp nodeinstanceclientproxy.h
|
||||
)
|
||||
|
||||
find_package(Qt5 COMPONENTS Quick3D QUIET)
|
||||
find_package(Qt5 5.15.0 COMPONENTS Quick3D QUIET)
|
||||
extend_qtc_executable(qml2puppet
|
||||
CONDITION TARGET Qt5::Quick3D
|
||||
FEATURE_INFO "Qt Quick 3D"
|
||||
|
Reference in New Issue
Block a user