public void Update(WSceneView view) { UpdateSelectionGizmo(view); // If we have a gizmo and we're transforming it, don't check for selection change. if (TransformGizmo != null && TransformGizmo.IsTransforming) { return; } if (WInput.GetMouseButtonDown(0) && !WInput.GetMouseButton(1)) { FRay mouseRay = view.ProjectScreenToWorld(WInput.MousePosition); var addedActor = Raycast(mouseRay); // Check the behaviour of this click to determine appropriate selection modification behaviour. // Click w/o Modifiers = Clear Selection, add result to selection // Click /w Ctrl = Toggle Selection State // Click /w Shift = Add to Selection bool ctrlPressed = WInput.GetKey(Key.LeftCtrl) || WInput.GetKey(Key.RightCtrl); bool shiftPressed = WInput.GetKey(Key.LeftShift) || WInput.GetKey(Key.RightShift); if (!ctrlPressed & !shiftPressed) { EditorSelection.ClearSelection(); if (addedActor != null) { EditorSelection.AddToSelection(addedActor); } } else if (addedActor != null && (ctrlPressed && !shiftPressed)) { if (addedActor.IsSelected) { EditorSelection.RemoveFromSelection(addedActor); } else { EditorSelection.AddToSelection(addedActor); } } else if (addedActor != null && shiftPressed) { if (!EditorSelection.SelectedObjects.Contains(addedActor)) { EditorSelection.AddToSelection(addedActor); } } UpdateGizmoTransform(); } // Add our gizmo to the renderer this frame. ((IRenderable)TransformGizmo).AddToRenderer(view); }
public void Update(WSceneView view) { if (WInput.GetMouseButton(0) && !WInput.GetMouseButton(1)) { FRay mouseRay = view.ProjectScreenToWorld(WInput.MousePosition); var addedActor = Raycast(mouseRay); // Check the behaviour of this click to determine appropriate selection modification behaviour. // Click w/o Modifiers = Clear Selection, add result to selection // Click /w Ctrl = Toggle Selection State // Click /w Shift = Add to Selection bool ctrlPressed = WInput.GetKey(Key.LeftCtrl) || WInput.GetKey(Key.RightCtrl); bool shiftPressed = WInput.GetKey(Key.LeftShift) || WInput.GetKey(Key.RightShift); if (ctrlPressed && !WInput.GetMouseButtonDown(0)) { return; } if (!ctrlPressed & !shiftPressed) { ClearSelection(); if (addedActor != null) { AddTriangleToSelection(addedActor); } } else if (addedActor != null && (ctrlPressed && !shiftPressed)) { if (addedActor.IsSelected) { RemoveTriangleFromSelection(addedActor); } else { AddTriangleToSelection(addedActor); } } else if (addedActor != null && shiftPressed) { if (!EditorSelection.SelectedObjects.Contains(addedActor)) { AddTriangleToSelection(addedActor); } } } }
private void UpdateSelectionGizmo(WSceneView view) { if (!TransformGizmo.Enabled && EditorSelection.SelectedObjects.Count > 0) { // Show the Transform Gizmo. TransformGizmo.Enabled = true; UpdateGizmoTransform(); // m_transformGizmo.SetPosition(m_selectionList[0].Transform.Position); // m_transformGizmo.SetLocalRotation(m_selectionList[0].Transform.Rotation); } else if (TransformGizmo.Enabled && EditorSelection.SelectedObjects.Count == 0) { // Hide the Transform Gizmo. TransformGizmo.Enabled = false; } if (!TransformGizmo.Enabled) { return; } if (WInput.GetKeyDown(Key.Q) && !WInput.GetMouseButton(1)) { TransformGizmo.SetMode(FTransformMode.None); } if (WInput.GetKeyDown(Key.W) && !WInput.GetMouseButton(1)) { TransformGizmo.SetMode(FTransformMode.Translation); } if (WInput.GetKeyDown(Key.E) && !WInput.GetMouseButton(1)) { TransformGizmo.SetMode(FTransformMode.Rotation); } if (WInput.GetKeyDown(Key.R) && !WInput.GetMouseButton(1)) { TransformGizmo.SetMode(FTransformMode.Scale); } if (WInput.GetKeyDown(Key.OemOpenBrackets)) { TransformGizmo.DecrementSize(); } if (WInput.GetKeyDown(Key.OemCloseBrackets)) { TransformGizmo.IncrementSize(); } if (WInput.GetKeyDown(Key.OemTilde)) { if (TransformGizmo.TransformSpace == FTransformSpace.World) { TransformGizmo.SetTransformSpace(FTransformSpace.Local); } else { TransformGizmo.SetTransformSpace(FTransformSpace.World); } UpdateGizmoTransform(); } if (WInput.GetMouseButtonDown(0)) { FRay mouseRay = view.ProjectScreenToWorld(WInput.MousePosition); if (TransformGizmo.CheckSelectedAxes(mouseRay)) { TransformGizmo.StartTransform(); } } if (WInput.GetMouseButtonUp(0)) { if (TransformGizmo.IsTransforming) { // When we end let go of the gizmo, we want to make one last action which specifies that it is done, // so that the next gizmo move doesn't merge with the previous. WUndoCommand undoAction = CreateUndoActionForGizmo(true); if (undoAction != null) { BroadcastUndoEventGenerated(undoAction); } TransformGizmo.EndTransform(); } } if (TransformGizmo.IsTransforming) { FRay mouseRay = view.ProjectScreenToWorld(WInput.MousePosition); if (TransformGizmo.TransformFromInput(mouseRay, view)) { WUndoCommand undoAction = CreateUndoActionForGizmo(false); if (undoAction != null) { BroadcastUndoEventGenerated(undoAction); } } } TransformGizmo.UpdateForSceneView(view); }
public void Update(WSceneView view) { m_View = view; UpdateSelectionGizmo(view); // Add our gizmo to the renderer this frame. if (TransformGizmo != null) { ((IRenderable)TransformGizmo).AddToRenderer(view); } // If we have a gizmo and we're transforming it, don't check for selection change. if (TransformGizmo != null && TransformGizmo.IsTransforming) { return; } if (WInput.GetMouseButtonDown(0) && !WInput.GetMouseButton(1) && !m_bOverrideSceneCamera) { FRay mouseRay = view.ProjectScreenToWorld(WInput.MousePosition); BindingVector3 addedVec = Raycast(mouseRay, view.ViewCamera); // Check the behaviour of this click to determine appropriate selection modification behaviour. // Click w/o Modifiers = Clear Selection, add result to selection // Click /w Ctrl = Toggle Selection State // Click /w Shift = Add to Selection bool ctrlPressed = WInput.GetKey(Key.LeftCtrl) || WInput.GetKey(Key.RightCtrl); bool shiftPressed = WInput.GetKey(Key.LeftShift) || WInput.GetKey(Key.RightShift); // Replace the previous selection with the current selection, if it's valid. if (!ctrlPressed & !shiftPressed) { EditorSelection.ClearSelection(); if (addedVec != null) { EditorSelection.AddToSelection(addedVec); } } else if (addedVec != null && (ctrlPressed && !shiftPressed)) { if (EditorSelection.SelectedObjects.Contains(addedVec)) { EditorSelection.RemoveFromSelection(addedVec); } else { EditorSelection.AddToSelection(addedVec); } } else if (addedVec != null && shiftPressed) { if (!EditorSelection.SelectedObjects.Contains(addedVec)) { EditorSelection.AddToSelection(addedVec); } } } if (m_CopyCameraRequest != null) { m_CopyCameraRequest.RequestingCut.CopySettingsFromCamera(view.ViewCamera, m_CopyCameraRequest.IsStart); m_CopyCameraRequest = null; } if (WInput.GetMouseButton(1) && m_bOverrideSceneCamera) { RestoreSceneCamera(view); } UpdateGizmoTransform(); }