Coder Social home page Coder Social logo

modular_tree's Introduction

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:

auto trunk = std::make_shared<TrunkFunction>();
auto branches = std::make_shared<BranchFunction>();
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:

auto branches_primary = std::make_shared<BranchFunction>();
auto branches_secondary = std::make_shared<BranchFunction>();
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:

auto trunk = std::make_shared<TrunkFunction>();
auto branches_healthy = std::make_shared<BranchFunction>();
auto branches_dead = std::make_shared<BranchFunction>();
branches_dead.length = RandomProperty{.1f,1f}; // dead branches will have a length between 10cm and 1m.
branches_dead.start_radius = ConstantProperty{.05f}; // dead branches will have a radius equal to 5% of the parent nodes

trunk->add_child(branches_healthy); // both sets of branches are grown on top of the trunk
trunk->add_child(branches_dead);
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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.