# How do algorithmic botany algorithms generate their plant geometry from a skeleton?

I read the Algorithmic Beauty of plants.The resource goes in depth as to how to generate plant topology, but it does not talk about how to make the geometry except for the leaves.

I tried looking into packages such as plantgl bbut I am still not entirely sure how they are making it.

I understand they use sweep surfaces, but are they putting any effort into ensuring their models are manifold? Or are they just piece wise parametrizing each 1D section and not bothering to guarantee watertighntnes?

Is there a way to grab a plant topology and parametrize it into a watertight mesh?

• look up L systems for generating plants, the book mentioned in the answer also goes into it nicely. Commented Feb 9, 2023 at 13:06
• That generates plant topology, not geometry. Which is exactly what i am saying. I know how to generate plant topology I don;t know how to generate the trunk and branch geometry. I.e. get a 2 manifold mesh. Commented Feb 9, 2023 at 23:57
• Well that's the allusion here. After an L system has generated the topology which is represented by symbols each symbol in turn has a corresponding mesh. Replace the symbols with the mesh make sure everything is connected, tesselate, weather, texture, animate. Commented Feb 10, 2023 at 12:01
• Just to be clear, it is not a 1 to 1 replacement (look up turtle system's) when generating the final mesh. Commented Feb 10, 2023 at 13:04
• Based on your feedback I decided to write an answer. Commented Feb 13, 2023 at 13:45

First, I'll note that cpfg, the plant-modeling software used in the creation of "The Algorithmic Beauty of Plants", has recently been open-sourced at https://github.com/AlgorithmicBotany/vlab so you can look it up yourself!

Briefly, though, you're right that plant axes are just cylinders swept along a polyline. There was no effort made into making these models watertight; the cylinder swept by lateral branches intersect the main branch geometry. In general, it's a hard problem to nicely skin branch intersections. There was some published work on it at that lab, The Use of Subdivision Surfaces in the Modeling of Plants, which tried to solve the problem by using low-poly branch templates; they still had difficulties for axes with many close branch points, if I recall.

A popular method of generating the mesh from an L system is called a "Turtle Graphics" system.

In a turtle graphics system we imagine a turtle which starts at the root of the system reads a symbol from the L system and walks in a specific direction based on the symbol. The symbol itself is associated with a polygon and the entire system is seeded with a polygon from the root symbol.

The polygons themselves can be generated algorithmically by the system and then modified for each generation of the plant or predefined such as a simple N sided circle.

As the turtle marches through the L system each symbol gives it instructions on direction and how many steps to take. For example, a turtle may be instructed to move 3 steps in the up direction.

The turtle starts at the seeded polygon, reads the symbol, takes a step and places the polygon for that symbol. Taking a step usually includes a "turn" this translates into a rotation matrix for the polygon being placed where the turtle represents the origin for the coordinate frame used to do the rotation and the turtles position becomes the translation. Then the two polygon's are connected. A simple and effective way to connect two polygons is: find the two nearest vertices, n and m, the generate vertex attributes in the order n,m,n+1 mod t,m+1 mod t...n+t mod t,m+t mod t where t is the total number of vertices. When t is not equal in the two polygons a combination of splitting the longest edge, and connecting multiple vertices in n to a single vertex in m (or vica versa depending on the vertex count) can be used.

Some simple checks should be run for each pair of polygons. 1) Make sure the polygons are planer. 2) Make sure the polygons are wound consistently 3) At connection time make sure all vertices in the polygon being placed are on the same side of the connecting polygon's plane. Vertices that pass through the plane will need to be adjusted so they are slightly above the plane of the other polygon.

Normally there is one main "trunk" for the turtle to follow, each branch is reinterpreted as a new turtle with a new seed polygon. Branch's can be integrated into the main structure by clipping each branch against the triangles of the main trunk. Some systems will allow branch's to intersect, others will do collision checking. Here again the can be special symbols that define the transition between the main structure and a branch, this allows for smooth transitions of UV coordinates.

Leaves can be single symbols represented as a single polygon, or an entire L system with its own turtles which is slow to generate but the results are stunning. Yet another approach is to generate a handful of leaves and the L system associates a symbol with each leaf.

Done correctly this results in a well defined structure. The root node can be closed off to make the polyhedron water tight.