Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DSH_ActorPoint: object
- {
- color col;
- vector3 pos;
- vector3 nextpos;
- actor act;
- static DSH_ActorPoint init(vector3 pushPos)
- {
- let p = new("DSH_actorPoint");
- p.pos = pushPos;
- p.col = "AAFFFF";
- return p;
- }
- }
- void GenerateActorPoints(int pointsPerCurve = 4)
- {
- //cPoints is an array that contains every control point of the polybezier
- int siz = cPoints.size();
- int halfway = floor(siz*0.5);
- //will need special case later on probably.
- if(siz <= 4)
- return;
- //not strictly needed perhaps, but cubic curves don't make sense with less than 4 segments per curve imo
- pointsPerCurve = max(4, pointsPerCurve);
- //increased every time we create and actor point
- int counter = 0;
- for(int i = 3; i< siz; i+=3) //three steps forward because we check backwards in the nested loop
- {
- for(int j = pointsPerCurve; j>=0; j--)
- {
- vector3 newPoint = PointOnCurve(j / double(pointsPerCurve), cPoints[i].pos, cPoints[i-1].pos, cPoints[i-2].pos, cPoints[i-3].pos,false);
- //old method. We don't want to have to sample twice per point, since we can set/get from or on previous points.
- //vector3 endpoint = PointOnCurve((j+1) / double(pointsPerCurve), cPoints[i].pos, cPoints[i-1].pos, cPoints[i-2].pos, cPoints[i-3].pos,False);
- DSH_ActorPoint pt = DSH_ActorPoint(DSH_actorPoint.init(newPoint));
- //the idea the block below is to orient the pos/nextpos of the
- //actor points so their pos (i.e where the real actor will be
- //spawned is oriented outward to the end points from the midddle
- //point. Like this: <<<<<<<<middle>>>>>>>>>>
- //|||||||||||||||||||||||||||
- if(i < halfway)
- {
- pt.pos = newPoint;
- if(counter>0)
- {
- actorPoints[counter-1].nextpos = newPoint;
- }
- }
- else if(i <= halfway+1 && j == pointsPerCurve) //this is supposed to happen once, exactly after the halfway mark.
- {
- actorPoints[counter-1].nextpos = newPoint;
- //current actor will be effectively invisible here, but this makes everything work.
- //TODO: send halp
- pt.pos = newPoint;
- pt.nextpos = newPoint;
- }
- else
- {
- pt.pos = actorPoints[counter-1].nextPos;
- pt.nextPos = newPoint;
- }
- //|||||||||||||||||||||||||||
- actorPoints.push(pt);
- counter++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement