duck

duck

May 18th, 2010
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1.         // start & end indices in routedata
  2.         float iLength = 0;
  3.         int startPointIndex = 0;
  4.         int endPointIndex = 0;
  5.         float midPointI = 0;
  6.         while (iLength < routeLength * i)
  7.         {
  8.             Vector3 pos = routeData[startPointIndex];
  9.             Vector3 npos = routeData[(startPointIndex + 1) % routeData.Count];
  10.             float addLength = (pos - npos).magnitude;
  11.             float prevLength = iLength;
  12.             iLength += addLength;
  13.             if (iLength >= routeLength * i)
  14.             {
  15.                 endPointIndex = (startPointIndex + 1) % routeData.Count;
  16.                 // t1
  17.                 midPointI = (i - (prevLength / routeLength)) / (addLength / routeLength);
  18.             }
  19.             else
  20.             {
  21.                 startPointIndex++;
  22.             }
  23.         }
Advertisement
Add Comment
Please, Sign In to add comment