TreeMesher¶
-
class TreeMesher¶
Bases:
TypedReferenceCountTurns a
TreeSkeletoninto one Geom: bark tubes and leaf cards in a single vertex table (one draw per tree), 32-bit indices.Bark. A ring per node on the skeleton’s rotation-minimising frame; the sides follow the radius (`ceil(2 pi r / edge_length)` within [min_sides, max_sides], never growing towards the tip) and rings of different counts are stitched by a zipper, so a stem’s tube has no gaps. A stem closes to a point at its tip; its base sits inside the parent. U runs round the stem (whole repeats, `bark_tile` metres each), V along the wood from the root (continuous across forks). Optional trunk lobes, a little bark noise, and a flare where a child leaves its parent.
Leaves. One quad per card (two crossed, or a cluster of three, by the leaf’s layout), normals bent out of the crown ellipsoid so a crown shades as a volume (`leaf_normal_card` of the card’s own facing kept). With `leaf_tile` > 0, a card larger than that (a thinned LOD’s card, grown to keep the crown’s area, or a billboard cloud’s) repeats its sprite `round(size / leaf_tile)` times each way instead of magnifying it: U and V run past 1 and the shader wraps them within the sprite.
Columns: `vertex`, `normal`, `texcoord`, `color` (rgb ambient occlusion from depth in the crown, a 1), `wind0` (bend weight, phase, flutter, level), `wind1` (pivot xyz: the stem centreline point or the leaf’s anchor, stiffness), `leaf` (random, kind: 0 bark 1 leaf, sprite, card layout), `tangent` (U’s direction, w the bitangent’s sign: the frame for bark and leaf normal maps), `wind2` (how much of the bend weight rides on the trunk’s mode, on the level-1 ancestor’s and on the level-2 ancestor’s, the damping ratio) and `wind3` (those three modes’ natural frequencies in Hz, then the flutter frequency: the leaf’s from its size, or the twig’s own for bark).
Dynamics. Each stem is a cantilever clamped where it grows: its stiffness is the tip compliance of the tapered tube, integral of (L - s)^2 / (E I(s)) ds, and its mass the wood’s plus everything growing on it (children whole, leaves at `LEAF_LOAD`), weighted by the first mode’s shape (Rayleigh); f = sqrt(k / m) / 2 pi. A bare uniform rod gives f ~ 0.28 (r / L^2) sqrt(E / rho), so a stem slows as it lengthens and quickens as it thickens. `wood_stiffness` (GPa) and `wood_density` (kg/m^3, green wood) are the species’; `damping` its damping ratio; `leaf_flutter` the flutter frequency (Hz) of a 1 m card, scaling as 1 / sqrt(size). The bend weight splits by the stems’ depth into the three modes so that a fork stays continuous: a child starts with exactly its parent’s split there, and deeper stems ride their level-2 ancestor’s mode (their own frequency drives the twig flutter). Card layouts: 0 single, 1 crossed, 2 cluster of three, 3 a spray folded down along its middle (conifers). The wind weight and the pivot are continuous across forks, so a child sways exactly with the parent ring it grows from.
Inheritance diagram
digraph inheritance0e5bf2acb2 { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "DTOOL_SUPER_BASE" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style=""]; "ReferenceCount" [URL="acron.core.ReferenceCount.html#acron.core.ReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "ReferenceCount" [arrowsize=0.75,style=""]; "TreeMesher" [URL="acron.proctree.TreeMesher.html#acron.proctree.TreeMesher",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "TypedReferenceCount" -> "TreeMesher" [arrowsize=0.75,style=""]; "TypedObject" [URL="acron.core.TypedObject.html#acron.core.TypedObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "TypedObject" [arrowsize=0.75,style=""]; "TypedReferenceCount" [URL="acron.core.TypedReferenceCount.html#acron.core.TypedReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "TypedObject" -> "TypedReferenceCount" [arrowsize=0.75,style=""]; "ReferenceCount" -> "TypedReferenceCount" [arrowsize=0.75,style=""]; }- TreeMesher.__init__()¶
- static TreeMesher.beam_frequency()¶
The first natural frequency (Hz) of a uniform round cantilever of this length and radius (m), wood stiffness (GPa) and density (kg/m^3), with `tip_mass` (kg) at its end – Rayleigh’s method: a tip stiffness of 3 E I / L^3 against the tip mass plus 33/140 of the rod’s own.
- TreeMesher.branch_frequencies()¶
Each branch’s first natural frequency (Hz), in the skeleton’s branch order; 0 for roots. See the class notes.
- TreeMesher.count_triangles()¶
Triangles
make_geom()would write (counted, not built: the LOD ladder asks this many times per level).
- TreeMesher.flutter_frequency()¶
The flutter frequency (Hz) of a leaf card of this size (m): `leaf_flutter` for a 1 m card, as 1 / sqrt(size) (smaller leaves on shorter stalks flutter faster).
- TreeMesher.get_bark()¶
- TreeMesher.get_bark_noise()¶
- TreeMesher.get_bark_tile()¶
- static TreeMesher.get_class_type()¶
- TreeMesher.get_damping()¶
- TreeMesher.get_edge_length()¶
- static TreeMesher.get_format()¶
The vertex format every tree mesh uses (registered once).
- TreeMesher.get_junction_flare()¶
- TreeMesher.get_leaf_flutter()¶
- TreeMesher.get_leaf_layout()¶
- TreeMesher.get_leaf_normal_card()¶
- TreeMesher.get_leaf_tile()¶
- TreeMesher.get_leaves()¶
- TreeMesher.get_lobe_depth()¶
- TreeMesher.get_lobes()¶
- TreeMesher.get_max_sides()¶
- TreeMesher.get_min_radius()¶
- TreeMesher.get_min_sides()¶
- TreeMesher.get_radial_scale()¶
- TreeMesher.get_ring_stride()¶
- TreeMesher.get_wood_density()¶
- TreeMesher.get_wood_stiffness()¶
- TreeMesher.make_geom()¶
The tree as one Geom (bark and leaves; 32-bit indices).
- TreeMesher.set_bark()¶
- TreeMesher.set_bark_noise()¶
- TreeMesher.set_bark_tile()¶
- TreeMesher.set_damping()¶
- TreeMesher.set_edge_length()¶
- TreeMesher.set_junction_flare()¶
- TreeMesher.set_leaf_flutter()¶
- TreeMesher.set_leaf_layout()¶
- TreeMesher.set_leaf_normal_card()¶
- TreeMesher.set_leaf_tile()¶
- TreeMesher.set_leaves()¶
- TreeMesher.set_lobe_depth()¶
- TreeMesher.set_lobes()¶
- TreeMesher.set_max_sides()¶
- TreeMesher.set_min_radius()¶
- TreeMesher.set_min_sides()¶
- TreeMesher.set_radial_scale()¶
- TreeMesher.set_ring_stride()¶
- TreeMesher.set_wood_density()¶
- TreeMesher.set_wood_stiffness()¶