Skip to content

PlantGeom.jlEverything 3D for plants 🌱

Read, build, reconstruct, and visualize 3D scenes with plants.

Coffee plant

PlantGeom.jl ​

PlantGeom lets you build, reconstruct, and visualize 3D plants powered by Makie.jl.

Basic usage ​

  1. Import the package and one of Makie's backends (e.g. CairoMakie or GLMakie)

  2. Read a plant or scene from a file or build one with PlantGeom's API

  3. Visualize it with plantviz

Read 3D files and visualize ​

We can read a plant from an OpenPlantFormat file (.opf) and visualize it with plantviz:

julia
using PlantGeom
using CairoMakie
files_dir = joinpath(dirname(dirname(pathof(PlantGeom))), "test", "files")
coffee = read_opf(joinpath(files_dir, "coffee.opf"))
plantviz(coffee, figure=(size=(980, 720),))

Simulate growth ​

We can build a plant with PlantGeom's growth API, and we can also color it with any attribute, e.g. height:

julia
using PlantGeom
using CairoMakie
include(joinpath(pkgdir(PlantGeom), "docs", "src", "getting_started", "tree_demo_helpers.jl"))
tree_demo = build_demo_tree_with_growth_api()
f, ax, p = plantviz(tree_demo, figure=(size=(860, 780),), color=:ZZ)
colorbar(f[1, 2], p, label="Height")
f

Build geometry from a Multi-scale Tree Graph ​

You can also read an MTG (Multi-Scale Tree Graph) and PlantGeom will automatically build its geometry based on the standard MTG's topology and attributes along with reference meshes for organs:

julia
using PlantGeom
using MultiScaleTreeGraph
using GeometryBasics
using Colors
using CairoMakie

mtg = read_mtg(joinpath(pkgdir(PlantGeom), "test", "files", "reconstruction_standard.mtg"))
stem_reference_mesh = RefMesh("stem", GeometryBasics.mesh(GeometryBasics.Cylinder(Point(0,0,0), Point(1,0,0), 0.5)), RGB(0.5, 0.38, 0.26))
leaf_reference_mesh = lamina_refmesh("leaf"; length=1.0, max_width=1.0, material=RGB(0.2, 0.62, 0.30))
prototypes = Dict(:Internode => RefMeshPrototype(stem_reference_mesh), :Leaf => RefMeshPrototype(leaf_reference_mesh))
set_geometry_from_attributes!(mtg, prototypes; convention=default_amap_geometry_convention())
plantviz(mtg, figure=(size=(900, 620),))

Mini Glossary ​

Here's a mini glossary of some of the terms used in PlantGeom.jl documentation:

TermPractical meaning
NodeA node (computer-graphics node, not botanic) representing one organ instance (stem segment, leaf, etc.)
MTGgraph made of connected Nodes storing topology + attributes
RefMeshreusable normalized reference mesh for organs, e.g. the mesh used for the leaves
Prototyperule for turning node attributes into geometry
rebuild_geometry!explicit geometry generation/update step