示例#1
0
        /// <summary>
        /// When we get interpolated points we subdivide the square so our sampling has more to work with
        /// </summary>
        /// <param name="normalizedDistance"></param>
        /// <returns></returns>
        protected override Vector3 GetPointInternal(float normalizedDistance)
        {
            if (points == null || points.Length != 8)
            {
                points = new Vector3[8];
            }

            BuildPoints();

            return(LineUtils.InterpolateVectorArray(points, normalizedDistance));
        }
        /// <summary>
        /// Gets the rotation of a point along the line at the specified length
        /// </summary>
        /// <param name="normalizedLength"></param>
        /// <param name="rotationType"></param>
        /// <returns></returns>
        public Quaternion GetRotation(float normalizedLength, RotationTypeEnum rotationType = RotationTypeEnum.None)
        {
            rotationType = (rotationType != RotationTypeEnum.None) ? rotationType : RotationType;
            Vector3 rotationVector = Vector3.zero;

            switch (rotationType)
            {
            case RotationTypeEnum.None:
            default:
                break;

            case RotationTypeEnum.Velocity:
                rotationVector = GetVelocity(normalizedLength);
                break;

            case RotationTypeEnum.RelativeToOrigin:
                Vector3 point  = GetPoint(normalizedLength);
                Vector3 origin = transform.TransformPoint(OriginOffset);
                rotationVector = (point - origin).normalized;
                break;
            }

            if (rotationVector.magnitude < MinRotationMagnitude)
            {
                return(transform.rotation);
            }

            Vector3 upVector = GetUpVectorInternal(normalizedLength);

            if (ManualUpVectorBlend > 0f)
            {
                Vector3 manualUpVector = LineUtils.GetVectorCollectionBlend(ManualUpVectors, normalizedLength, Loops);
                upVector = Vector3.Lerp(upVector, manualUpVector, manualUpVector.magnitude);
            }

            if (FlipUpVector)
            {
                upVector = -upVector;
            }

            return(Quaternion.LookRotation(rotationVector, upVector));
        }
        protected override Vector3 GetPointInternal(float normalizedDistance)
        {
            float totalDistance = normalizedDistance * (NumPoints - 1);

            int point1Index = Mathf.FloorToInt(totalDistance);

            point1Index -= (point1Index % 3);
            float subDistance = (totalDistance - point1Index) / 3;

            int point2Index = 0;
            int point3Index = 0;
            int point4Index = 0;

            if (!loops)
            {
                if (point1Index + 3 >= NumPoints)
                {
                    return(points[NumPoints - 1].Point);
                }
                if (point1Index < 0)
                {
                    return(points[0].Point);
                }

                point2Index = point1Index + 1;
                point3Index = point1Index + 2;
                point4Index = point1Index + 3;
            }
            else
            {
                point2Index = (point1Index + 1) % (NumPoints - 1);
                point3Index = (point1Index + 2) % (NumPoints - 1);
                point4Index = (point1Index + 3) % (NumPoints - 1);
            }

            Vector3 point1 = points[point1Index].Point;
            Vector3 point2 = points[point2Index].Point;
            Vector3 point3 = points[point3Index].Point;
            Vector3 point4 = points[point4Index].Point;

            return(LineUtils.InterpolateBezeirPoints(point1, point2, point3, point4, subDistance));
        }
        protected override Vector3 GetPointInternal(int pointIndex)
        {
            float angle = ((float)pointIndex / Resolution) * 2f * Mathf.PI;

            return(LineUtils.GetEllipsePoint(Radius.x, Radius.y, angle));
        }
 protected override Vector3 GetPointInternal(float normalizedDistance)
 {
     return(LineUtils.GetEllipsePoint(Radius.x, Radius.y, normalizedDistance * 2f * Mathf.PI));
 }
示例#6
0
 protected override Vector3 GetPointInternal(float normalizedDistance)
 {
     return(LineUtils.InterpolateBezeirPoints(points.Point1, points.Point2, points.Point3, points.Point4, normalizedDistance));
 }
示例#7
0
 protected override Vector3 GetPointInternal(float normalizedDistance)
 {
     return(LineUtils.GetPointAlongParabola(Start, End, UpDirection, Height, normalizedDistance));
 }