In most cases when I am using a cloner I just want to make tiles.
I just want clones of cubes to sit next to each other.
This is easy in linear mode because you have a “Per Step” mode (Count x Distance).
In “Grid Array” mode this is not an option. So you have to calculate the distance between a certain number of clones times their size… Boring!
So here is a little setup that will take you two minutes and teach you the very basics of Xpresso.
Lets get started with a Cube in a Cloner. Set the cloner in Grid Array mode. as you can see this sucks, the cubes overlap and all.
Now add a Xpresso tag to your Cloner.
Drag the Cloner into the Xpresso wind twice (2x), open the Count ports on the left one and the Size ports not the right one, like so:
Now add three (3) Math nodes in Multiply mode, and enter the size of the cube in the lower input ports:
AAARGH! They don’t touch!!
This is normal and we are going to solve this.
What happens is that the setup calculates the size multiplied by the count but that gives us one times too much distance.
So we have to subtract one (-1) from the clone count to get the right results.
Yeah man this rocks!
No it doesn’t. We don’t want to climb into xpresso each time we modify the size of the cube. This should all go automatically.
So we have to drag the cube into xpresso and open the size ports and connect those to the Math:Multiply nodes respectively
Ok this is it, this works. We are done.
Lets say we want more than this, we want to be able to add gaps between the tiles.
Well if you have come this far this should be easy.
We need a User-Data field in the cloner.
Click on the Cloner, in the attributes go tho the User Data menu, and Add User-Data.
Set it to “Real” and name it “GAP” and click OK
In the xpresso window we can find this User-Data in the (left) Cloner node
Add three (3) Math nodes in Add mode. Reconnect them between Cube size and the Math:Multiply and connect the User Data to the lower ports.
Bam! We got gaps. Duh who said xpresso was difficult?
Option: Auto resize the cube (not the cloner)
You can also take this whole setup to automatically adapt the size of the cube to the cloner size.
This is basically a whole new setup.
We need to open the Size and the Count ports on the cloner.
Subtract one (1) to the clone count.
Divide the size of the Cloner by the clone count -1.
Subtract the GAP from the result
And pass it on to the cube size.
Wow not to fast!
Just watch the image below and try to reproduce it (oh oh this is going to generate some negative comments here)
Keep this Setup in your library for later use.