# Be fruitful and multiply

There is strength in numbers. A single gnat is easily dispatched, but you’ll run away from a hundred of them. How unimpressive a single neuron is, but put 15 millions near to each other and you’ll get the brain of a space faring species, the rats. Paint 1000 of poor paintings and you’ll be a famous artist. See, where am I heading?

RealWorld cursor and icon editors allow creation of simple 3D models via the Unicorn3D subsystem. It can be used to make 3D models from basic shapes like spheres or cubes or from revolving or rectangular surfaces of limited complexity. What if you put more of these simple 3D shapes close to each other…

## Multiplying 3D objects

Unicorn3D objects can already be parametrized. This feature can be used for animation or to make multiple variants of a 3D object. Users can define variables and then use them instead of constants for various properties of a 3D object, for example position, size or color. This is an important prerequisite.

The green corn in the 3D object below was created by using a new feature that automatically duplicates components as many times as you wish.

The next version will introduce a new kind of variable called “iterator”. If you use this variable in your 3D object and set its value for example to 5, the 3D object will be drawn 5 times.

It would be useless to draw an object 5 times on the same spot. Hence you must use the iterator to parametrize something. If you use it to parametrize object position, you’ll get 5 of your 3D objects in a row. For each of the drawn objects, the iterator will have different value. In our case, it will be, 0, 1, 2, 3, and 4.

Cool? Kind of. But wait, there is more…

## Random numbers

With this kind of power hiding in the iterators, it would be a sin not to have a random number generator. So, there is one. Or two. Or as many as you want.

The rndX (rnd0, rnd1, rnd2, …) variable is used to generate pseudo-random numbers: rndX will have a different value for each iteration. Within the same iteration, it will keep a single value. This is useful if you need the same random number more than once. For example, when generating random gray color, you would use the same rndX for all (R, G, B) color components of a material.

Would you like to have 20 randomly placed snowflakes instead of just one? Suit yourself. Using rnd1, rnd2, rnd3 as x, y, z coordinates of a translation is very easy. And while you at it, why not make it 30 snow flakes?

## What else to expect?

The new version will also make it easy to turn on and off components of a 3D object. This feature can be used to randomly pick 1-of-N variants of an object when using iterators. For example, you can design 3 different kind of snow flakes and use them all in your snow blizzard 3D object.

Since duplication is now easy, the pyramid basic shape will have configurable number of sides. There is also going to be a more basic shapes - prism and tetrahedron.

### Summary

The iterator variable is a very small change from a usage point of view yet it opens a whole new class of 3D objects - simple particle systems. Although the “particles” cannot easily interact, many useful particle systems do not need this iteration.

BTW: What happens if more than one iterator variable is used? Since you are smart enough to ask this question, you are also smart enough to know the answer. There is only one that makes sense.