haki 1 Posted December 1 Hi folks, How would you go about adding points in a propagating manner in VEX. Here's what I mean: - Start with several incoming base points, each with an up vector. - For each one, add a new point somewhere along its up vector. - Calculate a new up vector by subtracting base positions from new point positions and setting the new point up vector to the result - Add the next new point somewhere along the previous point's up vector So, I called it propagating, because every next point in part defines the following. I think I'm on the right track here, but my gut's telling me I'm missing something. I'm stuck. Here's what I got: vector up = point(0, "up", @ptnum); vector currentPos = point(0, "P", @ptnum); vector newPos = {0,0,0}; int pts[]; for(int i=0; i<@numelem; i++) { append(pts,i); } int iteration = chi("iteration"); for(int j=0; j<=iteration-1; j++){ newPos = currentPos+up; int newPoint = addpoint(0, newPos); setpointattrib(0, "up", len(pts)+j, normalize(newPos), "set"); currentPos = point(0, "P", len(pts)+j); up = normalize(newPos-currentPos); currentPos = newPos; } Where do you think I'm wrong here. What would you do? Cheers! Share this post Link to post Share on other sites
ThomasPara 71 Posted Monday at 12:52 PM (edited) You cant import attributes from points that are created in the same wrangle, you will only get values from the wrangle above. And if you want to store attributes to a point you create you need to use the handle you have created. ex: setpointattrib(0,"attrib",newpoint,value,"set"); I think you might have been overthinking this one. vector up = set(0,1,0); vector this_pos = @P; int samples = chi("samples"); for(int i = 0;i<samples;i++){ this_pos += up*chf("lift"); int newpoint = addpoint(0,this_pos); } You can use this as base Edited Monday at 12:55 PM by ThomasPara Share this post Link to post Share on other sites
haki 1 Posted Tuesday at 10:26 AM 20 hours ago, ThomasPara said: You cant import attributes from points that are created in the same wrangle, you will only get values from the wrangle above. And if you want to store attributes to a point you create you need to use the handle you have created. ex: setpointattrib(0,"attrib",newpoint,value,"set"); Cheers, Thomas! That explains some of the confusion I had. And, you're right I was probably overthinking it. Thanks for the base script! I didn't write that in the post above, but I intended to later randomize the up vector direction for every new point and thus get a non-linear propagating pattern. I want to achieve a sort of (and I suspect that's not the right term here) parent-child behavior between every point and the next in line (something like tentacles constructed by points propagating in random directions). That's the reason why (in my head at least), calculating a new up by subtracting current_pos from new_pos and setting that at every sample is important. Except, and this is probably going to seem totally dumb... at sample 2 it falls apart. Up is no longer pointing where I'd expect it to. I bet this has something to do with the last line current_pos = point(0, "P", new_point); rand_dir_propagating_points.hiplc vector up = @up; vector current_pos = @P; vector new_pos = 0; int samples = chi("samples"); float offset = chf("offset"); for(int i = 0; i < samples; i++){ new_pos += current_pos + up * offset; int new_point = addpoint(0, new_pos); up = normalize(new_pos-current_pos); setpointattrib(0, "up", new_point, up, "set"); current_pos = point(0, "P", new_point); } It appears at sample 2, the up direction is pointing away from the world origin, and not away from the points at sample 1. I feel like I'm missing something so basic... Share this post Link to post Share on other sites
ThomasPara 71 Posted Tuesday at 11:01 AM Thats because your current_pos always get set to (0,0,0) Since you already have placed your point based on a vector, you dont need to "figure out" that vector again, it will only become the same vector. You can just offset with the same vector over and over again. You can then use the function "sample_direction_cone()" to vary your vector. Share this post Link to post Share on other sites
haki 1 Posted Tuesday at 12:29 PM Thanks, Thomas! 51 minutes ago, ThomasPara said: Thats because your current_pos always get set to (0,0,0) Ok. It seems I'm missing something here to understand why it always gets (0,0,0). On sample 1 it doesn't seem to get (0,0,0). Let me see. Maybe my comment's complete nonsense, so back to the drawing board: It seems like this does what I've sketched above: Now onto figuring out how to gain some degree of manual control over the random angle for each sample... Cheers! Share this post Link to post Share on other sites
haki 1 Posted Wednesday at 09:04 AM (edited) A quick update: rand_dir_propagating_points.hiplc Edited Wednesday at 09:21 AM by haki 1 Share this post Link to post Share on other sites
Librarian 129 Posted Wednesday at 09:15 AM Thank you @haki Share this post Link to post Share on other sites
haki 1 Posted Wednesday at 09:30 AM Cheers, @Librarian I hope you can find some use for it. I attached the current WIP file there. I can't wrap my head around how to gain manual control over the rand vector for each sample yet. Share this post Link to post Share on other sites