예제 #1
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;
            }
        }
예제 #2
0
        public override bool MouseEventPointedTriangle()
        {
            if (EditorInputManager.GetMouseButton(0))
            {
                if (ProjectionUV)
                {
                    if (PointedTris.SameAsLastFrame)
                    {
                        return(true);
                    }

                    if (MeshMGMT.SelectedUV == null)
                    {
                        MeshMGMT.SelectedUV = EditedMesh.meshPoints[0].uvpoints[0];
                    }

                    Vector3 trgPos = MeshMGMT.target.transform.position;
                    // float portion = 1f / Mathf.Max(0.01f, MeshUVprojectionSize);

                    for (int i = 0; i < 3; i++)
                    {
                        PointedTris.vertexes[i].EditedUV = PosToUV(PointedTris.vertexes[i].meshPoint.WorldPos - trgPos);
                    }

                    EditedMesh.Dirty = true;

                    return(true);
                }
            }
            return(false);
        }
예제 #3
0
        public void AddToTrisSet(Vertex nuv)
        {
            TrisSet[TrisVerts] = nuv;
            TrisVerts++;

            if (TrisVerts == 3)
            {
                foreach (Triangle t in edMesh.triangles)
                {
                    if (t.IsSamePoints(TrisSet))
                    {
                        t.Set(TrisSet);
                        edMesh.Dirty = true;
                        TrisVerts    = 0;
                        return;
                    }
                }
            }

            if (TrisVerts >= 3)
            {
                Triangle td = new Triangle(TrisSet);
                edMesh.triangles.Add(td);

                if (!EditorInputManager.getControlKey())
                {
                    MakeTriangleVertUnique(td, TrisSet[0]);
                    MakeTriangleVertUnique(td, TrisSet[1]);
                    MakeTriangleVertUnique(td, TrisSet[2]);
                }

                TrisVerts    = 0;
                edMesh.Dirty = true;
            }
        }
예제 #4
0
    public void FeedEvent(Event e)
    {
        if (!rendy || !rendy.enabled)
        {
            return;
        }

        if (e.isMouse)
        {
            UpdatePositions();
        }

        if (e.type == EventType.ScrollWheel)
        {
            ScrollsProcess(e.delta.y);
            UpdatePositions();
            e.Use();
        }

        if (EditorInputManager.GetMouseButtonDown(2))
        {
            RaycastHit hit;
            if (Physics.Raycast(EditorInputManager.GetScreenRay(), out hit))
            {
                onGridPos = hit.point;
            }
        }
    }
예제 #5
0
        public override bool MouseEventPointedVertex()
        {
            if (EditorInputManager.GetMouseButtonDown(0))
            {
                MeshMGMT.AssignSelected(PointedUv); //pointedUV.editedUV = meshMGMT.selectedUV.editedUV;
                _lastCalculatedUv = PointedUv.EditedUv;
                MeshMGMT.Dragging = true;
            }

            /*
             * if (EditorInputManager.GetMouseButtonDown(0))
             * {
             *  if ((meshMGMT.selectedUV != null) && (meshMGMT.pointedUV != null))
             *  {
             *      meshMGMT.pointedUV.editedUV = meshMGMT.selectedUV.editedUV;
             *      mesh.dirty = true;
             *  }
             * }
             *
             * if ((EditorInputManager.GetMouseButtonDown(1)) && (meshMGMT.pointedUV != null) && (UVnavigator.inst() != null))
             *  UVnavigator.inst().CenterOnUV(meshMGMT.pointedUV.editedUV);
             */
            /*
             * if (ProjectionUV && EditorInputManager.GetMouseButton(0)) {
             * Vector3 trgPos = meshMGMT.target.transform.position;
             * float portion = 1f / Mathf.Max(0.01f, MeshUVprojectionSize);
             *
             * Vector2 nuv = PosToUV((vertex.worldPos - trgPos) * portion);
             *
             * for (int i = 0; i < vertex.shared_v2s.Count; i++)
             *  vertex.shared_v2s[i][meshMGMT.editedUV] = nuv;
             * }
             */
            return(false);
        }
예제 #6
0
        private static Vector3 MouseToPlane(Plane plane)
        {
            var   ray = EditorInputManager.GetScreenMousePositionRay(TexMGMT.MainCamera);
            float rayDistance;

            return(plane.Raycast(ray, out rayDistance) ? ray.GetPoint(rayDistance) : Vector3.zero);
        }
예제 #7
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);
        }
예제 #8
0
        public override bool MouseEventPointedTriangle()
        {
            if (EditorInputManager.GetMouseButton(0))
            {
                if (PointedTris.SameAsLastFrame)
                {
                    return(true);
                }

                BrushConfig bcf = Cfg.brushConfig;

                Color c = bcf.colorLinear.ToGamma();

                foreach (var u in PointedTris.vertexes)
                {
                    foreach (var vuv in u.meshPoint.uvpoints)
                    {
                        bcf.mask.Transfer(ref vuv._color, c);
                    }
                }

                //  a.vert.SetColorOnLine(c, bcf.mask, b.vert);//setColor(glob.colorSampler.color, glob.colorSampler.mask);
                // b.vert.SetColorOnLine(c, bcf.mask, a.vert);
                MeshMGMT.edMesh.dirty_Color = true;
                return(true);
            }
            return(false);
        }
예제 #9
0
 public override void MouseEventPointedNothing()
 {
     if (EditorInputManager.GetMouseButtonDown(0))
     {
         MeshMGMT.AddPoint(MeshMGMT.onGridLocal);
     }
 }
예제 #10
0
        public void FeedEvent(Event e)
        {
            if (!rendy || !rendy.enabled)
            {
                return;
            }

            if (e.isMouse)
            {
                UpdatePositions();
            }


            if (e.type == EventType.KeyDown)
            {
                bool isHorisontal = e.keyCode == verticalPlanesKey;

                if (isHorisontal || e.keyCode == horisontalPlaneKey)
                {
                    ScrollsProcess(isHorisontal ? 1 : -1);
                    UpdatePositions();
                    e.Use();
                }
            }

            if (EditorInputManager.GetMouseButtonDown(2))
            {
                RaycastHit hit;
                if (Physics.Raycast(EditorInputManager.GetScreenMousePositionRay(TexMGMT.MainCamera), out hit))
                {
                    onGridPos = hit.point;
                }
            }
        }
예제 #11
0
        public override bool MouseEventPointedVertex()
        {
            MeshManager m = MeshMGMT;

            BrushConfig bcf = GlobalBrush;

            //if (EditorInputManager.GetMouseButtonDown(1))
            //  m.pointedUV.vert.clearColor(cfg.brushConfig.mask);

            if ((EditorInputManager.GetMouseButtonDown(0)))
            {
                if (EditorInputManager.getControlKey())
                {
                    bcf.mask.Transfer(ref m.PointedUV._color, bcf.colorLinear.ToGamma());
                }

                else
                {
                    foreach (Vertex uvi in m.PointedUV.meshPoint.uvpoints)
                    {
                        bcf.mask.Transfer(ref uvi._color, Cfg.brushConfig.colorLinear.ToGamma());
                    }
                }

                m.edMesh.dirty_Color = true;
            }

            return(false);
        }
예제 #12
0
        public override bool MouseEventPointedLine()
        {
            if (EditorInputManager.GetMouseButton(0))
            {
                if (MergeUnmerge)
                {
                    if (!EditorInputManager.getShiftKey())
                    {
                        Dirty |= PointedLine.AllVerticesShared();
                    }
                    else
                    {
                        Dirty |= PointedLine.GiveUniqueVerticesToTriangles();
                    }
                }
                else
                {
                    for (int i = 0; i < 2; i++)
                    {
                        Dirty |= PointedLine[i].SetSmoothNormal(!EditorInputManager.getShiftKey());
                    }
                }
            }

            return(false);
        }
예제 #13
0
파일: MeshTools.cs 프로젝트: Hengle/Tools-3
        public override bool MouseEventPointedTriangle()
        {
            if (EditorInputManager.GetMouseButtonDown(0) && EditorInputManager.Control)
            {
                _curSubMesh = MeshMGMT.PointedTriangle.subMeshIndex;
#if PEGI
                ("SubMesh " + _curSubMesh).showNotificationIn3D_Views();
#endif
            }

            if (!EditorInputManager.GetMouseButton(0) || EditorInputManager.Control ||
                (MeshMGMT.PointedTriangle.subMeshIndex == _curSubMesh))
            {
                return(false);
            }

            if (PointedTriangle.SameAsLastFrame)
            {
                return(true);
            }

            MeshMGMT.PointedTriangle.subMeshIndex = _curSubMesh;
            EditedMesh.subMeshCount = Mathf.Max(MeshMGMT.PointedTriangle.subMeshIndex + 1, EditedMesh.subMeshCount);
            EditedMesh.Dirty        = true;

            return(true);
        }
예제 #14
0
파일: MeshTools.cs 프로젝트: Hengle/Tools-3
 public override void MouseEventPointedNothing()
 {
     if (_addToTrianglesAndLines && EditorInputManager.GetMouseButtonDown(0))
     {
         MeshMGMT.CreatePointAndFocus(MeshMGMT.onGridLocal);
     }
 }
예제 #15
0
파일: MeshTools.cs 프로젝트: Hengle/Tools-3
        public override bool MouseEventPointedLine()
        {
            if (!EditorInputManager.GetMouseButton(0))
            {
                return(false);
            }

            var vrtA = PointedLine.points[0].meshPoint;
            var vrtB = PointedLine.points[1].meshPoint;

            if (EditorInputManager.Control)
            {
                _edgeValue = (vrtA.edgeStrength + vrtB.edgeStrength) * 0.5f;
            }
            else
            {
                if (PointedLine.SameAsLastFrame)
                {
                    return(true);
                }


                PutEdgeOnLine(PointedLine);

                return(true);
            }
            return(false);
        }
예제 #16
0
파일: MeshTools.cs 프로젝트: Hengle/Tools-3
        public override bool MouseEventPointedTriangle()
        {
            if (!EditorInputManager.GetMouseButton(0))
            {
                return(false);
            }

            if (PointedTriangle.SameAsLastFrame)
            {
                return(true);
            }

            var bcf = Cfg.brushConfig;

            var c = bcf.Color;

            foreach (var u in PointedTriangle.vertexes)
            {
                foreach (var vuv in u.meshPoint.vertices)
                {
                    bcf.mask.SetValuesOn(ref vuv.color, c);
                }
            }

            EditedMesh.dirtyColor = true;
            return(true);
        }
예제 #17
0
파일: MeshTools.cs 프로젝트: Hengle/Tools-3
        public override bool MouseEventPointedVertex()
        {
            var m = MeshMGMT;

            var bcf = GlobalBrush;

            //if (EditorInputManager.GetMouseButtonDown(1))
            //  m.pointedUV.vert.clearColor(cfg.brushConfig.mask);

            if ((EditorInputManager.GetMouseButtonDown(0)))
            {
                if (EditorInputManager.Control)
                {
                    bcf.mask.SetValuesOn(ref m.PointedUv.color, bcf.Color);
                }

                else
                {
                    foreach (var uvi in m.PointedUv.meshPoint.vertices)
                    {
                        bcf.mask.SetValuesOn(ref uvi.color, Cfg.brushConfig.Color);
                    }
                }

                EditedMesh.dirtyColor = true;
            }

            return(false);
        }
예제 #18
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);
        }
예제 #19
0
        public override void KeysEventPointedVertex()
        {
            var m = MeshMGMT;

            if (KeyCode.Delete.IsDown())
            {
                //Debug.Log("Deleting");
                if (!EditorInputManager.getControlKey())
                {
                    if (m.PointedUV.meshPoint.uvpoints.Count == 1)
                    {
                        if (!m.DeleteVertHEAL(MeshMGMT.PointedUV.meshPoint))
                        {
                            m.DeleteUv(MeshMGMT.PointedUV);
                        }
                    }
                    else
                    {
                        while (m.PointedUV.meshPoint.uvpoints.Count > 1)
                        {
                            m.edMesh.MoveTris(m.PointedUV.meshPoint.uvpoints[1], m.PointedUV.meshPoint.uvpoints[0]);
                        }
                    }
                }
                else
                {
                    m.DeleteUv(m.PointedUV);
                }
                m.edMesh.Dirty = true;
            }
        }
예제 #20
0
        public override bool MouseEventPointedTriangle()
        {
            if (EditorInputManager.GetMouseButton(0))
            {
                EditedMesh.Dirty |= PointedTris.SetSharpCorners(SetTo);
            }

            return(false);
        }
예제 #21
0
        void ProcessPointOnALine(Vertex a, Vertex b, Triangle t)
        {
            if (EditorInputManager.GetMouseButtonDown(1))
            {
                SelectedLine = new LineData(t, a, b);
                UpdateLocalSpaceV3s();
            }

            PointedLine = new LineData(t, new Vertex[] { a, b });
        }
예제 #22
0
        private void ProcessPointOnALine(PainterMesh.Vertex a, PainterMesh.Vertex b, PainterMesh.Triangle t)
        {
            if (EditorInputManager.GetMouseButtonDown(1))
            {
                SelectedLine = new PainterMesh.LineData(t, a, b);
                UpdateLocalSpaceMousePosition();
            }

            PointedLine = new PainterMesh.LineData(t, new[] { a, b });
        }
예제 #23
0
        public void CombinedUpdate()
        {
            if (target == null)
            {
                return;
            }

            if (!target.enabled)
            {
                DisconnectMesh();
                return;
            }

            int no = EditorInputManager.GetNumberKeyDown();

            SelectingUVbyNumber = false;
            if (no != -1)
            {
                currentUV = no - 1; SelectingUVbyNumber = true;
            }
            else
            {
                currentUV = 0;
            }

            if (Application.isPlaying)
            {
                UpdateInputPlaytime();
            }

            Grid.UpdatePositions();

            if (Application.isPlaying)
            {
                SORT_AND_UPDATE_UI();
            }

            if (edMesh.Dirty)
            {
                redoMoves.Clear();
                undoMoves.Add(edMesh.Encode().ToString());
                if (undoMoves.Count > 10)
                {
                    undoMoves.RemoveAt(0);
                }
                Redraw();
                previewMesh = null;
            }

            if (justLoaded >= 0)
            {
                justLoaded--;
            }
        }
예제 #24
0
        void ProcessPointOnALine(Vertex a, Vertex b, Triangle t)
        {
            if (EditorInputManager.GetMouseButtonDown(1))
            {
                updated = false;

                if (QuickMeshFunctions.Path.Selected())
                {
                    SetPathStart();
                }
            }
        }
예제 #25
0
파일: MeshTools.cs 프로젝트: Hengle/Tools-3
        public override bool MouseEventPointedLine()
        {
            if (EditorInputManager.GetMouseButton(0))
            {
                foreach (var t in MeshMGMT.PointedLine.GetAllTriangles())
                {
                    EditedMesh.Dirty |= t.SetSharpCorners(_setTo);
                }
            }

            return(false);
        }
예제 #26
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;
                        }
                    }
                }
            }
        }
예제 #27
0
    public static void ShowWindow()
    {
        EditorWindow thisWindow = EditorWindow.GetWindow(typeof(TrackPadTool));

        thisWindow.position = new Rect(Screen.width / 2, Screen.height / 2, 400, 600);
        thisWindow.minSize  = new Vector2(400, 600);
        thisWindow.maxSize  = new Vector2(400, 600);

        EditorInputManager.CreateInputManager();

        /* Set Input Objects */
        InputObject = GameObject.Find("EditorInput");
    }
예제 #28
0
파일: MeshTools.cs 프로젝트: Hengle/Tools-3
        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;
            }
        }
예제 #29
0
        public override void KeysEventPointedLine()
        {
            if (KeyCode.N.IsDown())
            {
                foreach (var t in MeshMGMT.PointedLine.GetAllTriangles_USES_Tris_Listing())
                {
                    t.SetSharpCorners(!EditorInputManager.getAltKey());
                }
#if !NO_PEGI
                "N ON A LINE - Make triangle normals Dominant".TeachingNotification();
#endif
                MeshMGMT.edMesh.Dirty = true;
            }
        }
예제 #30
0
 public override bool MouseEventPointedVertex()
 {
     if ((EditorInputManager.GetMouseButton(0)))
     {
         if (PointedUV.SameAsLastFrame)
         {
             return(true);
         }
         BrushConfig bcf = Cfg.brushConfig;
         bcf.colorLinear.ToV4(ref PointedVertex.shadowBake, bcf.mask);
         MeshMGMT.edMesh.Dirty = true;
         return(true);
     }
     return(false);
 }