Need help with modular_tree?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

MaximeHerpin
950 Stars 155 Forks GNU General Public License v3.0 404 Commits 24 Opened issues

Services available

!
?

Need anything else?

Contributors list

# 218,829
Python
Vim
google-...
blender
97 commits
# 237,221
Python
C++
Shell
77 commits
# 418,399
Python
blender
termina...
command...
4 commits

Mtree

Mtree (previously Modular Tree) is a library for making 3d trees. It comes as an addon for blender but the c++ library can be used separately.

Table of contents

Installation (blender addon)

Go to the latest release. Under

Assets
, select the version corresponding to your os.\ Follow the blender documentation to install the downloaded addon.

Development

Dependencies

  • Cmake
  • Blender 2.93 or higher (if you want to to develop the blender addon)

Installation

  1. Clone the repository reccursively
    git clone --recursive https://github.com/MaximeHerpin/modular_tree
  2. Execute the
    build_mtree
    bash script corresponding to your platform.
  3. If all went well, a cmake project has been generated under
    mtree/build
    .
  4. You can bundle the blender addon by calling the addon bundling script.

Usage

A

Tree
is generated by executing a succession of
TreeFunction
. When being executed, a
TreeFunction
modifies the structure of the tree, and then calls children functions recursively.\ For example, a basic tree has a trunk and branches on the trunk. Such a tree can be generated as such:
c++
auto trunk = std::make_shared();
auto branches = std::make_shared();
trunk->add_child(branches); // branches are added on top of the trunk
Tree tree(trunk);
tree.execute_functions(); // The tree structure is generated
ManifoldMesher mesher; // A mesher is responsible of converting a tree into a 3d mesh. The ManifoldMesher ensures a smooth topology
mesher.radial_resolution = 32;
Mesh tree_mesh = mesher.mesh_tree(tree); // the resulting mesh contains the geometry of the tree in the form of vertices and triangles
A second layer of branches can be grown on top of the branches by adding another branch function as a child of the first branch function:
c++
auto branches_primary = std::make_shared();
auto branches_secondary = std::make_shared();
branches_primary.add_child(branches_secondary); // the secondray branches will be distributed on top of the primary branches
Some trees have healthy branches as well as a layer of thin dead branches along the trunk. This can be achieved by adding to branch functions with different parameters on the trunk: ```c++ auto trunk = std::makeshared(); auto brancheshealthy = std::makeshared(); auto branchesdead = std::makeshared(); branchesdead.length = RandomProperty{.1f,1f}; // dead branches will have a length between 10cm and 1m. branchesdead.startradius = ConstantProperty{.05f}; // dead branches will have a radius equal to 5% of the parent nodes

trunk->addchild(brancheshealthy); // both sets of branches are grown on top of the trunk trunk->addchild(branchesdead); Tree tree(trunk); ```

License

Blender being under the GPL license, the blender addon (all files under

python_classes
as well as
__init__.py
) is under the GPLv3 license.\ The Mtree library is under the MIT license.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.