Guest User

Untitled

a guest
Dec 14th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. Vector p0t = new Vector (p0);
  2. Vector p1t = new Vector (p1);
  3. Vector p2t = new Vector (p2);
  4. Vector p3t = new Vector (p3);
  5. float c3;
  6. float c2;
  7. float c1;
  8. float c0;
  9.  
  10. c3 = (2 * x * x * x) - (3 * x * x) + 1;
  11. c2 = (x * x * x) - (2 * x * x) + x;
  12. c1 = (-2 * x * x * x) + (3 * x * x);
  13. c0 = (x * x * x) - (x * x);
  14.  
  15. p0t.multiply (c3);
  16. p1t.multiply (c1);
  17. p2t.multiply (c2);
  18. p3t.multiply (c0);
  19.  
  20. ans.add (p0t);
  21. ans.add (p1t);
  22. ans.add (p2t);
  23. ans.add (p3t);
  24.  
  25. return ans;
  26. }
  27.  
  28. public void renderCurve()
  29. {
  30. Vector p0,p1,p2,p3,p;
  31. for (int i = 0; i < points.Length; i = i + 4)
  32. {
  33. p0 = new Vector (points[i].x,points[i].y,points[i].z);
  34. p1 = new Vector (points[i + 1].x,points[i + 1].y,points[i + 1].z);
  35. p2 = new Vector (points[i + 2].x,points[i + 2].y,points[i + 2].z);
  36. p3 = new Vector (points[i + 3].x,points[i + 3].y,points[i + 3].z);
  37. for (float t = 0; t <= 1; t = (t + Time.deltaTime * 10))
  38. {
  39. p = hermite.getPoint (p0,p1,p2,p3,t);
  40. GameObject pobj = Instantiate (pointObject, new Vector3(p.x,p.y,0.0f), Quaternion.identity) as GameObject;
  41. }
  42. }
  43. }
Add Comment
Please, Sign In to add comment