Arrays
An array is a variable that contains a list of values, rather than just one. In Ygdrasil, arrays are a built-in part of the value node and all its related nodes. To create an array, you just make a regular value node - but instead of using the value message to store data in it, you use the values, plural, message.Creating an Array
value myarray (values(1 2 3 4 5))
Generating a Random Array
Using arrays in the mathematics node, you can generate a bunch of random numbers simultaneously. This example will move 5 cubes to different heights:
wandTrigger (when(button1,randomizer.random))
mathematics randomizer (
startValues(0 0 0 0 0),
endValues(6 6 6 6 6),
when(changed,
cube0.position(-2 0 $value0),
cube1.position(-1 0 $value1),
cube2.position(0 0 $value2),
cube3.position(1 0 $value3),
cube4.position(2 0 $value4)
)
)
object cube0 (file("cube.pfb"),position(-2 0 0))
object cube1 (file("cube.pfb"),position(-1 0 0))
object cube2 (file("cube.pfb"),position(0 0 0))
object cube3 (file("cube.pfb"),position(1 0 0))
object cube4 (file("cube.pfb"),position(2 0 0))
Randomly Resizing Object
This randomizer uses 3 values for the x,y, and z sizes of the object; and it also uses a fourth value as random delay to make itself resize again.
mathematics randomizer (
startValues(.5 .5 .5 .1),
endValues(2 2 2 1.0),
when(changed,
head.size($value0 $value1 $value2),
random+$value3
),
random
)
object head (file("head.pfb"),position(0 6 5),size(1 1 1))
(c) Ben Chang