コード例 #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
ファイル: Spline.cs プロジェクト: 8blazer/Terrain-Generator
        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;
        }
コード例 #6
0
    // Start is called before the first frame update
    void Start()
    {
        _spriteShapeController = GetComponent <SpriteShapeController>();

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