Example #1
0
        private void RebuildPath()
        {
            _CurvePoints = CRSpline3D.GeneratorPathControlPoints(_Path.Keys);
            if (!_Path.UseWorldSpace)
            {
                for (int i = 0; i < _CurvePoints.Length; i++)
                {
                    _CurvePoints[i] = _Path.transform.TransformPoint(_CurvePoints[i]);
                }
            }
            _Path.transform.hasChanged = false;

            // rebuild render points
            int count = _Path.Length * _Path.SmoothAmount;

            if (_RenderPoints == null || _RenderPoints.Length != count + 1)
            {
                _RenderPoints = new Vector3[count + 1];
            }

            _RenderPoints[0] = CRSpline3D.Interpolate(_CurvePoints, 0);
            for (int i = 1; i <= count; i++)
            {
                float pm = (float)i / count;
                _RenderPoints[i] = CRSpline3D.Interpolate(_CurvePoints, pm);
            }
        }