Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. class DSH_ActorPoint: object
  2. {
  3. color col;
  4. vector3 pos;
  5. vector3 nextpos;
  6. actor act;
  7. static DSH_ActorPoint init(vector3 pushPos)
  8. {
  9.  
  10. let p = new("DSH_actorPoint");
  11. p.pos = pushPos;
  12. p.col = "AAFFFF";
  13. return p;
  14. }
  15. }
  16.  
  17. void GenerateActorPoints(int pointsPerCurve = 4)
  18. {
  19. //cPoints is an array that contains every control point of the polybezier
  20. int siz = cPoints.size();
  21. int halfway = floor(siz*0.5);
  22.  
  23. //will need special case later on probably.
  24. if(siz <= 4)
  25. return;
  26.  
  27. //not strictly needed perhaps, but cubic curves don't make sense with less than 4 segments per curve imo
  28. pointsPerCurve = max(4, pointsPerCurve);
  29.  
  30. //increased every time we create and actor point
  31. int counter = 0;
  32.  
  33. for(int i = 3; i< siz; i+=3) //three steps forward because we check backwards in the nested loop
  34. {
  35. for(int j = pointsPerCurve; j>=0; j--)
  36. {
  37. vector3 newPoint = PointOnCurve(j / double(pointsPerCurve), cPoints[i].pos, cPoints[i-1].pos, cPoints[i-2].pos, cPoints[i-3].pos,false);
  38.  
  39. //old method. We don't want to have to sample twice per point, since we can set/get from or on previous points.
  40. //vector3 endpoint = PointOnCurve((j+1) / double(pointsPerCurve), cPoints[i].pos, cPoints[i-1].pos, cPoints[i-2].pos, cPoints[i-3].pos,False);
  41.  
  42. DSH_ActorPoint pt = DSH_ActorPoint(DSH_actorPoint.init(newPoint));
  43.  
  44. //the idea the block below is to orient the pos/nextpos of the
  45. //actor points so their pos (i.e where the real actor will be
  46. //spawned is oriented outward to the end points from the midddle
  47. //point. Like this: <<<<<<<<middle>>>>>>>>>>
  48.  
  49. //|||||||||||||||||||||||||||
  50. if(i < halfway)
  51. {
  52. pt.pos = newPoint;
  53. if(counter>0)
  54. {
  55. actorPoints[counter-1].nextpos = newPoint;
  56. }
  57. }
  58.  
  59. else if(i <= halfway+1 && j == pointsPerCurve) //this is supposed to happen once, exactly after the halfway mark.
  60. {
  61. actorPoints[counter-1].nextpos = newPoint;
  62. //current actor will be effectively invisible here, but this makes everything work.
  63. //TODO: send halp
  64. pt.pos = newPoint;
  65. pt.nextpos = newPoint;
  66. }
  67. else
  68. {
  69. pt.pos = actorPoints[counter-1].nextPos;
  70. pt.nextPos = newPoint;
  71. }
  72. //|||||||||||||||||||||||||||
  73.  
  74. actorPoints.push(pt);
  75. counter++;
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement