Nesting Generators (New in RC4)

Overview

From RailClone 4 onwards it is possible to take the output of one generator and use it as a segment inside another, all while retaining full instancing and in the same graph. Nested Generators, allow you to connect the output of L1S or A2S node to any of the segment inputs of another generator. There’s no limit to the number of levels you can nest, allowing you to use the plugin in ways that were impossible in previous releases.

To learn how nesting works, the introductory tutorial above demonstrates the fundamental principles to help you get up to speed with this powerful feature. 

Nested generators have full access to the properties of arrays further down the chain, allowing you to create sophisticated and intelligent models. 

If you’re still new to RailClone, you might imagine that this is as an advanced feature, but actually, in many cases the opposite is true. Nesting generators can dramatically simplify your graphs and we recommend introducing it to your workflow early.

For example, here’s a style (based on a question from a user) that creates a hanging ornament of origami birds. Their distances from the ceiling are controlled by a spline, with the ability to randomise transforms and sequence colours.

And here are the graphs to create this in RailClone 3 and RailClone 4.

Both graphs create exactly the same geometry, but RailClone 4 uses nested generators. As you can see it has far fewer nodes to achieve the same result, and more importantly, it was much easier and more logical to create!



In this section:


Procedures

To nest one generator inside another

  • Wire the output of one generator to the segment inputs of another generator

To transform nested generators

Generators can be transformed, just as though they were normal segments. To do this

  1. Create a Transform operator
  2. Wire the nested Generator to the Transform Operator. 
  3. Wire the Transform Operator to the input of another Generator. 
  4. Open the Transform Operator's properties and use the Fixed and Random Translation, Rotation and Scale controls as normal. 

To control the alignment of nested generators

It is possible to control the alignment used by a nested Generator using a Transform operator. 

  1. Add a Transform Operator as described above. 
  2. Open the Transform Operator's properties and enable the Alignment settings. 
  3. Select the desired alignment for each axis. 

Using Pivot alignment

The pivot of a nested generator is always at world origin - if the RailClone object's geometry is not generated at world origin before it is nested, the pivot may be offset some distance from the resultant object. To create geometry at world origin:

  • For nested Generators that use Size Parameters to control the size of the array (no base splines): Ensure the RailClone object is position at world origin
  • For nested Generators that use Splines: Ensure the splines are in the correct position in relation to the world origin remembering that the world origin will become the pivot point upon nesting. 



To use expressions with nested generators

Expressions can use the attributes from nested generators using the syntax GeneratorName.Attribute. To illustrate, in this example we will imagine we need to access the spline length to each of the 3 generators shown in the image below. 

To access the spline length from Generator 3 use: 

return generator_3/XSplineLength;

or

return XSplineLength; 

Because this is the generator to which the segment we are controlling is directly connected it is not strictly necessary to include the generator's name

To access the spline length from Generator 2 use: 

return generator_2/XSplineLength;

To access the spline length from Generator 2 use: 

return generator_2/XSplineLength;


Naming Generators

  • Best practice is to ensure that generators all have unique names. These should be normalised for use in expressions (no non-ascii characters, cannot start with digits, etc).
  • If you are not sure how a name will be generalised, you can instead simply pick it from the Attribute panel of the Expression Editor. In the above example, you can see that the spaces in the names have been automatically normalised by replacing them with an underscore 

  • If a Generator is renamed, the user is responsible for updating the expression. Same for using unique names in Generators.
  • In case of duplicated Generator names, RailClone will use the nearest node to the Arithmetic operator.