Ejemplo n.º 1
0
        /// Finds the distance along the path that is closest to the given point
        public float GetClosestDistanceAlongPath(Vector3 worldPoint)
        {
            Vector3        localPoint = MathUtility.InverseTransformPoint(worldPoint, transform, space);
            TimeOnPathData data       = CalculateClosestPointOnPathData(localPoint);

            return(Mathf.Lerp(cumulativeLengthAtEachVertex[data.previousIndex], cumulativeLengthAtEachVertex[data.nextIndex], data.percentBetweenIndices));
        }
Ejemplo n.º 2
0
        /// Finds the 'time' (0=start of path, 1=end of path) along the path that is closest to the given point
        public float GetClosestTimeOnPath(Vector3 worldPoint)
        {
            Vector3        localPoint = MathUtility.InverseTransformPoint(worldPoint, transform, space);
            TimeOnPathData data       = CalculateClosestPointOnPathData(localPoint);

            return(Mathf.Lerp(times[data.previousIndex], times[data.nextIndex], data.percentBetweenIndices));
        }
Ejemplo n.º 3
0
        /// Finds the distance along the path that is closest to the given point
        public float GetClosestDistanceAlongPath(Vector3 worldPoint)
        {
            TimeOnPathData data = CalculateClosestPointOnPathData(worldPoint);

            return(Mathf.Lerp(cumulativeLengthAtEachVertex[data.previousIndex],
                              cumulativeLengthAtEachVertex[data.nextIndex], data.percentBetweenIndices));
        }
Ejemplo n.º 4
0
        /// Finds the closest point on the path from any point in the world
        public Vector3 GetClosestPointOnPath(Vector3 worldPoint)
        {
            // Transform the provided worldPoint into VertexPath local-space.
            // This allows to do math on the localPoint's, thus avoiding the need to
            // transform each local vertexpath point into world space via GetPoint.
            Vector3 localPoint = MathUtility.InverseTransformPoint(worldPoint, transform, space);

            TimeOnPathData data        = CalculateClosestPointOnPathData(localPoint);
            Vector3        localResult = Vector3.Lerp(localPoints[data.previousIndex], localPoints[data.nextIndex], data.percentBetweenIndices);

            // Transform local result into world space
            return(MathUtility.TransformPoint(localResult, transform, space));
        }
Ejemplo n.º 5
0
        /// Finds the closest segment index on the path from any point in the world
        public int GetClosestBezierSegmentIndexOnPath(Vector3 worldPoint)
        {
            // Transform the provided worldPoint into VertexPath local-space.
            // This allows to do math on the localPoint's, thus avoiding the need to
            // transform each local vertexpath point into world space via GetPoint.
            Vector3 localPoint = MathUtility.InverseTransformPoint(worldPoint, transform, space);

            TimeOnPathData data = CalculateClosestPointOnPathData(localPoint);

            int res = GetBezierSegmentIndex(data.previousIndex);

            return(res);
        }
Ejemplo n.º 6
0
        /// Finds the 'time' (0=start of path, 1=end of path) along the path that is closest to the given point
        public float GetClosestTimeOnPath(Vector3 worldPoint)
        {
            TimeOnPathData data = CalculateClosestPointOnPathData(worldPoint);

            return(Mathf.Lerp(times[data.previousIndex], times[data.nextIndex], data.percentBetweenIndices));
        }
Ejemplo n.º 7
0
        /// Finds the closest point on the path from any point in the world
        public Vector3 GetClosestPointOnPath(Vector3 worldPoint)
        {
            TimeOnPathData data = CalculateClosestPointOnPathData(worldPoint);

            return(Vector3.Lerp(GetPoint(data.previousIndex), GetPoint(data.nextIndex), data.percentBetweenIndices));
        }