Beispiel #1
0
        public void AddPoint(Vector2 mousePosition)
        {
            Undo.RecordObject(TargetCurcuit, "Add Bezier Point");

            Vector2 direction = SelectedPath.Count > 0
                ? SelectedPath[SelectedPath.Count - 1].Anchor - mousePosition : Vector2.right;

            BezierPoint newPoint = new BezierPoint(
                HandleTransform.InverseTransformPoint(mousePosition),
                direction
                );

            SelectedPath.AddPoint(
                newPoint
                );

            SelectedBezierPoint = newPoint;
            SelectedSegment     = new Vector2Int(-1, -1);
        }
Beispiel #2
0
        /**
         * Returns the average position of the selected vertices in model space.
         */
        public HandleTransform GetHandleTransform()
        {
            Vector3 v = Vector3.zero;
            int len = _userIndices.Count;
            Vector3[] vertices = mesh.vertices;

            for(int i = 0; i < len; i++)
                v += vertices[_userIndices[i]];

            HandleTransform handle = new HandleTransform();
            if( len > 0 ) handle.position = v / (float)len;
            handle.rotation = Quaternion.identity;
            handle.scale = Vector3.one;

            return handle;
        }