Esempio n. 1
0
        public override bool MouseEventPointedTriangle()
        {
            var m = MeshMGMT;

            if (EditorInputManager.GetMouseButtonDown(0))
            {
                m.Dragging              = true;
                originalPosition        = GridNavigator.collisionPos;
                GridNavigator.onGridPos = GridNavigator.collisionPos;
                draggedVertices.Clear();
                foreach (var uv in PointedTris.vertexes)
                {
                    draggedVertices.Add(uv.meshPoint);
                }
            }

            if (addToTrianglesAndLines && EditorInputManager.GetMouseButtonUp(0) && m.dragDelay > 0 && draggedVertices.Contains(PointedTris))
            {
                if (Cfg.newVerticesUnique)
                {
                    m.edMesh.InsertIntoTriangleUniqueVerticles(m.PointedTris, m.collisionPosLocal);
                }
                else
                {
                    m.edMesh.InsertIntoTriangle(m.PointedTris, m.collisionPosLocal);
                }
            }



            return(false);
        }
Esempio n. 2
0
        public override bool MouseEventPointedLine()
        {
            var m = MeshMGMT;

            if (EditorInputManager.GetMouseButtonDown(0))
            {
                m.Dragging              = true;
                originalPosition        = GridNavigator.collisionPos;
                GridNavigator.onGridPos = GridNavigator.collisionPos;
                draggedVertices.Clear();
                foreach (var uv in PointedLine.pnts)
                {
                    draggedVertices.Add(uv.meshPoint);
                }
            }

            if (EditorInputManager.GetMouseButtonUp(0))
            {
                if (addToTrianglesAndLines && m.dragDelay > 0 && draggedVertices.Contains(PointedLine))
                {
                    MeshMGMT.edMesh.InsertIntoLine(MeshMGMT.PointedLine.pnts[0].meshPoint, MeshMGMT.PointedLine.pnts[1].meshPoint, MeshMGMT.collisionPosLocal);
                }
            }

            return(false);
        }
Esempio n. 3
0
        public override void ManageDragging()
        {
            if (PointedTris != null && SelectedUV != null)
            {
                Vector2 uv        = SelectedUV.SharedEditedUV;
                Vector2 posUV     = PointedTris.LocalPosToEditedUV(MeshMGMT.collisionPosLocal);
                Vector2 newUV     = uv * 2 - posUV;
                bool    isChanged = newUV != lastCalculatedUV;
                lastCalculatedUV = newUV;

                if (isChanged && !EditorInputManager.GetMouseButtonUp(0))
                {
                    var prMesh = FreshPreviewMesh;
                    if (prMesh.selectedUV != null)
                    {
                        prMesh.selectedUV.SharedEditedUV      = lastCalculatedUV;
                        MeshMGMT.target.meshFilter.sharedMesh = new MeshConstructor(prMesh, MeshMGMT.target.MeshProfile, MeshMGMT.target.meshFilter.sharedMesh).Construct();
                    }
                }
            }

            if (EditorInputManager.GetMouseButtonUp(0))
            {
                MeshMGMT.SelectedUV.SharedEditedUV = lastCalculatedUV;
                EditedMesh.Dirty  = true;
                MeshMGMT.Dragging = false;
            }


            if (!EditorInputManager.GetMouseButton(0))
            {
                MeshMGMT.Dragging = false;
            }
        }
Esempio n. 4
0
        public override void ManageDragging()
        {
            var m = MeshMGMT;

            bool beforeCouldDrag = m.dragDelay <= 0;

            if (EditorInputManager.GetMouseButtonUp(0) || !EditorInputManager.GetMouseButton(0))
            {
                m.Dragging = false;

                if (beforeCouldDrag)
                {
                    EditedMesh.dirty_Position = true;
                }
                else
                if ((m.TrisVerts < 3) && (m.SelectedUV != null) && (!m.IsInTrisSet(m.SelectedUV.meshPoint)))
                {
                    m.AddToTrisSet(m.SelectedUV);
                }
            }
            else
            {
                m.dragDelay -= Time.deltaTime;

                bool canDrag = m.dragDelay <= 0;

                if (beforeCouldDrag != canDrag && EditorInputManager.getAltKey() && (m.SelectedUV.meshPoint.uvpoints.Count > 1))
                {
                    m.DisconnectDragged();
                }

                if (canDrag || !Application.isPlaying)
                {
                    if ((GridNavigator.Inst().AngGridToCamera(GridNavigator.onGridPos) < 82))
                    {
                        Vector3 delta = GridNavigator.onGridPos - originalPosition;

                        if (delta.magnitude > 0)
                        {
                            m.TrisVerts = 0;

                            foreach (var v in draggedVertices)
                            {
                                v.WorldPos += delta;
                            }

                            originalPosition = GridNavigator.onGridPos;
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        public override void ManageDragging()
        {
            var m = MeshMGMT;

            var beforeCouldDrag = m.DragDelay <= 0;

            if (EditorInputManager.GetMouseButtonUp(0) || !EditorInputManager.GetMouseButton(0))
            {
                m.Dragging = false;

                if (beforeCouldDrag)
                {
                    EditedMesh.dirtyPosition = true;
                }
                else
                {
                    OnClickDetected();
                }
            }
            else
            {
                var canDrag = m.DragDelay <= 0;

                if (beforeCouldDrag != canDrag && EditorInputManager.Alt && m.SelectedUv.meshPoint.vertices.Count > 1)
                {
                    m.DisconnectDragged();
                }

                if (!canDrag || !(GridNavigator.Inst().AngGridToCamera(GridNavigator.onGridPos) < 82))
                {
                    return;
                }

                var delta = GridNavigator.onGridPos - _originalPosition;

                if (delta.magnitude == 0)
                {
                    return;
                }

                m.TriVertices = 0;

                foreach (var v in _draggedVertices)
                {
                    v.WorldPos += delta;
                }

                _originalPosition = GridNavigator.onGridPos;
            }
        }
Esempio n. 6
0
        public override void ManageDragging()
        {
            if (PointedTriangle != null && SelectedUv != null)
            {
                var uv        = SelectedUv.SharedEditedUv;
                var posUv     = PointedTriangle.LocalPosToEditedUv(MeshMGMT.collisionPosLocal);
                var newUv     = uv * 2 - posUv;
                var isChanged = newUv != _lastCalculatedUv;
                _lastCalculatedUv = newUv;

                var trg = MeshEditorManager.target;

                if (isChanged && !EditorInputManager.GetMouseButtonUp(0))
                {
                    var prMesh = GetPreviewMesh;
                    if (prMesh.selectedUv != null)
                    {
                        prMesh.selectedUv.SharedEditedUv = _lastCalculatedUv;
                        trg.SharedMesh = new MeshConstructor(prMesh, trg.MeshProfile, trg.SharedMesh).Construct();
                    }
                }
            }

            if (EditorInputManager.GetMouseButtonUp(0))
            {
                MeshMGMT.SelectedUv.SharedEditedUv = _lastCalculatedUv;
                EditedMesh.dirtyUvs = true;
                Debug.Log("Setting Dirty UV Test");
                MeshMGMT.Dragging = false;
            }


            if (!EditorInputManager.GetMouseButton(0))
            {
                MeshMGMT.Dragging = false;
            }
        }