Beispiel #1
0
        /// <summary>
        /// Gets all Approximation points for a given spline part
        /// </summary>
        /// <param name="fromTF">start TF</param>
        /// <param name="toTF">end TF</param>
        /// <param name="includeEndPoint">Whether the end position should be included</param>
        /// <returns>an array of Approximation points</returns>
        public Vector3[] GetApproximationPoints(float fromTF, float toTF, bool includeEndPoint = true)
        {
            float startLF;
            float startFrag;
            float endLF;
            float endFrag;
            var   startSeg = TFToSegment(fromTF, out startLF);
            int   startIdx = startSeg.getApproximationIndexINTERNAL(startLF, out startFrag);
            var   endSeg   = TFToSegment(toTF, out endLF);
            int   endIdx   = endSeg.getApproximationIndexINTERNAL(endLF, out endFrag);

            var seg = startSeg;

            Vector3[] res = new Vector3[1] {
                Vector3.Lerp(seg.Approximation[startIdx], seg.Approximation[startIdx + 1], startFrag)
            };
            //if (startFrag == 1)
            //    seg = seg.NextSegment;
            while (seg && seg != endSeg)
            {
                res      = res.AddRange <Vector3>(seg.Approximation.SubArray <Vector3>(startIdx + 1, seg.Approximation.Length - 1));
                startIdx = 1;
                seg      = seg.NextSegment;
            }
            if (seg)
            {
                int i = (startSeg == seg) ? startIdx + 1 : 1;
                res = res.AddRange <Vector3>(seg.Approximation.SubArray <Vector3>(i, endIdx - i));
                if (includeEndPoint && (endFrag > 0 || endFrag < 1))
                {
                    return(res.Add <Vector3>(Vector3.Lerp(seg.Approximation[endIdx], seg.Approximation[endIdx + 1], endFrag)));
                }
            }
            return(res);
        }