/// <summary>Get the tangent of the curve at a point along the path.</summary> /// <param name="pos">Postion along the path. Need not be normalized.</param> /// <returns>World-space direction of the path tangent. /// Length of the vector represents the tangent strength</returns> public override Vector3 EvaluateTangent(float pos) { Vector3 result = new Vector3(); if (m_Waypoints.Length == 0) { result = transform.rotation * Vector3.forward; } else { int indexA, indexB; pos = GetBoundingIndices(pos, out indexA, out indexB); if (indexA == indexB) { result = m_Waypoints[indexA].tangent; } else { Waypoint wpA = m_Waypoints[indexA]; Waypoint wpB = m_Waypoints[indexB]; result = SplineHelpers.BezierTangent3(pos - indexA, m_Waypoints[indexA].position, wpA.position + wpA.tangent, wpB.position - wpB.tangent, wpB.position); } } return(transform.TransformDirection(result)); }
public override Vector3 EvaluateTangent(float pos) { Vector3 direction = default(Vector3); if (this.m_Waypoints.Length == 0) { direction = base.transform.rotation * Vector3.forward; } else { int num; int num2; pos = this.GetBoundingIndices(pos, out num, out num2); if (num == num2) { direction = this.m_Waypoints[num].tangent; } else { CinemachinePath.Waypoint waypoint = this.m_Waypoints[num]; CinemachinePath.Waypoint waypoint2 = this.m_Waypoints[num2]; direction = SplineHelpers.BezierTangent3(pos - (float)num, this.m_Waypoints[num].position, waypoint.position + waypoint.tangent, waypoint2.position - waypoint2.tangent, waypoint2.position); } } return(base.transform.TransformDirection(direction)); }
/// <summary> /// 根据序号获取路径上的方向 /// </summary> /// <param name="pos">序号</param> /// <returns>全局方向</returns> public override Vector3 EvaluateTangent(float pos) { Vector3 result = transform.rotation * Vector3.forward; if (m_Waypoints.Length > 1) { UpdateControlPoints(); pos = GetBoundingIndices(pos, out int indexA, out int indexB); if (!Looped && indexA == m_Waypoints.Length - 1) { --indexA; } result = SplineHelpers.BezierTangent3(pos - indexA, m_Waypoints[indexA].position, m_ControlPoints1[indexA].position, m_ControlPoints2[indexA].position, m_Waypoints[indexB].position); } return(transform.TransformDirection(result)); }
public override Vector3 EvaluateTangent(float pos) { Vector3 direction = base.transform.rotation * Vector3.forward; if (this.m_Waypoints.Length > 1) { this.UpdateControlPoints(); int num; int num2; pos = this.GetBoundingIndices(pos, out num, out num2); if (!this.Looped && num == this.m_Waypoints.Length - 1) { num--; } direction = SplineHelpers.BezierTangent3(pos - (float)num, this.m_Waypoints[num].position, this.m_ControlPoints1[num].position, this.m_ControlPoints2[num].position, this.m_Waypoints[num2].position); } return(base.transform.TransformDirection(direction)); }