Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom bevel amounts per-level #61

Merged
merged 3 commits into from
Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class TreeGen(bpy.types.Operator):

_scene.tree_bend_v_input = _props.FloatVectorProperty(name="", description="Maximum angle by which the direction of the branch may change from start to end, rotating about the branch’s local y-axis. Applied randomly at each segment", default=(0, 50, 0, 0), size=4, min=0, max=360)

_scene.tree_curve_res_input = _props.FloatVectorProperty(name="", description="Number of segments in each branch", default=(5, 5, 3, 1), size=4, min=1, max=10)
_scene.tree_bevel_res_input = _props.IntVectorProperty(name="", description="Number of segments in each branch", default=(10, 10, 10, 10), size=4, min=1, max=10)
samipfjo marked this conversation as resolved.
Show resolved Hide resolved
_scene.tree_curve_res_input = _props.IntVectorProperty(name="", description="Number of segments in each branch", default=(5, 5, 3, 1), size=4, min=1, max=10)
_scene.tree_curve_input = _props.FloatVectorProperty(name="", description="Angle by which the direction of the branch will change from start to end, rotating about the branch’s local x-axis", default=(0, -40, -40, 0), size=4, min=-360, max=360)
_scene.tree_curve_v_input = _props.FloatVectorProperty(name="", description="Maximum variation in curve angle of a branch. Applied randomly at each segment", default=(20, 50, 75, 0), size=4, min=-360, max=360)
_scene.tree_curve_back_input = _props.FloatVectorProperty(name="", description="Angle in the opposite direction to the curve that the branch will curve back from half way along, creating S shaped branches", default=(0, 0, 0, 0), size=4, min=-360, max=360)
Expand Down Expand Up @@ -267,10 +268,10 @@ def get_params_from_customizer(context):

param_names = ['shape', 'g_scale', 'g_scale_v', 'levels', 'ratio', 'flare', 'ratio_power',
'base_size', 'down_angle', 'down_angle_v', 'rotate', 'rotate_v', 'branches',
'length', 'length_v', 'taper', 'seg_splits', 'split_angle', 'split_angle_v', 'curve_res',
'curve', 'curve_back', 'curve_v', 'bend_v', 'branch_dist', 'radius_mod', 'leaf_blos_num',
'leaf_shape', 'leaf_scale', 'leaf_scale_x', 'leaf_bend', 'blossom_shape', 'blossom_scale',
'blossom_rate', 'tropism', 'prune_ratio', 'prune_width', 'prune_width_peak',
'length', 'length_v', 'taper', 'seg_splits', 'split_angle', 'split_angle_v', 'bevel_res',
'curve_res', 'curve', 'curve_back', 'curve_v', 'bend_v', 'branch_dist', 'radius_mod',
'leaf_blos_num', 'leaf_shape', 'leaf_scale', 'leaf_scale_x', 'leaf_bend', 'blossom_shape',
'blossom_scale', 'blossom_rate', 'tropism', 'prune_ratio', 'prune_width', 'prune_width_peak',
'prune_power_low', 'prune_power_high', 'base_splits']

params = {}
Expand Down Expand Up @@ -564,6 +565,7 @@ def label_row(label, prop, checkbox=False, dropdown=False, container=None):
label_row('Taper', 'tree_taper_input', container=box)
label_row('Radius Modifier', 'tree_radius_mod_input', container=box)
box.separator()
label_row('Curve Bevel Resolution', 'tree_bevel_res_input', container=box)
label_row('Curve Resolution', 'tree_curve_res_input', container=box)
label_row('Curve', 'tree_curve_input', container=box)
label_row('Curve Variation', 'tree_curve_v_input', container=box)
Expand Down
10 changes: 5 additions & 5 deletions parametric/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ def create_branches(self):
start_time = time.time()

# Set up container objects and curves for each level
for level_name in ['Trunk'] + ['Branches' + str(_) for _ in range(1, self.param.levels)]:
for level_depth, level_name in enumerate(['Trunk'] + ['Branches' + str(_) for _ in range(1, self.param.levels)]):
level_curve = bpy.data.curves.new(level_name.lower(), type='CURVE')
level_curve.dimensions = '3D'
level_curve.resolution_u = 4
level_curve.resolution_u = self.param.curve_res[level_depth]
level_curve.fill_mode = 'FULL'
level_curve.bevel_depth = 1
level_curve.bevel_resolution = 10
level_curve.bevel_resolution = self.param.bevel_res[level_depth]

# Removed in Blender 2.82+
if hasattr(level_curve, 'use_uv_as_generated'):
Expand Down Expand Up @@ -267,7 +267,7 @@ def create_branches(self):

trunk = self.branch_curves[0].splines.new('BEZIER')
trunk.radius_interpolation = 'CARDINAL'
trunk.resolution_u = 2
trunk.resolution_u = self.param.curve_res[0]

self.make_stem(turtle, Stem(0, trunk))

Expand Down Expand Up @@ -924,7 +924,7 @@ def make_branches(self, turtle, stem, seg_ind, branches_on_seg, prev_rotation_an
else:
for pos_tur, dir_tur, rad, b_offset in branches_array:
new_spline = self.branch_curves[d_plus_1].splines.new('BEZIER')
new_spline.resolution_u = 6
new_spline.resolution_u = self.param.curve_res[d_plus_1]
new_spline.radius_interpolation = 'CARDINAL'
self.make_stem(dir_tur, Stem(d_plus_1, new_spline, stem, b_offset, rad), pos_corr_turtle=pos_tur)

Expand Down
1 change: 1 addition & 0 deletions parametric/tree_params/tree_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'seg_splits': [0, 0, 0, 0],
'split_angle': [40, 0, 0, 0],
'split_angle_v': [5, 0, 0, 0],
'bevel_res': [10, 10, 10, 10],
'curve_res': [5, 5, 3, 1],
'curve': [0, -40, -40, 0],
'curve_back': [0, 0, 0, 0],
Expand Down