Пример #1
0
        internal static float BezierLength(NativeArray <ShapeControlPoint> shapePoints, int splineDetail)
        {
            // Expand the Bezier.
            int   controlPointContour = shapePoints.Length - 1;
            float spd  = 0;
            float fmax = (float)(splineDetail - 1);

            for (int i = 0; i < controlPointContour; ++i)
            {
                int j = i + 1;
                ShapeControlPoint cp = shapePoints[i];
                ShapeControlPoint pp = shapePoints[j];

                Vector3 p0 = cp.position;
                Vector3 p1 = pp.position;
                Vector3 sp = p0;
                Vector3 rt = p0 + cp.rightTangent;
                Vector3 lt = p1 + pp.leftTangent;

                for (int n = 0; n < splineDetail; ++n)
                {
                    float   t  = (float)n / fmax;
                    Vector3 bp = BezierPoint(rt, p0, p1, lt, t);
                    spd += math.distance(bp, sp);
                    sp   = bp;
                }
            }

            return(spd);
        }
Пример #2
0
        public void SetTangentMode(int index, ShapeTangentMode mode)
        {
            ShapeControlPoint newPoint = m_ControlPoints[index];

            newPoint.mode          = mode;
            m_ControlPoints[index] = newPoint;
        }
Пример #3
0
        public void SetPosition(int index, Vector3 point)
        {
            if (!IsPositionValid(index, index + 1, point))
            {
                throw new ArgumentException("Internal error: Point too close to neighbor");
            }
            ShapeControlPoint newPoint = m_ControlPoints[index];

            newPoint.position      = point;
            m_ControlPoints[index] = newPoint;
        }
Пример #4
0
        public void SetPosition(int index, Vector3 point)
        {
            if (!IsPositionValid(index, index + 1, point))
            {
                throw new ArgumentException(KErrorMessage);
            }
            ShapeControlPoint newPoint = m_ControlPoints[index];

            newPoint.position      = point;
            m_ControlPoints[index] = newPoint;
        }
Пример #5
0
        public void SetRightTangent(int index, Vector3 tangent)
        {
            ShapeTangentMode mode = GetTangentMode(index);

            if (mode == ShapeTangentMode.Linear)
            {
                return;
            }

            ShapeControlPoint newPoint = m_ControlPoints[index];

            newPoint.rightTangent  = tangent;
            m_ControlPoints[index] = newPoint;
        }
    // Start is called before the first frame update
    void Start()
    {
        _spriteShapeController = GetComponent <SpriteShapeController>();

        var a = new UnityEngine.U2D.ShapeControlPoint();
    }