/// <inheritdoc />
        protected override Vector3 GetPointInternal(float normalizedDistance)
        {
            var totalDistance = normalizedDistance * (PointCount - 1);
            int point1Index   = Mathf.FloorToInt(totalDistance);

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

            int point2Index;
            int point3Index;
            int point4Index;

            if (!Loops)
            {
                if (point1Index + 3 >= PointCount)
                {
                    return(controlPoints[PointCount - 1].Position);
                }

                if (point1Index < 0)
                {
                    return(controlPoints[0].Position);
                }

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

            Vector3 point1 = controlPoints[point1Index].Position;
            Vector3 point2 = controlPoints[point2Index].Position;
            Vector3 point3 = controlPoints[point3Index].Position;
            Vector3 point4 = controlPoints[point4Index].Position;

            return(LineUtility.InterpolateBezierPoints(point1, point2, point3, point4, subDistance));
        }
        /// <summary>
        /// Gets the rotation of a point along the line at the specified length
        /// </summary>
        public Quaternion GetRotation(float normalizedLength, LineRotationMode lineRotationMode = LineRotationMode.None)
        {
            lineRotationMode = (lineRotationMode != LineRotationMode.None) ? lineRotationMode : rotationMode;
            Vector3 rotationVector = Vector3.zero;

            switch (lineRotationMode)
            {
            case LineRotationMode.Velocity:
                rotationVector = GetVelocity(normalizedLength);
                break;

            case LineRotationMode.RelativeToOrigin:
                Vector3 point  = GetPoint(normalizedLength);
                Vector3 origin = TransformPoint(originOffset);
                rotationVector = (point - origin).normalized;
                break;

            case LineRotationMode.None:
                return(LineTransform.rotation);
            }

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

            Vector3 upVector = GetUpVectorInternal(normalizedLength);

            if (manualUpVectorBlend > 0f)
            {
                Vector3 manualUpVector = LineUtility.GetVectorCollectionBlend(manualUpVectors, normalizedLength, Loops);
                upVector = Vector3.Lerp(upVector, manualUpVector, manualUpVector.magnitude);
            }

            if (flipUpVector)
            {
                upVector = -upVector;
            }

            return(Quaternion.LookRotation(rotationVector, upVector));
        }
Beispiel #3
0
 /// <inheritdoc />
 protected override Vector3 GetPointInternal(float normalizedDistance)
 {
     return(LineUtility.GetPointAlongPhysicalParabola(StartPoint.Position, direction, velocity, useCustomGravity ? gravity : UnityEngine.Physics.gravity, normalizedDistance * distanceMultiplier));
 }
Beispiel #4
0
 protected override Vector3 GetPointInternal(float normalizedDistance)
 {
     return(LineUtility.InterpolateBezierPoints(controlPoints.Point1, controlPoints.Point2, controlPoints.Point3, controlPoints.Point4, normalizedDistance));
 }
Beispiel #5
0
        /// <inheritdoc />
        protected override Vector3 GetPointInternal(int pointIndex)
        {
            float angle = ((float)pointIndex / resolution) * 2f * Mathf.PI;

            return(LineUtility.GetEllipsePoint(radius, angle));
        }
Beispiel #6
0
 /// <inheritdoc />
 protected override Vector3 GetPointInternal(float normalizedDistance)
 {
     return(LineUtility.GetEllipsePoint(radius, normalizedDistance * 2f * Mathf.PI));
 }
Beispiel #7
0
 /// <inheritdoc />
 protected override Vector3 GetPointInternal(float normalizedDistance)
 {
     return(LineUtility.GetPointAlongConstrainedParabola(StartPoint.Position, endPoint.Position, upDirection, height, normalizedDistance));
 }
 /// <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)
 {
     BuildPoints();
     return(LineUtility.InterpolateVectorArray(points, normalizedDistance));
 }