Пример #1
0
        private WUndoCommand CreateUndoActionForGizmo(bool isDone)
        {
            WUndoCommand undoAction = null;

            var actors = EditorSelection.SelectedObjects;

            switch (TransformGizmo.Mode)
            {
            case FTransformMode.Translation:
                undoAction = new WTranslateActorAction(actors, this, TransformGizmo.DeltaTranslation, TransformGizmo.TransformSpace, isDone);
                break;

            case FTransformMode.Rotation:
                undoAction = new WRotateActorAction(actors, this, TransformGizmo.DeltaRotation, TransformGizmo.TransformSpace, isDone);
                break;

            case FTransformMode.Scale:
                undoAction = new WScaleActorAction(actors, this, TransformGizmo.DeltaScale, isDone);
                Console.WriteLine(TransformGizmo.DeltaScale);
                break;

            default:
                break;
            }

            return(undoAction);
        }
Пример #2
0
        private WUndoCommand CreateUndoActionForGizmo(bool isDone)
        {
            WUndoCommand undoAction = null;

            var props = EditorSelection.SelectedObjects;

            switch (TransformGizmo.Mode)
            {
            case FTransformMode.Translation:
                undoAction = new WTranslateCameraPropertyAction(props, this, TransformGizmo.DeltaTranslation, TransformGizmo.TransformSpace, isDone);
                break;

            default:
                break;
            }

            return(undoAction);
        }
Пример #3
0
 public void BroadcastUndoEventGenerated(WUndoCommand command)
 {
     GenerateUndoEvent?.Invoke(this, new GenerateUndoEventArgs(command));
 }
Пример #4
0
        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);
        }
Пример #5
0
 public GenerateUndoEventArgs(WUndoCommand com)
 {
     Command = com;
 }