Building Plant Models
This page shows a GeometryBasics-first workflow: reference meshes are GeometryBasics.Mesh and node transformations use CoordinateTransformations.
Overview
The recommended workflow is:
- Define one
RefMeshper organ type usingGeometryBasics.Mesh. - Build your MTG topology.
- Attach
Geometryto each node with aCoordinateTransformations.Transformation.
Create Reference Meshes
refmesh_cylinderRefMesh{String, GeometryBasics.Mesh{3, Float32, GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}, (:position,), Tuple{Vector{Point{3, Float32}}}, Vector{GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}}}, ColorTypes.RGB{Float64}, Vector{Vec{3, Float64}}, Nothing}("Cylinder", Mesh{3, Float32, GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}}(...), Vec{3, Float64}[[-0.2079117555624273, -0.9781475869718993, 0.0], [0.5877851979724341, -0.8090170338407632, 0.0], [0.866025368452769, -0.500000061196242, 0.0], [0.9945218964062968, -0.10452845339151909, 0.0], [0.951056490534413, 0.30901707365834336, -0.0], [0.7431448429718478, 0.6691305869292987, -0.0], [0.40673667947806075, 0.9135454414352694, -0.0], [0.0, 1.0, -0.0], [-0.40673667947806075, 0.9135454414352694, 0.0], [-0.7431448429718478, 0.6691305869292987, 0.0] … [0.0, -0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, -0.0, -1.0], [0.0, 0.0, 1.0]], nothing, RGB{Float64}(0.5, 0.5, 0.5), false)Build an MTG
mtg = build_mtg(4, 2)
add_geometry!(mtg, refmesh_cylinder, refmesh_leaf)
length(descendants(mtg, :geometry; ignore_nothing=true, self=true))10Visualize
plantviz(mtg, color=Dict("Cylinder" => :tan4, "Leaf" => :seagreen3))Notes
- Internal coordinates are unitless
Float64values in meters. - Transform composition is done with
compose_lr(t1, t2)(left-to-right semantics). - Use
LinearMap,Translation, andAffineMapfromCoordinateTransformations.