Beispiel #1
0
 public Vector3 GetPositionAt(float t)
 {
     if ((t < 0f) && (prev != null) && prev.IsValid())
     {
         return(prev.GetPositionAt(t + 1.0f));
     }
     else if ((t > 1f) && (next != null) && next.IsValid())
     {
         return(next.GetPositionAt(t - 1.0f));
     }
     else if (IsValid())
     {
         float   t2 = t * t;
         float   t3 = t2 * t;
         Vector3 p0 = startPoint.position, p1 = endPoint.position, m0 = startTangent.position - p0, m1 = endTangent.position - p1;
         return((p0 * ((2.0f * t3) - (3.0f * t2) + 1.0f))
                + (m0 * (t3 + (-2.0f * t2) + t))
                + (p1 * ((-2.0f * t3) + (3.0f * t2)))
                + (m1 * (t3 - t2)));
     }
     else
     {
         return(transform.position);
     }
 }
Beispiel #2
0
 private void OnDrawGizmos()
 {
     for (int i = 0; i < sections.Count; i++)
     {
         SplineSection splineSection = sections[i];
         if (splineSection.IsValid())
         {
             Gizmos.color = Color.yellow;
             Gizmos.DrawLine(splineSection.startPoint.position, splineSection.startTangent.position);
             Gizmos.DrawLine(splineSection.endPoint.position, splineSection.endTangent.position);
             Gizmos.color = Color.white;
             for (int j = 0; j < 16; j++)
             {
                 Gizmos.DrawLine(splineSection.GetPositionAt(i / 16f), splineSection.GetPositionAt(((float)i + 1) / 16f));
             }
         }
     }
 }