tutorials:qsm:to-growable
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorials:qsm:to-growable [2025/10/13 14:52] – created Tim | tutorials:qsm:to-growable [2025/10/13 16:25] (current) – [Apical] Tim | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Turning a QSM into a growable model ====== | ====== Turning a QSM into a growable model ====== | ||
+ | In the following tutorial we will take a small QSM file, transform the existing cylinders into modules and add additional organs(Buds, | ||
+ | |||
+ | |||
+ | ===== Shoots ===== | ||
+ | |||
+ | In order to add more variables or functions to the individual shoots, we first turn our imported shoots into our own kind of shoots. For now the module MyShoot can be very simple (basically just a brown cylinder): | ||
+ | |||
+ | <code java> | ||
+ | module MyShoot(super.length, | ||
+ | </ | ||
+ | |||
+ | To use these new shoots we need a rule to turn all imported F's into MyShoot' | ||
+ | < | ||
+ | f:F ==> MyShoot(f.length, | ||
+ | </ | ||
+ | |||
+ | Yet there is an important addition here, that is different to normal L-System rule: we need to keep the local transformation that keeps the cylinders in place. | ||
+ | |||
+ | We can do this by applying an expression directly to the newly created shoot using ' | ||
+ | < | ||
+ | f:F ==> MyShoot(f.length, | ||
+ | </ | ||
+ | |||
+ | |||
+ | This is for now the core of our update function, which we can also extend by using the qsm library function | ||
+ | '' | ||
+ | |||
+ | |||
+ | <code java step1.rgg> | ||
+ | import static de.grogra.qsm.utils.Library.*; | ||
+ | module MyShoot(super.length, | ||
+ | |||
+ | public void update()[ | ||
+ | { jumpAllAxis(); | ||
+ | f:F ==> MyShoot(f.length, | ||
+ | ] | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ===== Adding buds ===== | ||
+ | |||
+ | In order to create new shoots we first need new buds, therefore the module " | ||
+ | < | ||
+ | module MyBud(int order, float length) extends Sphere(0.002){{setShader(EGA_3); | ||
+ | </ | ||
+ | |||
+ | ==== Apical ==== | ||
+ | <code java step2.rgg> | ||
+ | import static de.grogra.qsm.utils.Library.*; | ||
+ | import static de.grogra.qsm.utils.Descriptors.*; | ||
+ | module MyShoot(super.length, | ||
+ | module MyBud(int order, float length) extends Sphere(0.002){{setShader(EGA_3); | ||
+ | public void update()[ | ||
+ | { | ||
+ | | ||
+ | } | ||
+ | f: | ||
+ | f:F ==> MyShoot(f.length, | ||
+ | ] | ||
+ | |||
+ | |||
+ | public void grow()[ | ||
+ | MyBud(o, | ||
+ | |||
+ | ] | ||
+ | |||
+ | </ | ||
+ | ==== Lateral ==== | ||
+ | |||
+ | ===== Adding needles ===== | ||
tutorials/qsm/to-growable.1760359956.txt.gz · Last modified: 2025/10/13 14:52 by Tim