Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.idea/
6 changes: 6 additions & 0 deletions sapling_4/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ def no_update_tree(self, context):
min=0.0,
max=1.0,
default=0.20, update=update_tree)
leafBaseLevel: IntProperty(name='Leaf Start Level',
description='Level of branches on which leaves appear',
min=0,
max=4 ,
default=1, update=update_tree)
splitHeight: FloatProperty(name='Split Height',
description='Fraction of tree height with no splits',
min=0.0,
Expand Down Expand Up @@ -894,6 +899,7 @@ def draw(self, context):
box.prop(self, 'leafDist')

box.label(text="")
box.prop(self, 'leafBaseLevel')
box.prop(self, 'leafType')
box.prop(self, 'leafangle')
row = box.row()
Expand Down
2 changes: 1 addition & 1 deletion sapling_4/presets/Small Pine.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{'bevel': True, 'showLeaves': True, 'useArm': False, 'seed': 0, 'handleType': '0', 'bevelRes': 2, 'resU': 4, 'levels': 3, 'length': (1.0, 0.33000001311302185, 0.75, 0.44999998807907104), 'lengthV': (0.0, 0.15000000596046448, 0.25, 0.0), 'taperCrown': 0.0, 'branches': (0, 36, 10, 10), 'curveRes': (10, 5, 3, 1), 'curve': (0.0, 40.0, 30.0, 0.0), 'curveV': (12.5, 20.0, 33.33333206176758, 0.0), 'curveBack': (0.0, 0.0, 0.0, 0.0), 'baseSplits': 0, 'segSplits': (0.0, 0.30000001192092896, 0.4000000059604645, 0.0), 'splitByLen': True, 'rMode': 'rotate', 'splitStraight': 0.5, 'splitLength': 0.0, 'splitAngle': (0.0, 44.0, 50.0, 0.0), 'splitAngleV': (0.0, 5.0, 0.0, 0.0), 'scale': 4.0, 'scaleV': 1.0, 'attractUp': (2.0, 0.0, 0.5, 0.5), 'attractOut': (0.0, 0.0, 0.0, 0.0), 'shape': '8', 'shapeS': '4', 'customShape': (1.0, 1.0, 0.20000000298023224, 0.20000000298023224), 'branchDist': 1.5, 'nrings': 7, 'baseSize': 0.06799984723329544, 'baseSize_s': 0.25, 'leafBaseSize': 0.20000000298023224, 'splitHeight': 0.20000000298023224, 'splitBias': 0.0, 'ratio': 0.019999999552965164, 'minRadius': 0.001500000013038516, 'closeTip': False, 'rootFlare': 1.25, 'splitRadiusRatio': 0.0, 'autoTaper': True, 'taper': (1.0, 1.0, 1.0, 1.0), 'noTip': False, 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'ratioPower': 1.0, 'downAngle': (90.0, 110.0, 45.0, 45.0), 'downAngleV': (0.0, 42.0, 10.0, 10.0), 'useOldDownAngle': False, 'useParentAngle': True, 'rotate': (99.5, 137.5, -90.0, 137.5), 'rotateV': (15.0, 0.0, 0.0, 0.0), 'scale0': 1.0, 'scaleV0': 0.10000000149011612, 'attachment': '1', 'leaves': 500, 'leafType': '5', 'leafDownAngle': 65.0, 'leafDownAngleV': 55.0, 'leafRotate': 137.5, 'leafRotateV': 30.0, 'leafObjZ': '+2', 'leafObjY': '+1', 'leafScale': 0.20000000298023224, 'leafScaleX': 0.019999999552965164, 'leafScaleT': 0.25, 'leafScaleV': 0.10000000149011612, 'leafShape': 'rect', 'leafangle': -10.0, 'leafDist': '3', 'armAnim': False, 'previewArm': False, 'leafAnim': False, 'frameRate': 1.0, 'loopFrames': 0, 'wind': 1.0, 'gust': 1.0, 'gustF': 0.07500000298023224, 'af1': 1.0, 'af2': 1.0, 'af3': 4.0, 'makeMesh': False, 'armLevels': 2, 'boneStep': (1, 1, 1, 1), 'matIndex': (0, 0, 0, 0)}
{'bevel': True, 'showLeaves': True, 'useArm': False, 'seed': 0, 'handleType': '0', 'bevelRes': 2, 'resU': 4, 'levels': 3, 'length': (1.0, 0.33000001311302185, 0.75, 0.44999998807907104), 'lengthV': (0.0, 0.15000000596046448, 0.25, 0.0), 'taperCrown': 0.0, 'branches': (0, 36, 10, 10), 'curveRes': (10, 5, 3, 1), 'curve': (0.0, 40.0, 30.0, 0.0), 'curveV': (12.5, 20.0, 33.33333206176758, 0.0), 'curveBack': (0.0, 0.0, 0.0, 0.0), 'baseSplits': 0, 'segSplits': (0.0, 0.30000001192092896, 0.4000000059604645, 0.0), 'splitByLen': True, 'rMode': 'rotate', 'splitStraight': 0.5, 'splitLength': 0.0, 'splitAngle': (0.0, 44.0, 50.0, 0.0), 'splitAngleV': (0.0, 5.0, 0.0, 0.0), 'scale': 4.0, 'scaleV': 1.0, 'attractUp': (2.0, 0.0, 0.5, 0.5), 'attractOut': (0.0, 0.0, 0.0, 0.0), 'shape': '8', 'shapeS': '4', 'customShape': (1.0, 1.0, 0.20000000298023224, 0.20000000298023224), 'branchDist': 1.5, 'nrings': 7, 'baseSize': 0.06799984723329544, 'baseSize_s': 0.25, 'leafBaseSize': 0.20000000298023224, 'leafBaseLevel': 2, 'splitHeight': 0.20000000298023224, 'splitBias': 0.0, 'ratio': 0.019999999552965164, 'minRadius': 0.001500000013038516, 'closeTip': False, 'rootFlare': 1.25, 'splitRadiusRatio': 0.0, 'autoTaper': True, 'taper': (1.0, 1.0, 1.0, 1.0), 'noTip': False, 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'ratioPower': 1.0, 'downAngle': (90.0, 110.0, 45.0, 45.0), 'downAngleV': (0.0, 42.0, 10.0, 10.0), 'useOldDownAngle': False, 'useParentAngle': True, 'rotate': (99.5, 137.5, -90.0, 137.5), 'rotateV': (15.0, 0.0, 0.0, 0.0), 'scale0': 1.0, 'scaleV0': 0.10000000149011612, 'attachment': '1', 'leaves': 1500, 'leafType': '5', 'leafDownAngle': 65.0, 'leafDownAngleV': 55.0, 'leafRotate': 137.5, 'leafRotateV': 30.0, 'leafObjZ': '+2', 'leafObjY': '+1', 'leafScale': 0.20000000298023224, 'leafScaleX': 0.019999999552965164, 'leafScaleT': 0.25, 'leafScaleV': 0.10000000149011612, 'leafShape': 'rect', 'leafangle': -10.0, 'leafDist': '3', 'armAnim': False, 'previewArm': False, 'leafAnim': False, 'frameRate': 1.0, 'loopFrames': 0, 'wind': 1.0, 'gust': 1.0, 'gustF': 0.07500000298023224, 'af1': 1.0, 'af2': 1.0, 'af3': 4.0, 'makeMesh': False, 'armLevels': 2, 'boneStep': (1, 1, 1, 1), 'matIndex': (0, 0, 0, 0)}
2 changes: 1 addition & 1 deletion sapling_4/presets/White Birch.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{'bevel': True, 'showLeaves': True, 'useArm': False, 'seed': 0, 'handleType': '0', 'bevelRes': 2, 'resU': 2, 'levels': 3, 'length': (1.0, 0.33000001311302185, 0.375, 0.44999998807907104), 'lengthV': (0.05000000074505806, 0.20000000298023224, 0.3499999940395355, 0.0), 'taperCrown': 0.0, 'branches': (0, 60, 30, 10), 'curveRes': (10, 8, 3, 1), 'curve': (0.0, 30.0, 25.0, 0.0), 'curveV': (10.0, 10.0, 25.0, 0.0), 'curveBack': (0.0, 0.0, 0.0, 0.0), 'baseSplits': 2, 'segSplits': (0.3499999940395355, 0.3499999940395355, 0.3499999940395355, 0.0), 'splitByLen': True, 'rMode': 'rotate', 'splitStraight': 0.0, 'splitLength': 0.0, 'splitAngle': (20.0, 36.0, 32.0, 0.0), 'splitAngleV': (2.0, 2.0, 0.0, 0.0), 'scale': 12.0, 'scaleV': 2.0, 'attractUp': (0.0, -1.0, -0.6499999761581421, 0.0), 'attractOut': (0.0, 0.20000000298023224, 0.25, 0.0), 'shape': '8', 'shapeS': '7', 'customShape': (0.699999988079071, 1.0, 0.30000001192092896, 0.5900000333786011), 'branchDist': 1.5, 'nrings': 0, 'baseSize': 0.3499999940395355, 'baseSize_s': 0.800000011920929, 'leafBaseSize': 0.20000000298023224, 'splitHeight': 0.550000011920929, 'splitBias': 0.0, 'ratio': 0.019999999552965164, 'minRadius': 0.0020000000949949026, 'closeTip': False, 'rootFlare': 1.149999976158142, 'splitRadiusRatio': 0.0, 'autoTaper': True, 'taper': (1.0, 1.0, 1.0, 1.0), 'noTip': False, 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'ratioPower': 1.0, 'downAngle': (90.0, 60.0, 50.0, 45.0), 'downAngleV': (0.0, 25.0, 30.0, 10.0), 'useOldDownAngle': False, 'useParentAngle': True, 'rotate': (99.5, 137.5, 137.5, 137.5), 'rotateV': (0.0, 0.0, 0.0, 0.0), 'scale0': 1.0, 'scaleV0': 0.10000000149011612, 'attachment': '0', 'leaves': 16, 'leafType': '0', 'leafDownAngle': 45.0, 'leafDownAngleV': 10.0, 'leafRotate': 137.5, 'leafRotateV': 0.0, 'leafObjZ': '+2', 'leafObjY': '+1', 'leafScale': 0.20000000298023224, 'leafScaleX': 0.5, 'leafScaleT': 0.20000000298023224, 'leafScaleV': 0.25, 'leafShape': 'hex', 'leafangle': -45.0, 'leafDist': '6', 'armAnim': False, 'previewArm': False, 'leafAnim': False, 'frameRate': 1.0, 'loopFrames': 0, 'wind': 1.0, 'gust': 1.0, 'gustF': 0.07500000298023224, 'af1': 1.0, 'af2': 1.0, 'af3': 4.0, 'makeMesh': False, 'armLevels': 0, 'boneStep': (1, 1, 1, 1), 'matIndex': (0, 0, 0, 0)}
{'bevel': True, 'showLeaves': True, 'useArm': False, 'seed': 0, 'handleType': '0', 'bevelRes': 2, 'resU': 2, 'levels': 3, 'length': (1.0, 0.33000001311302185, 0.375, 0.44999998807907104), 'lengthV': (0.05000000074505806, 0.20000000298023224, 0.3499999940395355, 0.0), 'taperCrown': 0.0, 'branches': (0, 60, 30, 10), 'curveRes': (10, 8, 3, 1), 'curve': (0.0, 30.0, 25.0, 0.0), 'curveV': (10.0, 10.0, 25.0, 0.0), 'curveBack': (0.0, 0.0, 0.0, 0.0), 'baseSplits': 2, 'segSplits': (0.3499999940395355, 0.3499999940395355, 0.3499999940395355, 0.0), 'splitByLen': True, 'rMode': 'rotate', 'splitStraight': 0.0, 'splitLength': 0.0, 'splitAngle': (20.0, 36.0, 32.0, 0.0), 'splitAngleV': (2.0, 2.0, 0.0, 0.0), 'scale': 12.0, 'scaleV': 2.0, 'attractUp': (0.0, -1.0, -0.6499999761581421, 0.0), 'attractOut': (0.0, 0.20000000298023224, 0.25, 0.0), 'shape': '8', 'shapeS': '7', 'customShape': (0.699999988079071, 1.0, 0.30000001192092896, 0.5900000333786011), 'branchDist': 1.5, 'nrings': 0, 'baseSize': 0.3499999940395355, 'baseSize_s': 0.800000011920929, 'leafBaseSize': 0.20000000298023224, 'splitHeight': 0.550000011920929, 'splitBias': 0.0, 'ratio': 0.019999999552965164, 'minRadius': 0.0020000000949949026, 'closeTip': False, 'rootFlare': 1.149999976158142, 'splitRadiusRatio': 0.0, 'autoTaper': True, 'taper': (1.0, 1.0, 1.0, 1.0), 'noTip': False, 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'ratioPower': 1.0, 'downAngle': (90.0, 60.0, 50.0, 45.0), 'downAngleV': (0.0, 25.0, 30.0, 10.0), 'useOldDownAngle': False, 'useParentAngle': True, 'rotate': (99.5, 137.5, 137.5, 137.5), 'rotateV': (0.0, 0.0, 0.0, 0.0), 'scale0': 1.0, 'scaleV0': 0.10000000149011612, 'attachment': '0', 'leaves': 100, 'leafStartLength':0.5, 'leafStartLevel':1, 'leafType': '0', 'leafDownAngle': 45.0, 'leafDownAngleV': 10.0, 'leafRotate': 137.5, 'leafRotateV': 0.0, 'leafObjZ': '+2', 'leafObjY': '+1', 'leafScale': 0.20000000298023224, 'leafScaleX': 0.5, 'leafScaleT': 0.20000000298023224, 'leafScaleV': 0.25, 'leafShape': 'hex', 'leafangle': -45.0, 'leafDist': '6', 'armAnim': False, 'previewArm': False, 'leafAnim': False, 'frameRate': 1.0, 'loopFrames': 0, 'wind': 1.0, 'gust': 1.0, 'gustF': 0.07500000298023224, 'af1': 1.0, 'af2': 1.0, 'af3': 4.0, 'makeMesh': False, 'armLevels': 0, 'boneStep': (1, 1, 1, 1), 'matIndex': (0, 0, 0, 0)}
18 changes: 17 additions & 1 deletion sapling_4/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,7 @@ def addTree(props):
scale0 = props.scale0#
scaleV0 = props.scaleV0#
attachment = props.attachment
leafBaseLevel = int(props.leafBaseLevel)
leafType = props.leafType
leafDownAngle = radians(props.leafDownAngle)
leafDownAngleV = radians(props.leafDownAngleV)
Expand Down Expand Up @@ -1711,6 +1712,7 @@ def addTree(props):
scaleVal += copysign(1e-6, scaleVal) # Move away from zero to avoid div by zero

childP = []
summary_leaf_child_points = []
stemList = []

levelCount = []
Expand Down Expand Up @@ -1757,6 +1759,20 @@ def addTree(props):
splitHeight, attractOut, rMode, splitStraight, splitLength, lengthV, taperCrown,
noTip, boneStep, rotate, rotateV, leaves, leafType, attachment, matIndex)

# generating anchor points for leaves. Separated from the generation of branch anchor points.
if leafBaseLevel <= n:
leaves_points = []
for stem in stemList:
stemLength = stem.offsetLen + (len(stem.spline.bezier_points) - 1) * stem.segL
leafs_amount = int(leaves * stemLength / 10.0 + 0.5)
if leafs_amount > 0:
range_points = [t / leafs_amount for t in range(leafs_amount) if (t / leafs_amount > leafBaseSize) or (leafBaseLevel < n)]

if len(range_points) > 0:
leaves_points.extend(interpStem(stem, range_points, stemLength, baseSize_s))

summary_leaf_child_points.extend(leaves_points)

levelCount.append(len(cu.splines))

# Set curve resolution
Expand All @@ -1774,7 +1790,7 @@ def addTree(props):
oldRot = 0.0
n = min(3, n+1)
# For each of the child points we add leaves
for ln, cp in enumerate(childP):
for ln, cp in enumerate(summary_leaf_child_points):
# If the special flag is set then we need to add several leaves at the same location
if leafType == '4':
oldRot = -leafRotate / 2
Expand Down