Code Monkey home page Code Monkey logo

tree-gen's Introduction

tree-gen

Blender plugin produced as part of my undergraduate dissertation: Procedural generation of tree models for use in computer graphics.

Tree Sample Image

Thanks to the awesome work of Luke Pflibsen-Jones you can install the zip through the Blender addon UI (or drop the extracted folder into your blender addons directory) and enable the plugin in user settings to start generating trees - now with a complete customisation UI!

Download the latest version from here.

(WIP) Docmentation is available on the Wiki.

The code is under GPL-3.0 License, any models generated using the tool are free for use without restriction in any context apart from direct sale as assets.

tree-gen's People

Contributors

friggog avatar oxervision avatar samipfjo avatar thisisadoghello avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tree-gen's Issues

Assign each branch layer to separate vertex groups

Me again, sorry.

A great help would be to assign geometry to a vertex group per level. So there would be up to 4 vertex groups ready for custom manipulation/application of sub-materials, displacements and decimation. You might even name these: Trunk, Branches01, Branches02, Branches03.

Just a thought. Should be easy to implement and a huge timer saver for your users.

license of generated trees

Hi,
I would like to ask you, If I were to use this plugin to generate some trees, how would those trees themselves be governed in relation to the GPL license? I do not wish to make any of the work in which the trees are used as GPL too. I am no lawyer and I find GPL extremely difficult to understand.
Thanks

ZeroDivisionError on 4-level trees

This error is due to several of the stock parameter files having zero in their fourth-tier Length parameter. It can be remedied by simply providing a non-zero length parameter.

How should we want to handle this? I suggest a sanity-check function that executes before anything else when the generate button is pressed. Said function would read the parameters, check for conflicts, and throw a helpful error if it finds one. This would have the added benefit of centralizing most of the addon's "you're doing it wrong" messages, and would be easily expandable as we/others find naughty combinations. Thoughts?


To reproduce:

  1. Load Apple tree preset
  2. Seed 1000
  3. Keep leaf generation enabled
  4. Set level count to 4
  5. Generate

Full stack trace:

Traceback (most recent call last):
  File "C:\Users\Luke\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\ch_trees\gui.py", line 196, in _construct
    scene.generate_leaves_input)
  File "C:\Users\Luke\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\ch_trees\parametric\gen.py", line 1242, in construct
    t.make()
  File "C:\Users\Luke\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\ch_trees\parametric\gen.py", line 180, in make
    self.create_branches()
  File "C:\Users\Luke\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\ch_trees\parametric\gen.py", line 257, in create_branches
    self.make_stem(turtle, Stem(0, trunk))
  File "C:\Users\Luke\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\ch_trees\parametric\gen.py", line 589, in make_stem
    self.make_branches(turtle, stem, seg_ind, branches_on_seg, prev_rotation_angle)
  File "C:\Users\Luke\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\ch_trees\parametric\gen.py", line 913, in make_branches
    self.make_stem(dir_tur, Stem(d_plus_1, new_spline, stem, b_offset, rad), pos_corr_turtle=pos_tur)
  File "C:\Users\Luke\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\ch_trees\parametric\gen.py", line 589, in make_stem
    self.make_branches(turtle, stem, seg_ind, branches_on_seg, prev_rotation_angle)
  File "C:\Users\Luke\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\ch_trees\parametric\gen.py", line 913, in make_branches
    self.make_stem(dir_tur, Stem(d_plus_1, new_spline, stem, b_offset, rad), pos_corr_turtle=pos_tur)
  File "C:\Users\Luke\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\ch_trees\parametric\gen.py", line 589, in make_stem
    self.make_branches(turtle, stem, seg_ind, branches_on_seg, prev_rotation_angle)
  File "C:\Users\Luke\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\ch_trees\parametric\gen.py", line 913, in make_branches
    self.make_stem(dir_tur, Stem(d_plus_1, new_spline, stem, b_offset, rad), pos_corr_turtle=pos_tur)
  File "C:\Users\Luke\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\ch_trees\parametric\gen.py", line 430, in make_stem
    leaf_count = self.calc_leaf_count(stem)
  File "C:\Users\Luke\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\ch_trees\parametric\gen.py", line 1035, in calc_leaf_count
    result = leaves * (stem.length / (stem.parent.length_child_max * stem.parent.length))
ZeroDivisionError: float division by zero

No module named tree-gen-0

Hi,
I have installed the add-on from the blender add-on installer interface, when i try to enable the add on I get the error "No module named tree-gen-0" I am running blender version 2.93.6.
Screenshot attached. Any help is appreciated. Thank you.
Screenshot from 2021-12-13 22-15-50

suggestion for repo

thanks for your excellent repo.

a suggestion for easy usability, it's best to make the project so the init.py and other files are the top level directory.

This allows people to install who have lower technical knowledge (you can install zips with blenders menu), otherwise you have to manually install to the folders.

Distribution cannot be set to > 1

It is not possible to enter a distribution value larger than 1. This is due to gui.py line 113 have a max of 1. Removing the max parameter appears to fix the issue.

Error when installing through Blender's UI

The folder name inside the zip source includes the version number which makes the folder an invalid python id when blender tries to import it.

Steps to reproduce

  1. Open Blender's addon menu
  2. Click install
  3. Select the downloaded zip file
  4. Click the check box to enable the addon
  5. See the error in the console
Traceback (most recent call last):
  File "D:\Programs\Blender\2.90.1\2.90\scripts\modules\addon_utils.py", line 351, in enable
    mod = __import__(module_name)
ModuleNotFoundError: No module named 'tree-gen-0'

The folder in that path is actually tree-gen-0.0.3 which is the same as in the original zip file.
The solution is probably to create a github workflow to build the install file correctly

Discontinue support for Blender 2.79

It's getting a pain to maintain master and 2.79 branches in parallel - now seems like a reasonable time to discontinue support for 2.79 - what do you think @luketimothyjones?

Allow creation of custom trees through UI (WIP)

I have all the custom options displaying fairly decently in my parameter-customizer branch. Still need to implement loading the parameters before generation, but the inputs are present and they're locked to the ranges specified in the paper. I'm also planning on allowing users to save the parameters to a file (ala the existing format).

In other words, I'm back working on the project, now in a timezone even further from you than before (PDT/PST)! I have a full-time job, so my contributions may be more sporadic than before, but I'll be around.

image

Addon activation error on Blender 2.91

Hello !
I'm getting this error when trying to activate on Blender 2.91

Traceback (most recent call last): File "N:\Blender\Builds\stable\blender-2.91.0-windows64\2.91\scripts\modules\addon_utils.py", line 351, in enable mod = __import__(module_name) File "N:\Blender\Scripts\addons\tree-gen\__init__.py", line 13, in <module> from . import gui File "N:\Blender\Scripts\addons\tree-gen\gui.py", line 12, in <module> from ch_trees import parametric, utilities ModuleNotFoundError: No module named 'ch_trees'
Is there something i'm missing ?
Note that my addons folder is not the one located in the blender install, but a separated folder used in the paths in Blender prefs.

crash with enabled Simplifying tree branch geometry (tree +leaves)

latest master version 4cb4610
blender 2.79
fedora 28

Read prefs: /home/arpu/.config/blender/2.79/config/userpref.blend
STARTUP!!

Loading CATS...

READING SETTINGS FILE
SETTINGS LOADED!
CHECK UPDATE
READING FILE
SUPPORTER LIST FILE FOUND!
DICTIONARY LOADED!
DAYS SINCE GOOGLE DICT CREATION: 1
GOOGLE DICTIONARY LOADED!

Loaded CATS successfully!

TreeGen :: Warning: Unrecognized name in configuration "leaves"
** Generating Tree **

Making Stems
-> 6900 stems made
Stems made: 6991 in 4.566210 seconds
Curve points: 29870

Making Leaves
-> 81000 leaves made, 0 blossoms made
Made 81265 leaves and 0 blossoms in 2.882919 seconds

Tree generated in 7.526423 seconds

Simplifying tree branch geometry. Blender will appear to crash; be patient.
Exception in thread Thread-4:
Traceback (most recent call last):
File "/home/arpu/.config/blender/2.79/scripts/addons/ch_trees/gui.py", line 114, in _construct
utilities.simplify_branch_geometry(context)
File "/home/arpu/.config/blender/2.79/scripts/addons/ch_trees/utilities.py", line 85, in simplify_branch_geometry
bpy.data.objects.remove(old_branches)
ReferenceError: StructRNA of type Object has been removed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/arpu/.config/blender/2.79/scripts/addons/ch_trees/gui.py", line 118, in _construct
sys.stdout.write('\n{}\n'.format(traceback.print_exec()))
AttributeError: module 'traceback' has no attribute 'print_exec'

2018-12-05 22:23:21
COMMIT IDENTICAL
Saved session recovery to '/tmp/quit.blend'

Blender quit

Add "flare" option for the first level of branches off trunk

Certainly for the larger trees such as Oak, the ability to add "flares" to the branch start would really help them look less like they're rammed into the trunk mesh. I have been manually doing this for the lower branches on my trees as illustrated below:

image

add default materials

Maybe Im missing something here Im new to blender

If I add 10 trees each will show as gray and have no default materials I have to create for example 1 brown and 1 green generic material then click on each tree and their parts to select green or brown color, Im not interested in textures or things but just for simple visualisation it would be easier if each tree came with default colors or maybe in the generation dialog you could select preexisting materials and then each new is created with those materials as chosen.

how can you select all the added trees and set the leaf colors or branch colors of all for example?

Add options for bevel amount

Hi,

Love the add-on. Really useful and better results than Sapling.

This is more of a feature request:

I really think you could provide the option to set the 'Bevel' amount of the spline for the tree instead of hard-coding it at 10.

It seems excessive and an oversight considering you are able to change the Curve Resolution.

I've had to manually adjust your code to reduce the Bevel amount to 2.

Could you please either:

a) add a global Bevel amount option to the 'Tree Parameters'?

or (even better)

b) add the option to adjust the Bevel amount for each of the 4 'levels' and add this to the 'Branch Parameters'?

I appreciate option b might be a bit more involved, but it would add a huge amount of control for those of us using the add-on for mid-distance range trees.

Oh, and one last thing, when the tree is automatically converted to a mesh, is there a way you could run a 'merge by distance' for the verts? Set it to something really low like 0.0001m. That would be useful. Maybe offer it as a tick box?

Thanks for your work on this. Keep it up!

__init__.py

IN the new version init.py ist started with
nbl_info = {
"name": "TreeGen",
I think n is my mistake

Speed up leaf generation using DupliVerts

I was reading through the Sapling source code and noticed something cool; it uses DupliVerts to place the leaf meshes. I haven't tested it for speed, but given that it's a built-in feature of Blender, I'm betting it's faster than the current method.

I don't know if this would be straying too far from the intent of the project (an implementation of code from the source papers), but perhaps it could be provided as a toggleable option? If it is indeed faster, it could make generating conifers more bearable.

Wiki and Examples

Would be good to have a wiki with detail on how to use the plugin and some example renders.

Update tree function

It would be great to have an update function, in order to avoid having to regenerate the whole tree or generate a new one.

Any file describing how to use the addon

Hello!

I'm sorry if I'm really dumb, but I can't make the addon to work. I searched for help before coming here, as well took a look on the academic document about the generator. But I simply can't even get started. I imported the addon but can't find it anywhere while using Blender.
Any advise?

Thank you and thanks for the amazing work!

cant generate leaves

ive tried unisntaling and instaling the addon tweaked about with everything but for some reason they just dont generate

Ability to use custom leaf object

Also from #48

Currently we get the shape here:

tree-gen/parametric/gen.py

Lines 293 to 298 in 0b0bc62

# go through global leaf array populated in branch making phase and add polygons to mesh
base_leaf_shape = Leaf.get_shape(self.param.leaf_shape, self.tree_scale / self.param.g_scale,
self.param.leaf_scale, self.param.leaf_scale_x)
base_blossom_shape = Leaf.get_shape(-self.param.blossom_shape, self.tree_scale / self.param.g_scale,
self.param.blossom_scale, 1)

We should be able to alter the UI to let the user select a mesh object from the scene then get the mesh vertices to use as the base shape instead of getting the mesh from the cached list as currently happens.

Crashes in 2.90.1

I really like the models, and the dissertation was an interesting read, but unfortunately the plugin crashes for me in 2.90.1 on Ubuntu 20.04 when generating leaves.

Using the standard quaking aspen, this is the crash log:


# backtrace
/usr/lib/blender/blender(BLI_system_backtrace+0x37) [0x55b68d4e4617]
/usr/lib/blender/blender(+0x1002403) [0x55b677a61403]
/lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7fd9dec78210]
/usr/lib/blender/blender(WM_cursor_time+0x23) [0x55b677d52303]
/usr/lib/blender/blender(RNA_function_call+0x16) [0x55b677f30066]
/usr/lib/blender/blender(+0x16263cf) [0x55b6780853cf]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(_PyObject_MakeTpCall+0xa7) [0x7fd9e1042697]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(+0x73083) [0x7fd9e0e14083]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(_PyEval_EvalFrameDefault+0x8067) [0x7fd9e0e1c467]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(+0x7e0db) [0x7fd9e0e1f0db]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(+0x72ffd) [0x7fd9e0e13ffd]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(_PyEval_EvalFrameDefault+0x19f2) [0x7fd9e0e15df2]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(+0x7e0db) [0x7fd9e0e1f0db]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(+0x72ffd) [0x7fd9e0e13ffd]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(_PyEval_EvalFrameDefault+0x19f2) [0x7fd9e0e15df2]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(_PyEval_EvalCodeWithName+0x8fb) [0x7fd9e0f6688b]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(_PyFunction_Vectorcall+0x90) [0x7fd9e1041cd0]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(+0x72ffd) [0x7fd9e0e13ffd]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(_PyEval_EvalFrameDefault+0x8067) [0x7fd9e0e1c467]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(+0x7e0db) [0x7fd9e0e1f0db]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(+0x2a192a) [0x7fd9e104292a]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(+0x72ffd) [0x7fd9e0e13ffd]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(_PyEval_EvalFrameDefault+0x8067) [0x7fd9e0e1c467]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(+0x7e0db) [0x7fd9e0e1f0db]
/usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0(PyVectorcall_Call+0x5c) [0x7fd9e10423cc]
/usr/lib/blender/blender(+0x16270ad) [0x55b6780860ad]
/usr/lib/blender/blender(+0x1601b89) [0x55b678060b89]
/usr/lib/blender/blender(+0x12c7380) [0x55b677d26380]
/usr/lib/blender/blender(+0x12c78eb) [0x55b677d268eb]
/usr/lib/blender/blender(WM_operator_name_call_ptr+0x1e) [0x55b677d26e3e]
/usr/lib/blender/blender(+0x194bae6) [0x55b6783aaae6]
/usr/lib/blender/blender(+0x195c5e9) [0x55b6783bb5e9]
/usr/lib/blender/blender(+0x12cb3e6) [0x55b677d2a3e6]
/usr/lib/blender/blender(+0x12cba4c) [0x55b677d2aa4c]
/usr/lib/blender/blender(wm_event_do_handlers+0x4ad) [0x55b677d2b2cd]
/usr/lib/blender/blender(WM_main+0x20) [0x55b677d21c70]
/usr/lib/blender/blender(main+0x2b7) [0x55b677a0af57]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7fd9dec590b3]
/usr/lib/blender/blender(_start+0x2e) [0x55b677a5d92e]

# Python backtrace
  File "/home/r/.config/blender/2.90/scripts/addons/ch_trees/parametric/gen.py", line 303 in create_leaf_mesh
  File "/home/r/.config/blender/2.90/scripts/addons/ch_trees/parametric/gen.py", line 184 in make
  File "/home/r/.config/blender/2.90/scripts/addons/ch_trees/parametric/gen.py", line 1249 in construct
  File "/home/r/.config/blender/2.90/scripts/addons/ch_trees/gui.py", line 229 in _construct
  File "/home/r/.config/blender/2.90/scripts/addons/ch_trees/gui.py", line 198 in execute

Commenting out all calls to the bpy.context.window_manager seems to resolve the issue.

blender 2.83

in blender 2.83 clicking generate trees simply creates an empty

Split Angle not working/ no effect

Hi, I have noticed that the branch parameter "Split Angle" doesn't work, when keeping everething the same aswel as the seed and only changing the Split Angle parameter there seems to be no difference at all. Is this a bug or am I just using the library wrongly.

The values I used for split angle are 10, 20, 30
my_custom_tree.zip

Grow shyness

Hey.
Could you implement an prune based on an vonroi volume to simulate grow shyness.
DZTs2ViU8AAbaof

Blender 2.80 compatibility

The way that classes are registered has changed. Additionally, properties use type annotations now.

The class registration should be easy, and type annotations shouldn't be too bad, either. There will inevitably be other things that break.

Let's keep track of progress here.

Animation

Long term goal of wind sway animation, probably using armatures.

Seems that the Sapling implementation does almost exactly what we need. I.e. iterate over the curve (up to a level) and add an armature using the bezier points.

Hopefully using this as a basis and the wind sway equations from the original paper we should be able to do this relatively easily.

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.