예제 #1
0
    public void CreateMesh(System.Drawing.RectangleF rect, MeshDesign design)
    {
        if (activeLayers.Count == 0 || activeLayers.Count > 1)
        {
            return;
        }

        EMesh mesh = new EMesh(rect, design, activeLayers[0], this);

        activeLayers[0].AddMesh(mesh);
        SetSelected(new EMesh[] { mesh });

        ActiveHistory.Add(new CreateAction(mesh, ActiveHistory));
    }
예제 #2
0
    public void PasteSelected()
    {
        List <EMesh> newMeshes = new List <EMesh>();
        Layer        l         = ActiveLayers[0];

        foreach (EMesh m in meshClipboard)
        {
            EMesh nm = new EMesh(m, l, this);
            l.AddMesh(nm);
            newMeshes.Add(nm);
        }

        SetSelected(newMeshes);
        ActiveHistory.Add(new CreateAction(newMeshes, ActiveHistory));
    }
예제 #3
0
    public void Update()
    {
        mouse.PlaneDistance = editorCamera.Position.Z;

        cameraControl.Logic();
        editorCamera.Position = CameraControl.Position;
        editorCamera.Target   = CameraControl.Position * new Vector3(1, 1, 0);

        if (keyboard.KeyPressed(Key.Tab))
        {
            SwitchSelectMode();
        }

        if (keyboard.KeyReleased(Key.Delete))
        {
            List <EMesh> meshes = new List <EMesh>();
            foreach (EMesh m in SelectedMeshes)
            {
                meshes.Add(m);
            }

            if (meshes.Count > 0)
            {
                ActiveHistory.Add(new RemoveAction(meshes, ActiveHistory));

                foreach (EMesh m in meshes)
                {
                    m.Remove();
                }

                DeselectAll();
            }
        }

        /*
         * if (manipulatorMode == ManipulatorMode.Paint)
         * {
         *      form.CursorVisible = false;
         * }
         * else
         *      form.CursorVisible = true;
         */

        foreach (Manipulator m in manipulators)
        {
            m.UpdatePivot();
        }

        //SOME HOTKEYS
        if (form.Focused && !Manipulator.Active)
        {
            if (keyboard[Key.LControl])
            {
                //OPTIONS
                if (keyboard[Key.LShift])
                {
                    if (keyboard.KeyPressed(Key.G))
                    {
                        OptionsForm.options.ShowGrid = !OptionsForm.options.ShowGrid;
                    }
                    if (keyboard.KeyPressed(Key.L))
                    {
                        OptionsForm.options.FocusLayer = !OptionsForm.options.FocusLayer;
                    }
                    if (keyboard.KeyPressed(Key.B))
                    {
                        OptionsForm.options.MeshBorders = !OptionsForm.options.MeshBorders;
                    }
                }
                else                 //OTHER EDITOR HOTKEYS
                {
                    if (keyboard.KeyPressed(Key.D))
                    {
                        CopySelected();
                        PasteSelected();
                    }

                    if (keyboard.KeyPressed(Key.C))
                    {
                        CopySelected();
                    }
                    if (keyboard.KeyPressed(Key.V))
                    {
                        PasteSelected();
                    }

                    if (keyboard.KeyPressed(Key.Z) && ActiveLayers.Count > 0)
                    {
                        ActiveLayers[0].History.Undo();
                    }
                    if (keyboard.KeyPressed(Key.Y) && ActiveLayers.Count > 0)
                    {
                        ActiveLayers[0].History.Redo();
                    }

                    if (keyboard.KeyPressed(Key.B))
                    {
                        (manipulators[(int)ManipulatorMode.Paint] as VertexPen).ShowPalette();
                    }
                }
            }
            else
            {
                //MANIPULATOR CONTROL
                if (keyboard.KeyPressed(Key.Q))
                {
                    manipulatorMode = ManipulatorMode.None;
                }
                if (keyboard.KeyPressed(Key.W))
                {
                    manipulatorMode = ManipulatorMode.Translate;
                }
                if (keyboard.KeyPressed(Key.E))
                {
                    manipulatorMode = ManipulatorMode.Rotate;
                }
                if (keyboard.KeyPressed(Key.R))
                {
                    manipulatorMode = ManipulatorMode.Scale;
                }
                if (keyboard.KeyPressed(Key.B))
                {
                    manipulatorMode = ManipulatorMode.Paint;
                }
            }
        }

        selectionBox.Logic();
        meshCreator.Logic();

        foreach (EMesh m in Meshes)
        {
            m.Logic();
        }

        Manipulator.Logic();
    }