| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  | /**************************************************************************** | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Copyright (C) 2019 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.
 | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 14:54:20 +03:00
										 |  |  | import QtQuick 2.12 | 
					
						
							| 
									
										
										
										
											2019-11-13 11:16:55 +01:00
										 |  |  | import QtQuick.Window 2.12 | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  | import QtQuick3D 1.0 | 
					
						
							|  |  |  | import QtQuick.Controls 2.0 | 
					
						
							| 
									
										
										
										
											2019-10-15 14:54:20 +03:00
										 |  |  | import QtGraphicalEffects 1.0 | 
					
						
							| 
									
										
										
										
											2019-12-10 13:14:30 +02:00
										 |  |  | import MouseArea3D 1.0 | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | Window { | 
					
						
							| 
									
										
										
										
											2019-10-15 14:54:20 +03:00
										 |  |  |     id: viewWindow | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  |     width: 1024 | 
					
						
							|  |  |  |     height: 768 | 
					
						
							| 
									
										
										
										
											2019-11-13 11:16:55 +01:00
										 |  |  |     visible: false | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  |     title: "3D" | 
					
						
							| 
									
										
										
										
											2019-11-13 11:16:55 +01:00
										 |  |  |     flags: Qt.Widget | Qt.SplashScreen | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     onActiveChanged: { | 
					
						
							|  |  |  |         if (viewWindow.active) | 
					
						
							|  |  |  |             cameraControl.forceActiveFocus() | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-04 13:29:20 +02:00
										 |  |  |     property alias scene: editView.importScene | 
					
						
							| 
									
										
										
										
											2019-11-26 11:25:12 +02:00
										 |  |  |     property alias showEditLight: btnEditViewLight.toggled | 
					
						
							|  |  |  |     property alias usePerspective: btnPerspective.toggled | 
					
						
							| 
									
										
										
										
											2019-10-15 14:54:20 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |     property Node selectedNode: null // This is non-null only in single selection case
 | 
					
						
							|  |  |  |     property var selectedNodes: [] // All selected nodes
 | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |     property var lightGizmos: [] | 
					
						
							|  |  |  |     property var cameraGizmos: [] | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |     property var selectionBoxes: [] | 
					
						
							| 
									
										
										
										
											2019-11-07 10:46:14 +02:00
										 |  |  |     property rect viewPortRect: Qt.rect(0, 0, 1000, 1000) | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |     signal selectionChanged(var selectedNodes) | 
					
						
							| 
									
										
										
										
											2019-10-31 10:46:14 +02:00
										 |  |  |     signal commitObjectProperty(var object, var propName) | 
					
						
							|  |  |  |     signal changeObjectProperty(var object, var propName) | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |     function ensureSelectionBoxes(count) { | 
					
						
							|  |  |  |         var needMore = count - selectionBoxes.length | 
					
						
							|  |  |  |         if (needMore > 0) { | 
					
						
							|  |  |  |             var component = Qt.createComponent("SelectionBox.qml"); | 
					
						
							|  |  |  |             if (component.status === Component.Ready) { | 
					
						
							|  |  |  |                 for (var i = 0; i < needMore; ++i) { | 
					
						
							|  |  |  |                     var geometryName = _generalHelper.generateUniqueName("SelectionBoxGeometry"); | 
					
						
							|  |  |  |                     var box = component.createObject(mainSceneHelpers, {"view3D": editView, | 
					
						
							|  |  |  |                                                      "geometryName": geometryName}); | 
					
						
							|  |  |  |                     selectionBoxes[selectionBoxes.length] = box; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-10-25 15:25:21 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |     function selectObjects(objects) { | 
					
						
							|  |  |  |         // Create selection boxes as necessary. One more box than is actually needed is created, so
 | 
					
						
							|  |  |  |         // that we always have a previously created box to use for new selection.
 | 
					
						
							|  |  |  |         // This fixes an occasional visual glitch when creating a new box.
 | 
					
						
							|  |  |  |         ensureSelectionBoxes(objects.length + 1) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         var i; | 
					
						
							|  |  |  |         for (i = 0; i < objects.length; ++i) | 
					
						
							|  |  |  |             selectionBoxes[i].targetNode = objects[i]; | 
					
						
							|  |  |  |         for (i = objects.length; i < selectionBoxes.length; ++i) | 
					
						
							|  |  |  |             selectionBoxes[i].targetNode = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         selectedNodes = objects; | 
					
						
							|  |  |  |         if (objects.length === 0 || objects.length > 1) | 
					
						
							|  |  |  |             selectedNode = null; | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             selectedNode = objects[0]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function handleObjectClicked(object, multi) { | 
					
						
							| 
									
										
										
										
											2019-11-21 17:37:09 +02:00
										 |  |  |         var theObject = object; | 
					
						
							|  |  |  |         if (btnSelectGroup.selected) { | 
					
						
							|  |  |  |             while (theObject && theObject.parent !== scene) | 
					
						
							|  |  |  |                 theObject = theObject.parent; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |         // Object selection logic:
 | 
					
						
							|  |  |  |         // Regular click: Clear any multiselection, single-selects the clicked object
 | 
					
						
							|  |  |  |         // Ctrl-click: No objects selected: Act as single select
 | 
					
						
							|  |  |  |         //             One or more objects selected: Multiselect
 | 
					
						
							|  |  |  |         // Null object always clears entire selection
 | 
					
						
							|  |  |  |         var newSelection = []; | 
					
						
							|  |  |  |         if (object !== null) { | 
					
						
							|  |  |  |             if (multi && selectedNodes.length > 0) { | 
					
						
							|  |  |  |                 var deselect = false; | 
					
						
							|  |  |  |                 for (var i = 0; i < selectedNodes.length; ++i) { | 
					
						
							|  |  |  |                     // Multiselecting already selected object clears that object from selection
 | 
					
						
							|  |  |  |                     if (selectedNodes[i] !== object) | 
					
						
							|  |  |  |                         newSelection[newSelection.length] = selectedNodes[i]; | 
					
						
							|  |  |  |                     else | 
					
						
							|  |  |  |                         deselect = true; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 if (!deselect) | 
					
						
							|  |  |  |                     newSelection[newSelection.length] = object; | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 newSelection[0] = theObject; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         selectObjects(newSelection); | 
					
						
							|  |  |  |         selectionChanged(newSelection); | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function addLightGizmo(obj) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-12-11 16:00:28 +02:00
										 |  |  |         // Insert into first available gizmo
 | 
					
						
							|  |  |  |         for (var i = 0; i < lightGizmos.length; ++i) { | 
					
						
							|  |  |  |             if (!lightGizmos[i].targetNode) { | 
					
						
							|  |  |  |                 lightGizmos[i].targetNode = obj; | 
					
						
							|  |  |  |                 return; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // No free gizmos available, create a new one
 | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |         var component = Qt.createComponent("LightGizmo.qml"); | 
					
						
							|  |  |  |         if (component.status === Component.Ready) { | 
					
						
							|  |  |  |             var gizmo = component.createObject(overlayScene, | 
					
						
							| 
									
										
										
										
											2019-11-13 13:42:43 +02:00
										 |  |  |                                                {"view3D": overlayView, "targetNode": obj, | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |                                                 "selectedNodes": selectedNodes}); | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |             lightGizmos[lightGizmos.length] = gizmo; | 
					
						
							| 
									
										
										
										
											2019-11-21 17:37:09 +02:00
										 |  |  |             gizmo.clicked.connect(handleObjectClicked); | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |             gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;}); | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function addCameraGizmo(obj) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-12-11 16:00:28 +02:00
										 |  |  |         // Insert into first available gizmo
 | 
					
						
							|  |  |  |         for (var i = 0; i < cameraGizmos.length; ++i) { | 
					
						
							|  |  |  |             if (!cameraGizmos[i].targetNode) { | 
					
						
							|  |  |  |                 cameraGizmos[i].targetNode = obj; | 
					
						
							|  |  |  |                 return; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         // No free gizmos available, create a new one
 | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |         var component = Qt.createComponent("CameraGizmo.qml"); | 
					
						
							|  |  |  |         if (component.status === Component.Ready) { | 
					
						
							| 
									
										
										
										
											2019-11-15 15:20:31 +02:00
										 |  |  |             var geometryName = _generalHelper.generateUniqueName("CameraGeometry"); | 
					
						
							| 
									
										
										
										
											2019-11-07 10:46:14 +02:00
										 |  |  |             var gizmo = component.createObject( | 
					
						
							|  |  |  |                         overlayScene, | 
					
						
							|  |  |  |                         {"view3D": overlayView, "targetNode": obj, "geometryName": geometryName, | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |                          "viewPortRect": viewPortRect, "selectedNodes": selectedNodes}); | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |             cameraGizmos[cameraGizmos.length] = gizmo; | 
					
						
							| 
									
										
										
										
											2019-11-21 17:37:09 +02:00
										 |  |  |             gizmo.clicked.connect(handleObjectClicked); | 
					
						
							| 
									
										
										
										
											2019-11-07 10:46:14 +02:00
										 |  |  |             gizmo.viewPortRect = Qt.binding(function() {return viewPortRect;}); | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |             gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;}); | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Work-around the fact that the projection matrix for the camera is not calculated until
 | 
					
						
							|  |  |  |     // the first frame is rendered, so any initial calls to mapFrom3DScene() will fail.
 | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |     Component.onCompleted: { | 
					
						
							|  |  |  |         selectObjects([]); | 
					
						
							|  |  |  |         _generalHelper.requestOverlayUpdate(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 15:20:31 +02:00
										 |  |  |     onWidthChanged: _generalHelper.requestOverlayUpdate(); | 
					
						
							|  |  |  |     onHeightChanged: _generalHelper.requestOverlayUpdate(); | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |     Node { | 
					
						
							|  |  |  |         id: overlayScene | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |         PerspectiveCamera { | 
					
						
							|  |  |  |             id: overlayPerspectiveCamera | 
					
						
							|  |  |  |             clipFar: editPerspectiveCamera.clipFar | 
					
						
							| 
									
										
										
										
											2019-11-04 16:03:07 +02:00
										 |  |  |             clipNear: editPerspectiveCamera.clipNear | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |             position: editPerspectiveCamera.position | 
					
						
							|  |  |  |             rotation: editPerspectiveCamera.rotation | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         OrthographicCamera { | 
					
						
							|  |  |  |             id: overlayOrthoCamera | 
					
						
							| 
									
										
										
										
											2019-11-04 16:03:07 +02:00
										 |  |  |             clipFar: editOrthoCamera.clipFar | 
					
						
							|  |  |  |             clipNear: editOrthoCamera.clipNear | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |             position: editOrthoCamera.position | 
					
						
							|  |  |  |             rotation: editOrthoCamera.rotation | 
					
						
							| 
									
										
										
										
											2019-11-15 15:20:31 +02:00
										 |  |  |             scale: editOrthoCamera.scale | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-10 13:14:30 +02:00
										 |  |  |         MouseArea3D { | 
					
						
							|  |  |  |             id: gizmoDragHelper | 
					
						
							|  |  |  |             view3D: overlayView | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |         MoveGizmo { | 
					
						
							|  |  |  |             id: moveGizmo | 
					
						
							|  |  |  |             scale: autoScale.getScale(Qt.vector3d(5, 5, 5)) | 
					
						
							|  |  |  |             highlightOnHover: true | 
					
						
							|  |  |  |             targetNode: viewWindow.selectedNode | 
					
						
							| 
									
										
										
										
											2019-11-26 11:25:12 +02:00
										 |  |  |             globalOrientation: btnLocalGlobal.toggled | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |             visible: selectedNode && btnMove.selected | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |             view3D: overlayView | 
					
						
							| 
									
										
										
										
											2019-12-10 13:14:30 +02:00
										 |  |  |             dragHelper: gizmoDragHelper | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-31 10:46:14 +02:00
										 |  |  |             onPositionCommit: viewWindow.commitObjectProperty(selectedNode, "position") | 
					
						
							|  |  |  |             onPositionMove: viewWindow.changeObjectProperty(selectedNode, "position") | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ScaleGizmo { | 
					
						
							|  |  |  |             id: scaleGizmo | 
					
						
							|  |  |  |             scale: autoScale.getScale(Qt.vector3d(5, 5, 5)) | 
					
						
							|  |  |  |             highlightOnHover: true | 
					
						
							|  |  |  |             targetNode: viewWindow.selectedNode | 
					
						
							| 
									
										
										
										
											2019-11-18 13:10:54 +02:00
										 |  |  |             globalOrientation: false | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |             visible: selectedNode && btnScale.selected | 
					
						
							| 
									
										
										
										
											2019-10-31 10:46:14 +02:00
										 |  |  |             view3D: overlayView | 
					
						
							| 
									
										
										
										
											2019-12-10 13:14:30 +02:00
										 |  |  |             dragHelper: gizmoDragHelper | 
					
						
							| 
									
										
										
										
											2019-10-31 10:46:14 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             onScaleCommit: viewWindow.commitObjectProperty(selectedNode, "scale") | 
					
						
							|  |  |  |             onScaleChange: viewWindow.changeObjectProperty(selectedNode, "scale") | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-04 16:03:07 +02:00
										 |  |  |         RotateGizmo { | 
					
						
							|  |  |  |             id: rotateGizmo | 
					
						
							|  |  |  |             scale: autoScale.getScale(Qt.vector3d(7, 7, 7)) | 
					
						
							|  |  |  |             highlightOnHover: true | 
					
						
							|  |  |  |             targetNode: viewWindow.selectedNode | 
					
						
							| 
									
										
										
										
											2019-11-26 11:25:12 +02:00
										 |  |  |             globalOrientation: btnLocalGlobal.toggled | 
					
						
							| 
									
										
										
										
											2019-11-04 16:03:07 +02:00
										 |  |  |             visible: selectedNode && btnRotate.selected | 
					
						
							|  |  |  |             view3D: overlayView | 
					
						
							| 
									
										
										
										
											2019-12-10 13:14:30 +02:00
										 |  |  |             dragHelper: gizmoDragHelper | 
					
						
							| 
									
										
										
										
											2019-11-04 16:03:07 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             onRotateCommit: viewWindow.commitObjectProperty(selectedNode, "rotation") | 
					
						
							|  |  |  |             onRotateChange: viewWindow.changeObjectProperty(selectedNode, "rotation") | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |         AutoScaleHelper { | 
					
						
							|  |  |  |             id: autoScale | 
					
						
							|  |  |  |             view3D: overlayView | 
					
						
							| 
									
										
										
										
											2019-10-25 11:45:52 +03:00
										 |  |  |             position: moveGizmo.scenePosition | 
					
						
							| 
									
										
										
										
											2019-12-03 14:16:42 +02:00
										 |  |  |             orientation: moveGizmo.orientation | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-10-23 15:40:55 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  |     Rectangle { | 
					
						
							|  |  |  |         anchors.fill: parent | 
					
						
							| 
									
										
										
										
											2019-10-15 14:54:20 +03:00
										 |  |  |         focus: true | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-25 15:11:34 +02:00
										 |  |  |         gradient: Gradient { | 
					
						
							|  |  |  |             GradientStop { position: 1.0; color: "#222222" } | 
					
						
							|  |  |  |             GradientStop { position: 0.0; color: "#999999" } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |         MouseArea { | 
					
						
							|  |  |  |             anchors.fill: parent | 
					
						
							|  |  |  |             acceptedButtons: Qt.LeftButton | 
					
						
							|  |  |  |             onClicked: { | 
					
						
							|  |  |  |                 var pickResult = editView.pick(mouse.x, mouse.y); | 
					
						
							| 
									
										
										
										
											2019-11-29 17:28:11 +02:00
										 |  |  |                 handleObjectClicked(_generalHelper.resolvePick(pickResult.objectHit), | 
					
						
							|  |  |  |                                     mouse.modifiers & Qt.ControlModifier); | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |                 if (!pickResult.objectHit) | 
					
						
							|  |  |  |                     mouse.accepted = false; | 
					
						
							| 
									
										
										
										
											2019-10-23 15:40:55 +03:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 10:51:09 +02:00
										 |  |  |         DropArea { | 
					
						
							|  |  |  |             anchors.fill: parent | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 14:54:20 +03:00
										 |  |  |         View3D { | 
					
						
							|  |  |  |             id: editView | 
					
						
							|  |  |  |             anchors.fill: parent | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |             camera: usePerspective ? editPerspectiveCamera : editOrthoCamera | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |             Node { | 
					
						
							|  |  |  |                 id: mainSceneHelpers | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-13 17:02:52 +02:00
										 |  |  |                 HelperGrid { | 
					
						
							|  |  |  |                     id: helperGrid | 
					
						
							|  |  |  |                     lines: 50 | 
					
						
							|  |  |  |                     step: 50 | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 PointLight { | 
					
						
							| 
									
										
										
										
											2019-11-08 12:58:13 +02:00
										 |  |  |                     id: editLight | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |                     visible: showEditLight | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |                     position: usePerspective ? editPerspectiveCamera.position | 
					
						
							|  |  |  |                                              : editOrthoCamera.position | 
					
						
							| 
									
										
										
										
											2019-11-08 12:58:13 +02:00
										 |  |  |                     quadraticFade: 0 | 
					
						
							|  |  |  |                     linearFade: 0 | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 15:20:31 +02:00
										 |  |  |                 // Initial camera position and rotation should be such that they look at origin.
 | 
					
						
							|  |  |  |                 // Otherwise EditCameraController._lookAtPoint needs to be initialized to correct
 | 
					
						
							|  |  |  |                 // point.
 | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |                 PerspectiveCamera { | 
					
						
							|  |  |  |                     id: editPerspectiveCamera | 
					
						
							| 
									
										
										
										
											2019-11-13 17:02:52 +02:00
										 |  |  |                     z: -600 | 
					
						
							| 
									
										
										
										
											2019-11-15 15:20:31 +02:00
										 |  |  |                     y: 600 | 
					
						
							|  |  |  |                     rotation.x: 45 | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |                     clipFar: 100000 | 
					
						
							| 
									
										
										
										
											2019-11-04 16:03:07 +02:00
										 |  |  |                     clipNear: 1 | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 OrthographicCamera { | 
					
						
							|  |  |  |                     id: editOrthoCamera | 
					
						
							| 
									
										
										
										
											2019-11-13 17:02:52 +02:00
										 |  |  |                     z: -600 | 
					
						
							| 
									
										
										
										
											2019-11-15 15:20:31 +02:00
										 |  |  |                     y: 600 | 
					
						
							|  |  |  |                     rotation.x: 45 | 
					
						
							| 
									
										
										
										
											2019-11-04 16:03:07 +02:00
										 |  |  |                     clipFar: 100000 | 
					
						
							| 
									
										
										
										
											2019-11-26 11:25:12 +02:00
										 |  |  |                     clipNear: -10000 | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2019-10-15 14:54:20 +03:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |         View3D { | 
					
						
							|  |  |  |             id: overlayView | 
					
						
							|  |  |  |             anchors.fill: parent | 
					
						
							| 
									
										
										
										
											2019-10-25 14:44:55 +03:00
										 |  |  |             camera: usePerspective ? overlayPerspectiveCamera : overlayOrthoCamera | 
					
						
							| 
									
										
										
										
											2019-11-04 13:29:20 +02:00
										 |  |  |             importScene: overlayScene | 
					
						
							| 
									
										
										
										
											2019-10-15 14:54:20 +03:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-24 17:22:49 +03:00
										 |  |  |         Overlay2D { | 
					
						
							|  |  |  |             id: gizmoLabel | 
					
						
							| 
									
										
										
										
											2019-10-31 10:46:14 +02:00
										 |  |  |             targetNode: moveGizmo.visible ? moveGizmo : scaleGizmo | 
					
						
							| 
									
										
										
										
											2019-10-24 17:22:49 +03:00
										 |  |  |             targetView: overlayView | 
					
						
							| 
									
										
										
										
											2019-10-31 10:46:14 +02:00
										 |  |  |             visible: targetNode.dragging | 
					
						
							| 
									
										
										
										
											2019-10-24 17:22:49 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |             Rectangle { | 
					
						
							|  |  |  |                 color: "white" | 
					
						
							|  |  |  |                 x: -width / 2 | 
					
						
							| 
									
										
										
										
											2019-11-25 17:24:59 +02:00
										 |  |  |                 y: -height - 8 | 
					
						
							| 
									
										
										
										
											2019-10-24 17:22:49 +03:00
										 |  |  |                 width: gizmoLabelText.width + 4 | 
					
						
							|  |  |  |                 height: gizmoLabelText.height + 4 | 
					
						
							|  |  |  |                 border.width: 1 | 
					
						
							|  |  |  |                 Text { | 
					
						
							|  |  |  |                     id: gizmoLabelText | 
					
						
							|  |  |  |                     text: { | 
					
						
							|  |  |  |                         var l = Qt.locale(); | 
					
						
							| 
									
										
										
										
											2019-10-31 10:46:14 +02:00
										 |  |  |                         var targetProperty; | 
					
						
							|  |  |  |                         if (viewWindow.selectedNode) { | 
					
						
							|  |  |  |                             if (gizmoLabel.targetNode === moveGizmo) | 
					
						
							|  |  |  |                                 targetProperty = viewWindow.selectedNode.position; | 
					
						
							|  |  |  |                             else | 
					
						
							|  |  |  |                                 targetProperty = viewWindow.selectedNode.scale; | 
					
						
							|  |  |  |                             return qsTr("x:") + Number(targetProperty.x).toLocaleString(l, 'f', 1) | 
					
						
							|  |  |  |                                 + qsTr(" y:") + Number(targetProperty.y).toLocaleString(l, 'f', 1) | 
					
						
							|  |  |  |                                 + qsTr(" z:") + Number(targetProperty.z).toLocaleString(l, 'f', 1); | 
					
						
							|  |  |  |                         } else { | 
					
						
							|  |  |  |                             return ""; | 
					
						
							|  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2019-10-24 17:22:49 +03:00
										 |  |  |                     } | 
					
						
							|  |  |  |                     anchors.centerIn: parent | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 15:20:31 +02:00
										 |  |  |         EditCameraController { | 
					
						
							| 
									
										
										
										
											2019-10-15 14:54:20 +03:00
										 |  |  |             id: cameraControl | 
					
						
							| 
									
										
										
										
											2019-11-15 15:20:31 +02:00
										 |  |  |             camera: editView.camera | 
					
						
							|  |  |  |             anchors.fill: parent | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:34 +02:00
										 |  |  |             view3d: editView | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-10-15 14:54:20 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |     Rectangle { // toolbar
 | 
					
						
							|  |  |  |         id: toolbar | 
					
						
							|  |  |  |         color: "#9F000000" | 
					
						
							|  |  |  |         width: 35 | 
					
						
							|  |  |  |         height: col.height | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         Column { | 
					
						
							|  |  |  |             id: col | 
					
						
							|  |  |  |             anchors.horizontalCenter: parent.horizontalCenter | 
					
						
							|  |  |  |             spacing: 5 | 
					
						
							|  |  |  |             padding: 5 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-21 11:13:19 +02:00
										 |  |  |             property var groupSelect: [btnSelectGroup, btnSelectItem] | 
					
						
							|  |  |  |             property var groupTransform: [btnMove, btnRotate, btnScale] | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-13 17:02:52 +02:00
										 |  |  |             ToolBarButton { | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |                 id: btnSelectItem | 
					
						
							|  |  |  |                 selected: true | 
					
						
							|  |  |  |                 tooltip: qsTr("Select Item") | 
					
						
							|  |  |  |                 shortcut: "Q" | 
					
						
							|  |  |  |                 currentShortcut: selected ? "" : shortcut | 
					
						
							|  |  |  |                 tool: "item_selection" | 
					
						
							| 
									
										
										
										
											2019-11-21 11:13:19 +02:00
										 |  |  |                 buttonsGroup: col.groupSelect | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-13 17:02:52 +02:00
										 |  |  |             ToolBarButton { | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |                 id: btnSelectGroup | 
					
						
							|  |  |  |                 tooltip: qsTr("Select Group") | 
					
						
							|  |  |  |                 shortcut: "Q" | 
					
						
							|  |  |  |                 currentShortcut: btnSelectItem.currentShortcut === shortcut ? "" : shortcut | 
					
						
							|  |  |  |                 tool: "group_selection" | 
					
						
							| 
									
										
										
										
											2019-11-21 11:13:19 +02:00
										 |  |  |                 buttonsGroup: col.groupSelect | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             Rectangle { // separator
 | 
					
						
							|  |  |  |                 width: 25 | 
					
						
							|  |  |  |                 height: 1 | 
					
						
							|  |  |  |                 color: "#f1f1f1" | 
					
						
							|  |  |  |                 anchors.horizontalCenter: parent.horizontalCenter | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-13 17:02:52 +02:00
										 |  |  |             ToolBarButton { | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |                 id: btnMove | 
					
						
							| 
									
										
										
										
											2019-11-21 11:13:19 +02:00
										 |  |  |                 selected: true | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |                 tooltip: qsTr("Move current selection") | 
					
						
							| 
									
										
										
										
											2019-11-21 11:13:19 +02:00
										 |  |  |                 shortcut: "W" | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |                 currentShortcut: shortcut | 
					
						
							|  |  |  |                 tool: "move" | 
					
						
							| 
									
										
										
										
											2019-11-21 11:13:19 +02:00
										 |  |  |                 buttonsGroup: col.groupTransform | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-13 17:02:52 +02:00
										 |  |  |             ToolBarButton { | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |                 id: btnRotate | 
					
						
							|  |  |  |                 tooltip: qsTr("Rotate current selection") | 
					
						
							|  |  |  |                 shortcut: "E" | 
					
						
							|  |  |  |                 currentShortcut: shortcut | 
					
						
							|  |  |  |                 tool: "rotate" | 
					
						
							| 
									
										
										
										
											2019-11-21 11:13:19 +02:00
										 |  |  |                 buttonsGroup: col.groupTransform | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-13 17:02:52 +02:00
										 |  |  |             ToolBarButton { | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |                 id: btnScale | 
					
						
							|  |  |  |                 tooltip: qsTr("Scale current selection") | 
					
						
							| 
									
										
										
										
											2019-11-21 11:13:19 +02:00
										 |  |  |                 shortcut: "R" | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |                 currentShortcut: shortcut | 
					
						
							|  |  |  |                 tool: "scale" | 
					
						
							| 
									
										
										
										
											2019-11-21 11:13:19 +02:00
										 |  |  |                 buttonsGroup: col.groupTransform | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             Rectangle { // separator
 | 
					
						
							|  |  |  |                 width: 25 | 
					
						
							|  |  |  |                 height: 1 | 
					
						
							|  |  |  |                 color: "#f1f1f1" | 
					
						
							|  |  |  |                 anchors.horizontalCenter: parent.horizontalCenter | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             ToolBarButton { | 
					
						
							|  |  |  |                 id: btnFit | 
					
						
							|  |  |  |                 tooltip: qsTr("Fit camera to current selection") | 
					
						
							|  |  |  |                 shortcut: "F" | 
					
						
							|  |  |  |                 currentShortcut: shortcut | 
					
						
							|  |  |  |                 tool: "fit" | 
					
						
							|  |  |  |                 togglable: false | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 onSelectedChanged: { | 
					
						
							| 
									
										
										
										
											2019-11-22 16:53:36 +02:00
										 |  |  |                     if (selected) { | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |                         var targetNode = viewWindow.selectedNodes.length > 0 | 
					
						
							|  |  |  |                                 ? selectionBoxes[0].model : null; | 
					
						
							| 
									
										
										
										
											2019-11-27 15:48:51 +02:00
										 |  |  |                         cameraControl.focusObject(targetNode, editView.camera.rotation, true); | 
					
						
							| 
									
										
										
										
											2019-11-22 16:53:36 +02:00
										 |  |  |                     } | 
					
						
							| 
									
										
										
										
											2019-11-21 11:13:19 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:34 +02:00
										 |  |  |     AxisHelper { | 
					
						
							| 
									
										
										
										
											2019-11-08 15:05:36 +02:00
										 |  |  |         anchors.right: parent.right | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:34 +02:00
										 |  |  |         anchors.top: parent.top | 
					
						
							|  |  |  |         width: 100 | 
					
						
							|  |  |  |         height: width | 
					
						
							|  |  |  |         editCameraCtrl: cameraControl | 
					
						
							| 
									
										
										
										
											2019-11-26 17:56:00 +02:00
										 |  |  |         selectedNode : viewWindow.selectedNodes.length ? selectionBoxes[0].model : null | 
					
						
							| 
									
										
										
										
											2019-11-20 18:01:34 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-26 11:25:12 +02:00
										 |  |  |     Rectangle { // top controls bar
 | 
					
						
							|  |  |  |         color: "#aa000000" | 
					
						
							|  |  |  |         width: 265 | 
					
						
							|  |  |  |         height: btnPerspective.height + 10 | 
					
						
							|  |  |  |         anchors.top: parent.top | 
					
						
							|  |  |  |         anchors.right: parent.right | 
					
						
							|  |  |  |         anchors.rightMargin: 100 | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-26 11:25:12 +02:00
										 |  |  |         ToggleButton { | 
					
						
							|  |  |  |             id: btnPerspective | 
					
						
							|  |  |  |             anchors.top: parent.top | 
					
						
							|  |  |  |             anchors.topMargin: 5 | 
					
						
							|  |  |  |             anchors.left: parent.left | 
					
						
							|  |  |  |             anchors.leftMargin: 5 | 
					
						
							|  |  |  |             tooltip: qsTr("Toggle Perspective / Orthographic Projection") | 
					
						
							|  |  |  |             states: [{iconId: "ortho", text: qsTr("Orthographic")}, {iconId: "persp",  text: qsTr("Perspective")}] | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-26 11:25:12 +02:00
										 |  |  |         ToggleButton { | 
					
						
							|  |  |  |             id: btnLocalGlobal | 
					
						
							|  |  |  |             anchors.top: parent.top | 
					
						
							|  |  |  |             anchors.topMargin: 5 | 
					
						
							| 
									
										
										
										
											2019-11-25 15:11:34 +02:00
										 |  |  |             anchors.left: parent.left | 
					
						
							| 
									
										
										
										
											2019-11-26 11:25:12 +02:00
										 |  |  |             anchors.leftMargin: 100 | 
					
						
							|  |  |  |             tooltip: qsTr("Toggle Global / Local Orientation") | 
					
						
							|  |  |  |             states: [{iconId: "local",  text: qsTr("Local")}, {iconId: "global", text: qsTr("Global")}] | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-11-25 15:11:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-26 11:25:12 +02:00
										 |  |  |         ToggleButton { | 
					
						
							|  |  |  |             id: btnEditViewLight | 
					
						
							|  |  |  |             anchors.top: parent.top | 
					
						
							|  |  |  |             anchors.topMargin: 5 | 
					
						
							|  |  |  |             anchors.left: parent.left | 
					
						
							|  |  |  |             anchors.leftMargin: 165 | 
					
						
							|  |  |  |             toggleBackground: true | 
					
						
							|  |  |  |             tooltip: qsTr("Toggle Edit Light") | 
					
						
							|  |  |  |             states: [{iconId: "edit_light_off",  text: qsTr("Edit Light Off")}, {iconId: "edit_light_on", text: qsTr("Edit Light On")}] | 
					
						
							| 
									
										
										
										
											2019-10-23 16:02:56 +03:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-10-15 14:54:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Text { | 
					
						
							|  |  |  |         id: helpText | 
					
						
							| 
									
										
										
										
											2019-11-25 15:11:34 +02:00
										 |  |  |         color: "white" | 
					
						
							| 
									
										
										
										
											2019-11-15 15:20:31 +02:00
										 |  |  |         text: qsTr("Camera controls: ALT + mouse press and drag. Left: Rotate, Middle: Pan, Right/Wheel: Zoom.") | 
					
						
							| 
									
										
										
										
											2019-10-15 14:54:20 +03:00
										 |  |  |         anchors.bottom: parent.bottom | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-09-27 18:52:06 +02:00
										 |  |  | } |