I've been breaking my head with the following problem.
Goal: to make a procedural bookshelf. At a certain point the user can choose how many vertical planks he wants. After he has chosen the amount he should be able to them between their neighboring vertical planks. Basically: to move a point along a line between it's left and right neighbor. It cannot go past it's left and right neighbor.
Setup: line with length 1 in z direction form 0 to 1. Resampled and has 5 points.
// loops over points to find neighbors // adds the z position of each points neigbor to an array // writes that array as an attribute to the point for(int i = 0; i < npoints(0); i++) { float nearpos[] = array(); vector pos_one = point(0, "P", i - 1); vector pos_two = point(0, "P", i + 1); insert(nearpos, 0, pos_one.z); insert(nearpos, 0, pos_two.z); setpointattrib(0, "nearpos", i, nearpos); }
Clearly I'm doing something wrong as this gives me a static array of positions. Where i to change the position of one point, the array does not get updated. Would love some help on this.
P.s: I know I can do this with for loop nodes, but I'm practicing VEX and would like to find a VEX solution.