Inheritance: FC3Editor.Nomad.InputBase
Beispiel #1
0
            public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs)
            {
                if (mouseEvent == Editor.MouseEvent.MouseDown)
                {
                    if (this.m_context.m_gizmoActive)
                    {
                        Vec3 position = this.m_context.m_gizmo.Position;
                        Vec3 rotationAxis = default(Vec3);
                        switch (this.m_context.m_gizmo.Active)
                        {
                        case Axis.X:
                            rotationAxis = this.m_context.m_gizmo.Axis.axisX;
                            break;

                        case Axis.Y:
                            rotationAxis = this.m_context.m_gizmo.Axis.axisY;
                            break;

                        case Axis.Z:
                            rotationAxis = this.m_context.m_gizmo.Axis.axisZ;
                            break;
                        }
                        ToolObject.RotateAction rotateAction = new ToolObject.RotateAction(this.m_context);
                        if (this.m_paramSnap.Value)
                        {
                            rotateAction.SetSnap(this.m_paramSnapSize.Value);
                        }
                        rotateAction.Start(position, rotationAxis);
                    }
                    else
                    {
                        Vec3 pos;
                        EditorObject objectFromScreenPoint = ObjectManager.GetObjectFromScreenPoint(Editor.Viewport.NormalizedMousePos, out pos);
                        if (objectFromScreenPoint.IsValid)
                        {
                            if (!this.m_context.m_selection.Contains(objectFromScreenPoint))
                            {
                                EditorObjectSelection editorObjectSelection = EditorObjectSelection.Create();
                                if ((Control.ModifierKeys & Keys.Control) != Keys.None)
                                {
                                    this.m_context.m_selection.Clone(editorObjectSelection, false);
                                }
                                this.m_context.SelectObject(editorObjectSelection, objectFromScreenPoint);
                                this.m_context.SetSelection(editorObjectSelection, objectFromScreenPoint);
                            }
                            else
                            {
                                this.m_context.SetupGizmo(objectFromScreenPoint);
                            }
                            EditorObjectPivot editorObjectPivot;
                            Vec3 position2;
                            if (objectFromScreenPoint.GetClosestPivot(pos, out editorObjectPivot))
                            {
                                position2 = editorObjectPivot.position;
                            }
                            else
                            {
                                position2 = objectFromScreenPoint.Position;
                            }
                            Vec3 rotationAxis2 = new Vec3(0f, 0f, 1f);
                            ToolObject.RotateAction rotateAction2 = new ToolObject.RotateAction(this.m_context);
                            if (this.m_paramSnap.Value)
                            {
                                rotateAction2.SetSnap(this.m_paramSnapSize.Value);
                            }
                            rotateAction2.Start(position2, rotationAxis2);
                        }
                        else
                        {
                            ToolObject.SelectAction selectAction = new ToolObject.SelectAction(this.m_context);
                            selectAction.Start();
                        }
                    }
                }
                return false;
            }
Beispiel #2
0
            public override bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs)
            {
                if (this.m_actionAlignToObject.Checked)
                {
                    return this.OnAlignToObjectMouseEvent(mouseEvent, mouseEventArgs);
                }
                if (mouseEvent == Editor.MouseEvent.MouseDown)
                {
                    if (this.m_context.m_gizmoActive)
                    {
                        UndoManager.RecordUndo();
                        if ((Control.ModifierKeys & Keys.Control) == Keys.None)
                        {
                            if ((Control.ModifierKeys & Keys.Shift) != Keys.None)
                            {
                                EditorObjectSelection editorObjectSelection = EditorObjectSelection.Create();
                                this.m_context.m_selection.Clone(editorObjectSelection, true);
                                int num = this.m_context.m_selection.IndexOf(this.m_context.m_gizmoObject);
                                this.m_context.SetSelection(editorObjectSelection, (num != -1) ? editorObjectSelection[num] : EditorObject.Null);
                            }
                            ToolObject.MoveAction moveAction = new ToolObject.MoveAction(this.m_context);
                            if (this.m_paramSnap.Value)
                            {
                                if (this.m_paramSnapObjectSize.Value && this.m_context.m_gizmoObject.IsValid)
                                {
                                    moveAction.SetSnap(this.m_context.m_gizmoObject);
                                }
                                else
                                {
                                    moveAction.SetSnap(this.m_paramSnapSize.Value);
                                }
                            }
                            moveAction.Start(this.m_context.m_gizmo.Position);
                        }
                        else
                        {
                            ToolObject.RotateAction rotateAction = new ToolObject.RotateAction(this.m_context);
                            Vec3 rotationAxis = default(Vec3);
                            switch (this.m_context.m_gizmo.Active)
                            {
                            case Axis.X:
                                rotationAxis = this.m_context.m_gizmo.Axis.axisX;
                                break;

                            case Axis.Y:
                                rotationAxis = this.m_context.m_gizmo.Axis.axisY;
                                break;

                            case Axis.Z:
                                rotationAxis = this.m_context.m_gizmo.Axis.axisZ;
                                break;
                            }
                            rotateAction.Start(this.m_context.m_gizmo.Position, rotationAxis);
                        }
                    }
                    else
                    {
                        UndoManager.RecordUndo();
                        bool flag = true;
                        Vec3 vec;
                        EditorObject objectFromScreenPoint = ObjectManager.GetObjectFromScreenPoint(Editor.Viewport.NormalizedMousePos, out vec);
                        if (objectFromScreenPoint.IsValid)
                        {
                            if (!this.m_context.m_selection.Contains(objectFromScreenPoint))
                            {
                                EditorObjectSelection editorObjectSelection2 = EditorObjectSelection.Create();
                                if ((Control.ModifierKeys & Keys.Control) != Keys.None || (Control.ModifierKeys & Keys.Shift) != Keys.None)
                                {
                                    this.m_context.m_selection.Clone(editorObjectSelection2, false);
                                }
                                this.m_context.SelectObject(editorObjectSelection2, objectFromScreenPoint);
                                this.m_context.SetSelection(editorObjectSelection2, objectFromScreenPoint);
                            }
                            else
                            {
                                this.m_context.SetupGizmo(objectFromScreenPoint);
                            }
                            EditorObjectPivot editorObjectPivot;
                            Vec3 position;
                            if (this.m_paramGrabAnchor.Value && objectFromScreenPoint.GetClosestPivot(vec, out editorObjectPivot, (objectFromScreenPoint.Position - vec).Length * 1.1f))
                            {
                                position = editorObjectPivot.position;
                            }
                            else
                            {
                                position = objectFromScreenPoint.Position;
                            }
                            ToolObject.MovePhysicsAction movePhysicsAction = new ToolObject.MovePhysicsAction(this.m_context);
                            movePhysicsAction.Start(position);
                            flag = false;
                        }
                        if (flag)
                        {
                            ToolObject.SelectAction selectAction = new ToolObject.SelectAction(this.m_context);
                            selectAction.Start();
                        }
                    }
                }
                return false;
            }