Created
June 19, 2018 22:40
-
-
Save mimetaur/19afaf884d363fa71de9104b4758ac2c to your computer and use it in GitHub Desktop.
Sketch 1 / Create Points Attribute Wrangle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // paramaters come in as floats by default | |
| // in order to cast them to other types | |
| // need to wrap them in a "set()" | |
| int width = set(ch("width")); | |
| int height = set(ch("height")); | |
| int num_points = set(ch("num_points")); | |
| int seed = set(ch("seed")); | |
| // seed needs to be persisted | |
| // down the line as an attributes | |
| // to remain available to future geometry | |
| i@seed = seed; | |
| for (int i = 0; i < num_points; i++) | |
| { | |
| // if we just used "rand(i)" | |
| // without offsetting the random seeds differently | |
| // we end up with a diagonal line of points | |
| float random_remap_x = fit(rand(seed+i), 0, 1, -0.5, 0.5); | |
| float random_remap_y = fit(rand(seed-i), 0, 1, -0.5, 0.5); | |
| float xpos = random_remap_x * width; | |
| float zpos = random_remap_y * height; | |
| vector position = set(xpos, 0, zpos); | |
| // http://www.sidefx.com/docs/houdini/vex/functions/addpoint.html | |
| addpoint(0, position); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment