The basic idea of a rule is to replace a shape with a certain shape symbol with a number of new shapes. Formally:
PredecessorShape --> SuccessorLet us start with a very simple example:
A --> BOn application on a specific shape with symbol A, the rule above creates a copy of the shape and sets its shape symbol to B. The A shape is now considered done and not processed anymore. If there is no rule matching symbol B the generation process is finished. The resulting structure is called the shape tree and looks like this:
A rule can have more complex successors, e.g., the right side of the rule can consist of multiple shape symbols and so-called shape operations:
A --> B t(3, 0, 0) CThis successor is now executed from the left to the right. Again, B is an identical copy of A. Then the current shape is translated by 3 units in x-direction (i.e., the scope.t is manipulated) and a new shape C is created. The shape tree now has two leaves:
If we add this rule for C:
C --> D s(2, 0.5, 1.75) EThe generation process will add two children, D and E to shape C. Shape D is an exact copy of shape C, but shape E will have a different sized scope (because of the s() shape operation). The shape tree and the associated model look like this:
Note that now, the leaves (B, D, E) are not on the same level (i.e. have different distances to the root shape) but they are all part of the model.
Another shape operation is the insert operation i():
E --> i("cylinder.obj") FAfter starting the generation again, shape E is not a leaf anymore but now has a child shape F.
Terminal ShapesIn the E rule above, F is a so-called terminal shape: because no rule F is defined, the generation is stopped at this point. However, the CGA editor will issue a "Undefined Rule" warning. This can be suppressed by adding a period after F, thus explicitely marking F as a terminal shape:
E --> i("cylinder.obj") F.
A Note on LeavesFor convenience, rules like the E rule above can be truncated:
E --> i("cylinder.obj")In this case (i.e. E has no children), the rule interpreter silently inserts a leaf with the same name as the rule itself. The shape tree after applying the E rule above looks like this:
Copyright ©2008-2016 Esri R&D Center Zurich. All rights reserved.