├── sapling_4 ├── __pycache__ │ ├── utils.cpython-37.pyc │ └── __init__.cpython-37.pyc ├── presets │ ├── Default Tree.py │ ├── Small Pine.py │ └── White Birch.py └── __init__.py ├── add_curve_sapling_3 ├── __pycache__ │ ├── utils.cpython-34.pyc │ └── __init__.cpython-34.pyc ├── presets │ ├── quaking_aspen.py │ ├── Japanese Maple.py │ ├── Douglas Fir.py │ ├── Small Maple.py │ ├── White Birch.py │ ├── Small Pine.py │ └── Default Tree.py └── __init__.py ├── README.md ├── add_curve_sapling_3_2_8 ├── presets │ ├── quaking_aspen.py │ ├── Japanese Maple.py │ ├── Douglas Fir.py │ ├── Small Maple.py │ ├── White Birch.py │ ├── Small Pine.py │ └── Default Tree.py └── __init__.py ├── pastChanges.md └── LICENSE /sapling_4/__pycache__/utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abpy/improved-sapling-tree-generator/HEAD/sapling_4/__pycache__/utils.cpython-37.pyc -------------------------------------------------------------------------------- /sapling_4/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abpy/improved-sapling-tree-generator/HEAD/sapling_4/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /add_curve_sapling_3/__pycache__/utils.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abpy/improved-sapling-tree-generator/HEAD/add_curve_sapling_3/__pycache__/utils.cpython-34.pyc -------------------------------------------------------------------------------- /add_curve_sapling_3/__pycache__/__init__.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abpy/improved-sapling-tree-generator/HEAD/add_curve_sapling_3/__pycache__/__init__.cpython-34.pyc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Improved Sapling Tree Generator 2 | A new version of Blenders sapling tree generator addon with improvements, new features, and bug fixes 3 | 4 | * For blender 2.7: `add_curve_sapling_3` 5 | * For blender 2.8: `add_curve_sapling_3_2_8` 6 | * Latest: `sapling_4` 7 | 8 | ### New Alternate Version "sapling_4" 9 | * includes many changes to improve usability and appearance of trees 10 | * breaks backwards compatibility with older presets 11 | * #### Change Log: 12 | * rearrange interface, remove, add, rename settings 13 | * add alternate / opposite attachment setting 14 | * smoother interpolation for custom shape 15 | * removed pruning 16 | * splits alternate direction 17 | * remove taper crown 18 | * improve split radius ratio 19 | * split angle is now actual angle and half as much as before 20 | * branch straightness affects all levels 21 | * positive curvature now curves branches up 22 | * curvature variation is consistent with resolution 23 | * length variation affects branches without splits 24 | * removed curve back 25 | * improve distance mode 26 | * change to radius calculation 27 | * change distribution function 28 | 29 | ##### For tips on using the tree generator see [tips](https://github.com/abpy/improved-sapling-tree-generator/wiki/Tips) in the wiki. 30 | 31 | The blender 2.7 version of this addon has been [added](https://developer.blender.org/rBAc3a6d9132a44afd254fa120157c66e72b751e6f1) to blender master as of version [f7cca89](https://github.com/abpy/improved-sapling-tree-generator/commit/720f312cb083c7a1b866f006b38fcf67521a6f39) with small changes. 32 | -------------------------------------------------------------------------------- /add_curve_sapling_3/presets/quaking_aspen.py: -------------------------------------------------------------------------------- 1 | {'scaleV0': 0.10000000149011612, 'autoTaper': True, 'branchDist': 1.0, 'leaves': 25, 'ratio': 0.014999999664723873, 'shape': '7', 'useArm': False, 'bevelRes': 0, 'rootFlare': 1.0, 'frameRate': 1.0, 'segSplits': (0.0, 0.0, 0.0, 0.0), 'handleType': '0', 'leafScaleT': 0.0, 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'armLevels': 2, 'attractOut': (0.0, 0.0, 0.0, 0.0), 'prunePowerHigh': 0.5, 'showLeaves': False, 'nrings': 0, 'leafScaleV': 0.0, 'baseSize': 0.4000000059604645, 'af2': 1.0, 'curve': (0.0, -40.0, -40.0, 0.0), 'resU': 4, 'prune': False, 'taperCrown': 0.0, 'minRadius': 0.001500000013038516, 'pruneRatio': 1.0, 'scale': 13.0, 'prunePowerLow': 0.0010000000474974513, 'leafDownAngle': 45.0, 'pruneWidthPeak': 0.6000000238418579, 'splitHeight': 0.20000000298023224, 'scale0': 1.0, 'splitAngle': (0.0, 0.0, 0.0, 0.0), 'leafShape': 'hex', 'splitBias': 0.0, 'pruneWidth': 0.4000000059604645, 'bevel': False, 'armAnim': False, 'attractUp': (0.0, 0.0, 0.5, 0.5), 'leafDownAngleV': 10.0, 'curveRes': (8, 5, 3, 1), 'curveV': (20.0, 50.0, 75.0, 0.0), 'horzLeaves': True, 'customShape': (0.5, 1.0, 0.30000001192092896, 0.5), 'af3': 4.0, 'taper': (1.0, 1.0, 1.0, 1.0), 'af1': 1.0, 'pruneBase': 0.30000001192092896, 'branches': (0, 50, 30, 10), 'loopFrames': 0, 'levels': 3, 'rotateV': (15.0, 0.0, 0.0, 0.0), 'leafScale': 0.17000000178813934, 'curveBack': (0.0, 0.0, 0.0, 0.0), 'splitAngleV': (0.0, 0.0, 0.0, 0.0), 'gust': 1.0, 'rotate': (99.5, 137.5, 137.5, 137.5), 'useOldDownAngle': False, 'useParentAngle': True, 'downAngle': (90.0, 110.0, 45.0, 45.0), 'downAngleV': (0.0, 80.0, 10.0, 10.0), 'baseSize_s': 0.25, 'leafType': '0', 'length': (1.0, 0.30000001192092896, 0.6000000238418579, 0.44999998807907104), 'boneStep': (1, 1, 1, 1), 'lengthV': (0.0, 0.0, 0.0, 0.0), 'wind': 1.0, 'previewArm': False, 'makeMesh': False, 'shapeS': '4', 'ratioPower': 1.100000023841858, 'leafAnim': False, 'scaleV': 3.0, 'baseSplits': 0, 'rMode': 'rotate', 'leafDist': '6', 'closeTip': False, 'leafRotateV': 10.0, 'leafScaleX': 1.0, 'splitByLen': True, 'gustF': 0.07500000298023224, 'leafRotate': 90.0, 'seed': 0, 'leafangle': 0.0} -------------------------------------------------------------------------------- /add_curve_sapling_3_2_8/presets/quaking_aspen.py: -------------------------------------------------------------------------------- 1 | {'scaleV0': 0.10000000149011612, 'autoTaper': True, 'branchDist': 1.0, 'leaves': 25, 'ratio': 0.014999999664723873, 'shape': '7', 'useArm': False, 'bevelRes': 0, 'rootFlare': 1.0, 'frameRate': 1.0, 'segSplits': (0.0, 0.0, 0.0, 0.0), 'handleType': '0', 'leafScaleT': 0.0, 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'armLevels': 2, 'attractOut': (0.0, 0.0, 0.0, 0.0), 'prunePowerHigh': 0.5, 'showLeaves': False, 'nrings': 0, 'leafScaleV': 0.0, 'baseSize': 0.4000000059604645, 'af2': 1.0, 'curve': (0.0, -40.0, -40.0, 0.0), 'resU': 4, 'prune': False, 'taperCrown': 0.0, 'minRadius': 0.001500000013038516, 'pruneRatio': 1.0, 'scale': 13.0, 'prunePowerLow': 0.0010000000474974513, 'leafDownAngle': 45.0, 'pruneWidthPeak': 0.6000000238418579, 'splitHeight': 0.20000000298023224, 'scale0': 1.0, 'splitAngle': (0.0, 0.0, 0.0, 0.0), 'leafShape': 'hex', 'splitBias': 0.0, 'pruneWidth': 0.4000000059604645, 'bevel': False, 'armAnim': False, 'attractUp': (0.0, 0.0, 0.5, 0.5), 'leafDownAngleV': 10.0, 'curveRes': (8, 5, 3, 1), 'curveV': (20.0, 50.0, 75.0, 0.0), 'horzLeaves': True, 'customShape': (0.5, 1.0, 0.30000001192092896, 0.5), 'af3': 4.0, 'taper': (1.0, 1.0, 1.0, 1.0), 'af1': 1.0, 'pruneBase': 0.30000001192092896, 'branches': (0, 50, 30, 10), 'loopFrames': 0, 'levels': 3, 'rotateV': (15.0, 0.0, 0.0, 0.0), 'leafScale': 0.17000000178813934, 'curveBack': (0.0, 0.0, 0.0, 0.0), 'splitAngleV': (0.0, 0.0, 0.0, 0.0), 'gust': 1.0, 'rotate': (99.5, 137.5, 137.5, 137.5), 'useOldDownAngle': False, 'useParentAngle': True, 'downAngle': (90.0, 110.0, 45.0, 45.0), 'downAngleV': (0.0, 80.0, 10.0, 10.0), 'baseSize_s': 0.25, 'leafType': '0', 'length': (1.0, 0.30000001192092896, 0.6000000238418579, 0.44999998807907104), 'boneStep': (1, 1, 1, 1), 'lengthV': (0.0, 0.0, 0.0, 0.0), 'wind': 1.0, 'previewArm': False, 'makeMesh': False, 'shapeS': '4', 'ratioPower': 1.100000023841858, 'leafAnim': False, 'scaleV': 3.0, 'baseSplits': 0, 'rMode': 'rotate', 'leafDist': '6', 'closeTip': False, 'leafRotateV': 10.0, 'leafScaleX': 1.0, 'splitByLen': True, 'gustF': 0.07500000298023224, 'leafRotate': 90.0, 'seed': 0, 'leafangle': 0.0} -------------------------------------------------------------------------------- /sapling_4/presets/Default Tree.py: -------------------------------------------------------------------------------- 1 | {'bevel': False, 'showLeaves': False, 'useArm': False, 'seed': 0, 'handleType': '0', 'bevelRes': 2, 'resU': 4, 'levels': 3, 'length': (1.0, 0.3499999940395355, 0.5, 0.44999998807907104), 'lengthV': (0.05000000074505806, 0.10000000149011612, 0.15000000596046448, 0.25), 'taperCrown': 0.0, 'branches': (0, 60, 1, 10), 'curveRes': (8, 5, 3, 1), 'curve': (0.0, 20.0, 20.0, 0.0), 'curveV': (5.0, 10.0, 15.0, 20.0), 'curveBack': (0.0, 0.0, 0.0, 0.0), 'baseSplits': 0, 'segSplits': (0.0, 0.0, 0.0, 0.0), 'splitByLen': True, 'rMode': 'rotate', 'splitStraight': 0.30000001192092896, 'splitLength': 0.029999999329447746, 'splitAngle': (16.0, 45.0, 45.0, 60.0), 'splitAngleV': (2.0, 5.0, 5.0, 5.0), 'scale': 13.0, 'scaleV': 2.0, 'attractUp': (0.25, 0.25, 0.25, 0.25), 'attractOut': (0.0, 0.0, 0.0, 0.0), 'shape': '7', 'shapeS': '4', 'customShape': (0.5, 1.0, 0.30000001192092896, 0.5), 'branchDist': 1.350000023841858, 'nrings': 0, 'baseSize': 0.33000001311302185, 'baseSize_s': 0.25, 'leafBaseSize': 0.20000000298023224, 'splitHeight': 0.25, '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, 75.0, 10.0, 10.0), 'useOldDownAngle': False, 'useParentAngle': True, 'rotate': (99.5, 137.5, 137.5, 137.5), 'rotateV': (15.0, 5.0, 5.0, 5.0), 'scale0': 1.0, 'scaleV0': 0.05000000074505806, 'attachment': '0', 'leaves': 25, 'leafType': '0', 'leafDownAngle': 60.0, 'leafDownAngleV': 30.0, 'leafRotate': 90.0, 'leafRotateV': 10.0, 'leafObjZ': '+2', 'leafObjY': '+1', 'leafScale': 0.17000000178813934, 'leafScaleX': 1.0, 'leafScaleT': -0.25, 'leafScaleV': 0.25, 'leafShape': 'hex', 'leafangle': -30.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': 2, 'boneStep': (1, 1, 1, 1), 'matIndex': (0, 0, 0, 0)} -------------------------------------------------------------------------------- /sapling_4/presets/Small Pine.py: -------------------------------------------------------------------------------- 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)} -------------------------------------------------------------------------------- /add_curve_sapling_3/presets/Japanese Maple.py: -------------------------------------------------------------------------------- 1 | {'leafScaleT': -0.5, 'shapeS': '10', 'scaleV': 2.0, 'resU': 4, 'boneStep': (1, 1, 1, 1), 'af3': 4.0, 'baseSize': 0.4000000059604645, 'prunePowerLow': 0.0010000000474974513, 'leafRotateV': 0.0, 'rootFlare': 1.0, 'customShape': (0.699999988079071, 1.0, 0.20000000298023224, 0.800000011920929), 'attractOut': (0.0, 0.75, 0.25, 0.0), 'useArm': False, 'branches': (0, 50, 10, 16), 'leafDownAngle': 45.0, 'length': (1.0, 0.30000001192092896, 0.5, 0.20000000298023224), 'segSplits': (0.25, 0.4000000059604645, 0.5, 0.0), 'makeMesh': False, 'curveV': (400.0, 150.0, 100.0, 0.0), 'curveBack': (0.0, 0.0, 0.0, 0.0), 'af1': 1.0, 'closeTip': False, 'frameRate': 1.0, 'leafangle': -10.0, 'af2': 1.0, 'rMode': 'rotate', 'leafScaleV': 0.0, 'rotateV': (15.0, 0.0, 0.0, 0.0), 'useParentAngle': False, 'taperCrown': 0.0, 'minRadius': 0.001500000013038516, 'splitAngleV': (5.0, 5.0, 0.0, 0.0), 'scaleV0': 0.10000000149011612, 'bevel': True, 'leafDownAngleV': 10.0, 'previewArm': False, 'showLeaves': True, 'ratioPower': 1.25, 'handleType': '0', 'branchDist': 1.0, 'leafScaleX': 0.20000000298023224, 'prune': False, 'splitHeight': 0.30000001192092896, 'baseSplits': 2, 'baseSize_s': 0.25, 'downAngle': (90.0, 90.0, 30.0, 30.0), 'bevelRes': 1, 'leafAnim': False, 'loopFrames': 0, 'lengthV': (0.0, 0.0, 0.0, 0.0), 'gust': 1.0, 'downAngleV': (0.0, 90.0, 15.0, 10.0), 'leafRotate': 137.5, 'wind': 1.0, 'leaves': -5, 'curve': (0.0, -20.0, -20.0, 0.0), 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'pruneRatio': 1.0, 'pruneBase': 0.30000001192092896, 'armAnim': False, 'splitBias': 0.0, 'rotate': (99.5, 137.5, 137.5, 137.5), 'armLevels': 2, 'scale': 6.0, 'prunePowerHigh': 0.5, 'nrings': 0, 'splitByLen': True, 'leafShape': 'hex', 'splitAngle': (15.0, 20.0, 25.0, 0.0), 'ratio': 0.019999999552965164, 'scale0': 1.0, 'autoTaper': True, 'pruneWidth': 0.4000000059604645, 'leafScale': 0.17000000178813934, 'seed': 0, 'curveRes': (16, 5, 3, 1), 'horzLeaves': True, 'useOldDownAngle': False, 'levels': 4, 'pruneWidthPeak': 0.6000000238418579, 'attractUp': (0.0, -0.3499999940395355, -0.20000000298023224, 0.0), 'taper': (1.0, 1.0, 1.0, 1.0), 'leafDist': '6', 'gustF': 0.07500000298023224, 'shape': '8'} -------------------------------------------------------------------------------- /add_curve_sapling_3_2_8/presets/Japanese Maple.py: -------------------------------------------------------------------------------- 1 | {'leafScaleT': -0.5, 'shapeS': '10', 'scaleV': 2.0, 'resU': 4, 'boneStep': (1, 1, 1, 1), 'af3': 4.0, 'baseSize': 0.4000000059604645, 'prunePowerLow': 0.0010000000474974513, 'leafRotateV': 0.0, 'rootFlare': 1.0, 'customShape': (0.699999988079071, 1.0, 0.20000000298023224, 0.800000011920929), 'attractOut': (0.0, 0.75, 0.25, 0.0), 'useArm': False, 'branches': (0, 50, 10, 16), 'leafDownAngle': 45.0, 'length': (1.0, 0.30000001192092896, 0.5, 0.20000000298023224), 'segSplits': (0.25, 0.4000000059604645, 0.5, 0.0), 'makeMesh': False, 'curveV': (400.0, 150.0, 100.0, 0.0), 'curveBack': (0.0, 0.0, 0.0, 0.0), 'af1': 1.0, 'closeTip': False, 'frameRate': 1.0, 'leafangle': -10.0, 'af2': 1.0, 'rMode': 'rotate', 'leafScaleV': 0.0, 'rotateV': (15.0, 0.0, 0.0, 0.0), 'useParentAngle': False, 'taperCrown': 0.0, 'minRadius': 0.001500000013038516, 'splitAngleV': (5.0, 5.0, 0.0, 0.0), 'scaleV0': 0.10000000149011612, 'bevel': True, 'leafDownAngleV': 10.0, 'previewArm': False, 'showLeaves': True, 'ratioPower': 1.25, 'handleType': '0', 'branchDist': 1.0, 'leafScaleX': 0.20000000298023224, 'prune': False, 'splitHeight': 0.30000001192092896, 'baseSplits': 2, 'baseSize_s': 0.25, 'downAngle': (90.0, 90.0, 30.0, 30.0), 'bevelRes': 1, 'leafAnim': False, 'loopFrames': 0, 'lengthV': (0.0, 0.0, 0.0, 0.0), 'gust': 1.0, 'downAngleV': (0.0, 90.0, 15.0, 10.0), 'leafRotate': 137.5, 'wind': 1.0, 'leaves': -5, 'curve': (0.0, -20.0, -20.0, 0.0), 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'pruneRatio': 1.0, 'pruneBase': 0.30000001192092896, 'armAnim': False, 'splitBias': 0.0, 'rotate': (99.5, 137.5, 137.5, 137.5), 'armLevels': 2, 'scale': 6.0, 'prunePowerHigh': 0.5, 'nrings': 0, 'splitByLen': True, 'leafShape': 'hex', 'splitAngle': (15.0, 20.0, 25.0, 0.0), 'ratio': 0.019999999552965164, 'scale0': 1.0, 'autoTaper': True, 'pruneWidth': 0.4000000059604645, 'leafScale': 0.17000000178813934, 'seed': 0, 'curveRes': (16, 5, 3, 1), 'horzLeaves': True, 'useOldDownAngle': False, 'levels': 4, 'pruneWidthPeak': 0.6000000238418579, 'attractUp': (0.0, -0.3499999940395355, -0.20000000298023224, 0.0), 'taper': (1.0, 1.0, 1.0, 1.0), 'leafDist': '6', 'gustF': 0.07500000298023224, 'shape': '8'} -------------------------------------------------------------------------------- /add_curve_sapling_3/presets/Douglas Fir.py: -------------------------------------------------------------------------------- 1 | {'pruneRatio': 1.0, 'wind': 1.0, 'prune': False, 'splitByLen': True, 'attractUp': (0.0, 0.3499999940395355, 0.25, 0.15000000596046448), 'segSplits': (0.0, 0.3499999940395355, 0.6000000238418579, 0.0), 'rMode': 'rotate', 'rotate': (99.5, 137.5, -45.0, -60.0), 'curve': (0.0, 20.0, -10.0, 0.0), 'af2': 1.0, 'seed': 0, 'length': (1.0, 0.20000000298023224, 0.550000011920929, 0.44999998807907104), 'attractOut': (0.0, 0.0, 0.0, 0.0), 'leafScaleT': 0.0, 'scaleV': 15.0, 'splitHeight': 0.20000000298023224, 'minRadius': 0.0020000000949949026, 'leafRotate': 137.5, 'curveRes': (12, 4, 3, 2), 'curveV': (40.0, 30.0, 15.0, 10.0), 'nrings': 0, 'levels': 4, 'frameRate': 1.0, 'ratioPower': 1.2000000476837158, 'leafDownAngle': 45.0, 'armLevels': 2, 'branches': (0, 75, 16, 10), 'splitAngleV': (0.0, 0.0, 0.0, 0.0), 'shape': '8', 'rotateV': (15.0, 0.0, 15.0, 45.0), 'loopFrames': 0, 'curveBack': (0.0, 0.0, 0.0, 0.0), 'taperCrown': 0.0, 'prunePowerLow': 0.0010000000474974513, 'handleType': '0', 'af3': 4.0, 'useParentAngle': True, 'customShape': (0.5, 1.0, 0.3499999940395355, 0.10000000149011612), 'scale0': 1.0, 'rootFlare': 1.2999999523162842, 'leafScaleV': 0.0, 'leafScale': 0.17000000178813934, 'leafangle': 0.0, 'scaleV0': 0.10000000149011612, 'downAngleV': (0.0, 30.0, 10.0, 10.0), 'af1': 1.0, 'autoTaper': True, 'scale': 35.0, 'gustF': 0.07500000298023224, 'ratio': 0.014999999664723873, 'leafScaleX': 1.0, 'shapeS': '7', 'bevelRes': 1, 'bevel': True, 'leaves': 25, 'splitAngle': (0.0, 12.0, 18.0, 0.0), 'downAngle': (90.0, 130.0, 45.0, 45.0), 'previewArm': False, 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'showLeaves': False, 'leafAnim': False, 'baseSize': 0.33000001311302185, 'gust': 1.0, 'horzLeaves': True, 'baseSize_s': 0.5, 'leafDownAngleV': 10.0, 'makeMesh': False, 'leafDist': '6', 'armAnim': False, 'baseSplits': 0, 'lengthV': (0.0, 0.10000000149011612, 0.25, 0.25), 'branchDist': 1.850000023841858, 'useArm': False, 'useOldDownAngle': False, 'taper': (1.0, 1.0, 1.0, 1.0), 'pruneBase': 0.30000001192092896, 'splitBias': 0.0, 'boneStep': (1, 1, 1, 1), 'leafShape': 'hex', 'resU': 4, 'prunePowerHigh': 0.5, 'closeTip': True, 'pruneWidth': 0.4000000059604645, 'leafRotateV': 0.0, 'pruneWidthPeak': 0.6000000238418579} -------------------------------------------------------------------------------- /add_curve_sapling_3_2_8/presets/Douglas Fir.py: -------------------------------------------------------------------------------- 1 | {'pruneRatio': 1.0, 'wind': 1.0, 'prune': False, 'splitByLen': True, 'attractUp': (0.0, 0.3499999940395355, 0.25, 0.15000000596046448), 'segSplits': (0.0, 0.3499999940395355, 0.6000000238418579, 0.0), 'rMode': 'rotate', 'rotate': (99.5, 137.5, -45.0, -60.0), 'curve': (0.0, 20.0, -10.0, 0.0), 'af2': 1.0, 'seed': 0, 'length': (1.0, 0.20000000298023224, 0.550000011920929, 0.44999998807907104), 'attractOut': (0.0, 0.0, 0.0, 0.0), 'leafScaleT': 0.0, 'scaleV': 15.0, 'splitHeight': 0.20000000298023224, 'minRadius': 0.0020000000949949026, 'leafRotate': 137.5, 'curveRes': (12, 4, 3, 2), 'curveV': (40.0, 30.0, 15.0, 10.0), 'nrings': 0, 'levels': 4, 'frameRate': 1.0, 'ratioPower': 1.2000000476837158, 'leafDownAngle': 45.0, 'armLevels': 2, 'branches': (0, 75, 16, 10), 'splitAngleV': (0.0, 0.0, 0.0, 0.0), 'shape': '8', 'rotateV': (15.0, 0.0, 15.0, 45.0), 'loopFrames': 0, 'curveBack': (0.0, 0.0, 0.0, 0.0), 'taperCrown': 0.0, 'prunePowerLow': 0.0010000000474974513, 'handleType': '0', 'af3': 4.0, 'useParentAngle': True, 'customShape': (0.5, 1.0, 0.3499999940395355, 0.10000000149011612), 'scale0': 1.0, 'rootFlare': 1.2999999523162842, 'leafScaleV': 0.0, 'leafScale': 0.17000000178813934, 'leafangle': 0.0, 'scaleV0': 0.10000000149011612, 'downAngleV': (0.0, 30.0, 10.0, 10.0), 'af1': 1.0, 'autoTaper': True, 'scale': 35.0, 'gustF': 0.07500000298023224, 'ratio': 0.014999999664723873, 'leafScaleX': 1.0, 'shapeS': '7', 'bevelRes': 1, 'bevel': True, 'leaves': 25, 'splitAngle': (0.0, 12.0, 18.0, 0.0), 'downAngle': (90.0, 130.0, 45.0, 45.0), 'previewArm': False, 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'showLeaves': False, 'leafAnim': False, 'baseSize': 0.33000001311302185, 'gust': 1.0, 'horzLeaves': True, 'baseSize_s': 0.5, 'leafDownAngleV': 10.0, 'makeMesh': False, 'leafDist': '6', 'armAnim': False, 'baseSplits': 0, 'lengthV': (0.0, 0.10000000149011612, 0.25, 0.25), 'branchDist': 1.850000023841858, 'useArm': False, 'useOldDownAngle': False, 'taper': (1.0, 1.0, 1.0, 1.0), 'pruneBase': 0.30000001192092896, 'splitBias': 0.0, 'boneStep': (1, 1, 1, 1), 'leafShape': 'hex', 'resU': 4, 'prunePowerHigh': 0.5, 'closeTip': True, 'pruneWidth': 0.4000000059604645, 'leafRotateV': 0.0, 'pruneWidthPeak': 0.6000000238418579} -------------------------------------------------------------------------------- /sapling_4/presets/White Birch.py: -------------------------------------------------------------------------------- 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)} -------------------------------------------------------------------------------- /add_curve_sapling_3/presets/Small Maple.py: -------------------------------------------------------------------------------- 1 | {'leafDownAngle': 45.0, 'handleType': '0', 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'useArm': False, 'rootFlare': 1.0, 'segSplits': (0.44999998807907104, 0.5, 0.800000011920929, 0.0), 'leafRotateV': 0.0, 'leaves': 32, 'baseSplits': 1, 'rotate': (99.5, 137.5, 137.5, 137.5), 'scale': 8.0, 'makeMesh': False, 'leafDownAngleV': 10.0, 'curve': (0.0, 30.0, 0.0, 0.0), 'splitBias': 0.0, 'leafScale': 0.18000000715255737, 'levels': 3, 'leafScaleT': 0.3499999940395355, 'seed': 0, 'autoTaper': True, 'pruneWidthPeak': 0.6000000238418579, 'branchDist': 1.25, 'prune': False, 'splitAngle': (8.0, 18.0, 18.0, 0.0), 'shapeS': '7', 'useParentAngle': True, 'af1': 1.0, 'armAnim': False, 'resU': 4, 'ratioPower': 1.2000000476837158, 'scaleV': 2.0, 'splitHeight': 0.20000000298023224, 'leafRotate': 137.5, 'customShape': (0.5, 1.0, 0.30000001192092896, 0.5), 'shape': '7', 'ratio': 0.019999999552965164, 'rMode': 'rotate', 'downAngle': (90.0, 48.0, 45.0, 45.0), 'bevelRes': 2, 'showLeaves': True, 'wind': 1.0, 'loopFrames': 0, 'splitByLen': True, 'lengthV': (0.0, 0.029999999329447746, 0.15000000596046448, 0.0), 'leafShape': 'hex', 'downAngleV': (0.0, 48.0, 10.0, 10.0), 'leafangle': -35.0, 'bevel': True, 'gustF': 0.07500000298023224, 'taper': (1.0, 1.0, 1.0, 1.0), 'previewArm': False, 'frameRate': 1.0, 'curveBack': (0.0, -30.0, -20.0, 0.0), 'taperCrown': 0.20000000298023224, 'rotateV': (15.0, 0.0, 0.0, 0.0), 'scaleV0': 0.20000000298023224, 'gust': 1.0, 'horzLeaves': True, 'attractUp': (-0.5, -0.699999988079071, 0.0, 0.0), 'splitAngleV': (2.0, 5.0, 5.0, 0.0), 'pruneRatio': 1.0, 'curveV': (10.0, 35.0, 35.0, 0.0), 'prunePowerHigh': 0.5, 'closeTip': False, 'leafScaleV': 0.20000000298023224, 'leafAnim': False, 'minRadius': 0.0020000000949949026, 'af3': 4.0, 'attractOut': (0.0, 0.4000000059604645, 0.5, 0.0), 'branches': (0, 110, 18, 10), 'leafScaleX': 0.6499999761581421, 'length': (1.0, 0.46000000834465027, 0.44999998807907104, 0.44999998807907104), 'useOldDownAngle': False, 'armLevels': 2, 'boneStep': (1, 1, 1, 1), 'pruneBase': 0.30000001192092896, 'curveRes': (8, 5, 3, 1), 'prunePowerLow': 0.0010000000474974513, 'af2': 1.0, 'pruneWidth': 0.4000000059604645, 'nrings': 0, 'baseSize_s': 0.25, 'baseSize': 0.2800000011920929, 'leafDist': '6', 'scale0': 1.0} -------------------------------------------------------------------------------- /add_curve_sapling_3_2_8/presets/Small Maple.py: -------------------------------------------------------------------------------- 1 | {'leafDownAngle': 45.0, 'handleType': '0', 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'useArm': False, 'rootFlare': 1.0, 'segSplits': (0.44999998807907104, 0.5, 0.800000011920929, 0.0), 'leafRotateV': 0.0, 'leaves': 32, 'baseSplits': 1, 'rotate': (99.5, 137.5, 137.5, 137.5), 'scale': 8.0, 'makeMesh': False, 'leafDownAngleV': 10.0, 'curve': (0.0, 30.0, 0.0, 0.0), 'splitBias': 0.0, 'leafScale': 0.18000000715255737, 'levels': 3, 'leafScaleT': 0.3499999940395355, 'seed': 0, 'autoTaper': True, 'pruneWidthPeak': 0.6000000238418579, 'branchDist': 1.25, 'prune': False, 'splitAngle': (8.0, 18.0, 18.0, 0.0), 'shapeS': '7', 'useParentAngle': True, 'af1': 1.0, 'armAnim': False, 'resU': 4, 'ratioPower': 1.2000000476837158, 'scaleV': 2.0, 'splitHeight': 0.20000000298023224, 'leafRotate': 137.5, 'customShape': (0.5, 1.0, 0.30000001192092896, 0.5), 'shape': '7', 'ratio': 0.019999999552965164, 'rMode': 'rotate', 'downAngle': (90.0, 48.0, 45.0, 45.0), 'bevelRes': 2, 'showLeaves': True, 'wind': 1.0, 'loopFrames': 0, 'splitByLen': True, 'lengthV': (0.0, 0.029999999329447746, 0.15000000596046448, 0.0), 'leafShape': 'hex', 'downAngleV': (0.0, 48.0, 10.0, 10.0), 'leafangle': -35.0, 'bevel': True, 'gustF': 0.07500000298023224, 'taper': (1.0, 1.0, 1.0, 1.0), 'previewArm': False, 'frameRate': 1.0, 'curveBack': (0.0, -30.0, -20.0, 0.0), 'taperCrown': 0.20000000298023224, 'rotateV': (15.0, 0.0, 0.0, 0.0), 'scaleV0': 0.20000000298023224, 'gust': 1.0, 'horzLeaves': True, 'attractUp': (-0.5, -0.699999988079071, 0.0, 0.0), 'splitAngleV': (2.0, 5.0, 5.0, 0.0), 'pruneRatio': 1.0, 'curveV': (10.0, 35.0, 35.0, 0.0), 'prunePowerHigh': 0.5, 'closeTip': False, 'leafScaleV': 0.20000000298023224, 'leafAnim': False, 'minRadius': 0.0020000000949949026, 'af3': 4.0, 'attractOut': (0.0, 0.4000000059604645, 0.5, 0.0), 'branches': (0, 110, 18, 10), 'leafScaleX': 0.6499999761581421, 'length': (1.0, 0.46000000834465027, 0.44999998807907104, 0.44999998807907104), 'useOldDownAngle': False, 'armLevels': 2, 'boneStep': (1, 1, 1, 1), 'pruneBase': 0.30000001192092896, 'curveRes': (8, 5, 3, 1), 'prunePowerLow': 0.0010000000474974513, 'af2': 1.0, 'pruneWidth': 0.4000000059604645, 'nrings': 0, 'baseSize_s': 0.25, 'baseSize': 0.2800000011920929, 'leafDist': '6', 'scale0': 1.0} -------------------------------------------------------------------------------- /add_curve_sapling_3/presets/White Birch.py: -------------------------------------------------------------------------------- 1 | {'seed': 0, 'showLeaves': True, 'armLevels': 0, 'leafDist': '6', 'baseSize': 0.3499999940395355, 'loopFrames': 0, 'af3': 4.0, 'previewArm': False, 'leafangle': -45.0, 'useParentAngle': True, 'handleType': '0', 'branches': (0, 60, 30, 10), 'autoTaper': True, 'splitAngle': (12.0, 18.0, 16.0, 0.0), 'baseSize_s': 0.800000011920929, 'closeTip': False, 'af2': 1.0, 'prune': False, 'scale0': 1.0, 'rMode': 'rotate', 'useOldDownAngle': False, 'scaleV0': 0.10000000149011612, 'splitBias': 0.0, 'resU': 2, 'curveBack': (0.0, -5.0, 0.0, 0.0), 'scale': 12.0, 'shape': '8', 'leafDownAngle': 45.0, 'af1': 1.0, 'ratio': 0.019999999552965164, 'horzLeaves': True, 'leafRotate': 137.5, 'minRadius': 0.0020000000949949026, 'bevelRes': 2, 'splitByLen': True, 'rootFlare': 1.149999976158142, 'makeMesh': False, 'downAngleV': (0.0, 25.0, 30.0, 10.0), 'levels': 3, 'scaleV': 2.0, 'armAnim': False, 'lengthV': (0.05000000074505806, 0.20000000298023224, 0.3499999940395355, 0.0), 'pruneWidth': 0.3100000023841858, 'gustF': 0.07500000298023224, 'taper': (1.0, 1.0, 1.0, 1.0), 'splitAngleV': (2.0, 2.0, 0.0, 0.0), 'prunePowerLow': 0.0010000000474974513, 'leafScaleT': 0.20000000298023224, 'leafScaleX': 0.5, 'leafRotateV': 0.0, 'ratioPower': 1.399999976158142, 'segSplits': (0.3499999940395355, 0.3499999940395355, 0.3499999940395355, 0.0), 'downAngle': (90.0, 60.0, 50.0, 45.0), 'rotateV': (0.0, 0.0, 0.0, 0.0), 'gust': 1.0, 'attractUp': (0.0, -1.0, -0.6499999761581421, 0.0), 'leafScaleV': 0.25, 'frameRate': 1.0, 'curveV': (100.0, 80.0, 80.0, 0.0), 'boneStep': (1, 1, 1, 1), 'customShape': (0.699999988079071, 1.0, 0.30000001192092896, 0.5900000333786011), 'pruneBase': 0.30000001192092896, 'leafAnim': False, 'curveRes': (10, 8, 3, 1), 'nrings': 0, 'bevel': True, 'taperCrown': 0.0, 'baseSplits': 2, 'leafShape': 'hex', 'splitHeight': 0.550000011920929, 'wind': 1.0, 'curve': (0.0, -30.0, -25.0, 0.0), 'rotate': (137.5, 137.5, 137.5, 137.5), 'length': (1.0, 0.33000001311302185, 0.375, 0.44999998807907104), 'leafScale': 0.20000000298023224, 'attractOut': (0.0, 0.20000000298023224, 0.25, 0.0), 'prunePowerHigh': 0.10000000149011612, 'branchDist': 1.5, 'useArm': False, 'pruneRatio': 1.0, 'shapeS': '7', 'leafDownAngleV': 10.0, 'pruneWidthPeak': 0.5, 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'leaves': 16} -------------------------------------------------------------------------------- /add_curve_sapling_3_2_8/presets/White Birch.py: -------------------------------------------------------------------------------- 1 | {'seed': 0, 'showLeaves': True, 'armLevels': 0, 'leafDist': '6', 'baseSize': 0.3499999940395355, 'loopFrames': 0, 'af3': 4.0, 'previewArm': False, 'leafangle': -45.0, 'useParentAngle': True, 'handleType': '0', 'branches': (0, 60, 30, 10), 'autoTaper': True, 'splitAngle': (12.0, 18.0, 16.0, 0.0), 'baseSize_s': 0.800000011920929, 'closeTip': False, 'af2': 1.0, 'prune': False, 'scale0': 1.0, 'rMode': 'rotate', 'useOldDownAngle': False, 'scaleV0': 0.10000000149011612, 'splitBias': 0.0, 'resU': 2, 'curveBack': (0.0, -5.0, 0.0, 0.0), 'scale': 12.0, 'shape': '8', 'leafDownAngle': 45.0, 'af1': 1.0, 'ratio': 0.019999999552965164, 'horzLeaves': True, 'leafRotate': 137.5, 'minRadius': 0.0020000000949949026, 'bevelRes': 2, 'splitByLen': True, 'rootFlare': 1.149999976158142, 'makeMesh': False, 'downAngleV': (0.0, 25.0, 30.0, 10.0), 'levels': 3, 'scaleV': 2.0, 'armAnim': False, 'lengthV': (0.05000000074505806, 0.20000000298023224, 0.3499999940395355, 0.0), 'pruneWidth': 0.3100000023841858, 'gustF': 0.07500000298023224, 'taper': (1.0, 1.0, 1.0, 1.0), 'splitAngleV': (2.0, 2.0, 0.0, 0.0), 'prunePowerLow': 0.0010000000474974513, 'leafScaleT': 0.20000000298023224, 'leafScaleX': 0.5, 'leafRotateV': 0.0, 'ratioPower': 1.399999976158142, 'segSplits': (0.3499999940395355, 0.3499999940395355, 0.3499999940395355, 0.0), 'downAngle': (90.0, 60.0, 50.0, 45.0), 'rotateV': (0.0, 0.0, 0.0, 0.0), 'gust': 1.0, 'attractUp': (0.0, -1.0, -0.6499999761581421, 0.0), 'leafScaleV': 0.25, 'frameRate': 1.0, 'curveV': (100.0, 80.0, 80.0, 0.0), 'boneStep': (1, 1, 1, 1), 'customShape': (0.699999988079071, 1.0, 0.30000001192092896, 0.5900000333786011), 'pruneBase': 0.30000001192092896, 'leafAnim': False, 'curveRes': (10, 8, 3, 1), 'nrings': 0, 'bevel': True, 'taperCrown': 0.0, 'baseSplits': 2, 'leafShape': 'hex', 'splitHeight': 0.550000011920929, 'wind': 1.0, 'curve': (0.0, -30.0, -25.0, 0.0), 'rotate': (137.5, 137.5, 137.5, 137.5), 'length': (1.0, 0.33000001311302185, 0.375, 0.44999998807907104), 'leafScale': 0.20000000298023224, 'attractOut': (0.0, 0.20000000298023224, 0.25, 0.0), 'prunePowerHigh': 0.10000000149011612, 'branchDist': 1.5, 'useArm': False, 'pruneRatio': 1.0, 'shapeS': '7', 'leafDownAngleV': 10.0, 'pruneWidthPeak': 0.5, 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'leaves': 16} -------------------------------------------------------------------------------- /add_curve_sapling_3/presets/Small Pine.py: -------------------------------------------------------------------------------- 1 | {'scale0': 1.0, 'curve': (0.0, -40.0, -30.0, 0.0), 'gustF': 0.07500000298023224, 'scale': 4.0, 'bevelRes': 2, 'prunePowerLow': 0.0010000000474974513, 'makeMesh': False, 'resU': 4, 'curveV': (100.0, 100.0, 100.0, 0.0), 'leafRotate': 137.5, 'scaleV': 1.0, 'pruneBase': 0.30000001192092896, 'boneStep': (1, 1, 1, 1), 'armAnim': False, 'attractOut': (0.0, 0.0, 0.0, 0.0), 'leaves': 500, 'leafScale': 0.20000000298023224, 'splitByLen': True, 'ratioPower': 1.0, 'af2': 1.0, 'scaleV0': 0.10000000149011612, 'length': (1.0, 0.3199999928474426, 0.75, 0.44999998807907104), 'nrings': 7, 'levels': 3, 'wind': 1.0, 'af3': 4.0, 'leafType': '5', 'splitBias': 0.0, 'bevel': True, 'downAngle': (90.0, 110.0, 45.0, 45.0), 'noTip': False, 'branchDist': 1.600000023841858, 'shapeS': '4', 'baseSplits': 0, 'lengthV': (0.0, 0.15000000596046448, 0.25, 0.0), 'attractUp': (2.0, 0.0, 0.5, 0.5), 'loopFrames': 0, 'useArm': False, 'frameRate': 1.0, 'leafScaleX': 0.019999999552965164, 'previewArm': False, 'pruneWidthPeak': 0.6000000238418579, 'seed': 0, 'useOldDownAngle': False, 'leafObjY': '+1', 'curveRes': (8, 5, 3, 1), 'armLevels': 2, 'baseSize_s': 0.25, 'downAngleV': (0.0, 42.0, 10.0, 10.0), 'branches': (0, 36, 7, 10), 'segSplits': (0.0, 0.30000001192092896, 0.4000000059604645, 0.0), 'pruneWidth': 0.4000000059604645, 'gust': 1.0, 'rootFlare': 1.0, 'rotateV': (15.0, 0.0, 0.0, 0.0), 'pruneRatio': 1.0, 'minRadius': 0.001500000013038516, 'splitHeight': 0.20000000298023224, 'prune': False, 'leafShape': 'rect', 'leafBaseSize': 0.20000000298023224, 'leafObjZ': '+2', 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'leafScaleT': 0.25, 'splitAngleV': (0.0, 5.0, 0.0, 0.0), 'leafDownAngle': 65.0, 'autoTaper': True, 'leafDist': '3', 'af1': 1.0, 'shape': '8', 'baseSize': 0.06799984723329544, 'prunePowerHigh': 0.5, 'showLeaves': True, 'leafangle': -10.0, 'curveBack': (0.0, 0.0, 0.0, 0.0), 'rotate': (99.5, 137.5, -90.0, 137.5), 'useParentAngle': True, 'closeTip': False, 'rMode': 'rotate', 'leafDownAngleV': 55.0, 'horzLeaves': False, 'leafRotateV': 30.0, 'splitAngle': (0.0, 22.0, 25.0, 0.0), 'taperCrown': 0.0, 'customShape': (0.8999999761581421, 1.0, 0.20000000298023224, 0.20000000298023224), 'leafAnim': False, 'taper': (1.0, 1.0, 1.0, 1.0), 'leafScaleV': 0.10000000149011612, 'ratio': 0.019999999552965164, 'handleType': '0'} -------------------------------------------------------------------------------- /add_curve_sapling_3_2_8/presets/Small Pine.py: -------------------------------------------------------------------------------- 1 | {'scale0': 1.0, 'curve': (0.0, -40.0, -30.0, 0.0), 'gustF': 0.07500000298023224, 'scale': 4.0, 'bevelRes': 2, 'prunePowerLow': 0.0010000000474974513, 'makeMesh': False, 'resU': 4, 'curveV': (100.0, 100.0, 100.0, 0.0), 'leafRotate': 137.5, 'scaleV': 1.0, 'pruneBase': 0.30000001192092896, 'boneStep': (1, 1, 1, 1), 'armAnim': False, 'attractOut': (0.0, 0.0, 0.0, 0.0), 'leaves': 500, 'leafScale': 0.20000000298023224, 'splitByLen': True, 'ratioPower': 1.0, 'af2': 1.0, 'scaleV0': 0.10000000149011612, 'length': (1.0, 0.3199999928474426, 0.75, 0.44999998807907104), 'nrings': 7, 'levels': 3, 'wind': 1.0, 'af3': 4.0, 'leafType': '5', 'splitBias': 0.0, 'bevel': True, 'downAngle': (90.0, 110.0, 45.0, 45.0), 'noTip': False, 'branchDist': 1.600000023841858, 'shapeS': '4', 'baseSplits': 0, 'lengthV': (0.0, 0.15000000596046448, 0.25, 0.0), 'attractUp': (2.0, 0.0, 0.5, 0.5), 'loopFrames': 0, 'useArm': False, 'frameRate': 1.0, 'leafScaleX': 0.019999999552965164, 'previewArm': False, 'pruneWidthPeak': 0.6000000238418579, 'seed': 0, 'useOldDownAngle': False, 'leafObjY': '+1', 'curveRes': (8, 5, 3, 1), 'armLevels': 2, 'baseSize_s': 0.25, 'downAngleV': (0.0, 42.0, 10.0, 10.0), 'branches': (0, 36, 7, 10), 'segSplits': (0.0, 0.30000001192092896, 0.4000000059604645, 0.0), 'pruneWidth': 0.4000000059604645, 'gust': 1.0, 'rootFlare': 1.0, 'rotateV': (15.0, 0.0, 0.0, 0.0), 'pruneRatio': 1.0, 'minRadius': 0.001500000013038516, 'splitHeight': 0.20000000298023224, 'prune': False, 'leafShape': 'rect', 'leafBaseSize': 0.20000000298023224, 'leafObjZ': '+2', 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'leafScaleT': 0.25, 'splitAngleV': (0.0, 5.0, 0.0, 0.0), 'leafDownAngle': 65.0, 'autoTaper': True, 'leafDist': '3', 'af1': 1.0, 'shape': '8', 'baseSize': 0.06799984723329544, 'prunePowerHigh': 0.5, 'showLeaves': True, 'leafangle': -10.0, 'curveBack': (0.0, 0.0, 0.0, 0.0), 'rotate': (99.5, 137.5, -90.0, 137.5), 'useParentAngle': True, 'closeTip': False, 'rMode': 'rotate', 'leafDownAngleV': 55.0, 'horzLeaves': False, 'leafRotateV': 30.0, 'splitAngle': (0.0, 22.0, 25.0, 0.0), 'taperCrown': 0.0, 'customShape': (0.8999999761581421, 1.0, 0.20000000298023224, 0.20000000298023224), 'leafAnim': False, 'taper': (1.0, 1.0, 1.0, 1.0), 'leafScaleV': 0.10000000149011612, 'ratio': 0.019999999552965164, 'handleType': '0'} -------------------------------------------------------------------------------- /add_curve_sapling_3/presets/Default Tree.py: -------------------------------------------------------------------------------- 1 | {'curveV': (20.0, 50.0, 75.0, 75.0), 'minRadius': 0.001500000013038516, 'useParentAngle': True, 'pruneBase': 0.30000001192092896, 'prunePowerHigh': 0.5, 'downAngleV': (0.0, 75.0, 10.0, 10.0), 'levels': 3, 'length': (1.0, 0.30000001192092896, 0.6000000238418579, 0.44999998807907104), 'gust': 1.0, 'ratio': 0.014999999664723873, 'leafScaleT': -0.25, 'shapeS': '4', 'boneStep': (1, 1, 1, 1), 'seed': 0, 'matIndex': (0, 0, 0, 0), 'closeTip': False, 'prunePowerLow': 0.0010000000474974513, 'leafDownAngleV': 30.0, 'shape': '7', 'leafAnim': False, 'rotateV': (15.0, 0.0, 0.0, 0.0), 'baseSize_s': 0.5, 'handleType': '0', 'segSplits': (0.0, 0.0, 0.0, 0.0), 'useArm': False, 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'pruneRatio': 1.0, 'resU': 4, 'taper': (1.0, 1.0, 1.0, 1.0), 'af3': 4.0, 'bevel': False, 'prune': False, 'customShape': (0.5, 1.0, 0.30000001192092896, 0.5), 'rMode': 'rotate', 'baseSplits': 0, 'makeMesh': False, 'scaleV': 3.0, 'leafScale': 0.17000000178813934, 'splitHeight': 0.20000000298023224, 'gustF': 0.07500000298023224, 'ratioPower': 1.0, 'leafangle': -30.0, 'downAngle': (90.0, 110.0, 45.0, 45.0), 'attractOut': (0.0, 0.0, 0.0, 0.0), 'rootFlare': 1.25, 'noTip': False, 'af1': 1.0, 'baseSize': 0.33000001311302185, 'curveRes': (8, 5, 3, 1), 'leafDist': '6', 'scale': 13.0, 'rotate': (99.5, 137.5, 137.5, 137.5), 'branchDist': 1.350000023841858, 'splitRadiusRatio': 0.0, 'branches': (0, 60, 1, 10), 'wind': 1.0, 'leafType': '0', 'pruneWidthPeak': 0.6000000238418579, 'splitStraight': 0.0, 'frameRate': 1.0, 'leafObjZ': '+2', 'loopFrames': 0, 'armLevels': 2, 'splitByLen': True, 'scaleV0': 0.05000000074505806, 'lengthV': (0.05000000074505806, 0.10000000149011612, 0.15000000596046448, 0.25), 'scale0': 1.0, 'attractUp': (0.0, 0.0, 0.25, 0.25), 'taperCrown': 0.0, 'splitAngleV': (2.0, 5.0, 5.0, 5.0), 'leafShape': 'hex', 'pruneWidth': 0.4000000059604645, 'leaves': 25, 'leafRotateV': 10.0, 'showLeaves': False, 'armAnim': False, 'af2': 1.0, 'leafRotate': 90.0, 'curveBack': (0.0, 0.0, 0.0, 0.0), 'leafScaleX': 1.0, 'autoTaper': True, 'leafBaseSize': 0.20000000298023224, 'nrings': 0, 'useOldDownAngle': False, 'splitAngle': (8.0, 20.0, 25.0, 30.0), 'leafScaleV': 0.25, 'curve': (0.0, -40.0, -40.0, 0.0), 'splitLength': 0.0, 'horzLeaves': True, 'leafDownAngle': 60.0, 'splitBias': 0.0, 'previewArm': False, 'bevelRes': 1, 'leafObjY': '+1'} -------------------------------------------------------------------------------- /add_curve_sapling_3_2_8/presets/Default Tree.py: -------------------------------------------------------------------------------- 1 | {'curveV': (20.0, 50.0, 75.0, 75.0), 'minRadius': 0.001500000013038516, 'useParentAngle': True, 'pruneBase': 0.30000001192092896, 'prunePowerHigh': 0.5, 'downAngleV': (0.0, 75.0, 10.0, 10.0), 'levels': 3, 'length': (1.0, 0.30000001192092896, 0.6000000238418579, 0.44999998807907104), 'gust': 1.0, 'ratio': 0.014999999664723873, 'leafScaleT': -0.25, 'shapeS': '4', 'boneStep': (1, 1, 1, 1), 'seed': 0, 'matIndex': (0, 0, 0, 0), 'closeTip': False, 'prunePowerLow': 0.0010000000474974513, 'leafDownAngleV': 30.0, 'shape': '7', 'leafAnim': False, 'rotateV': (15.0, 0.0, 0.0, 0.0), 'baseSize_s': 0.5, 'handleType': '0', 'segSplits': (0.0, 0.0, 0.0, 0.0), 'useArm': False, 'radiusTweak': (1.0, 1.0, 1.0, 1.0), 'pruneRatio': 1.0, 'resU': 4, 'taper': (1.0, 1.0, 1.0, 1.0), 'af3': 4.0, 'bevel': False, 'prune': False, 'customShape': (0.5, 1.0, 0.30000001192092896, 0.5), 'rMode': 'rotate', 'baseSplits': 0, 'makeMesh': False, 'scaleV': 3.0, 'leafScale': 0.17000000178813934, 'splitHeight': 0.20000000298023224, 'gustF': 0.07500000298023224, 'ratioPower': 1.0, 'leafangle': -30.0, 'downAngle': (90.0, 110.0, 45.0, 45.0), 'attractOut': (0.0, 0.0, 0.0, 0.0), 'rootFlare': 1.25, 'noTip': False, 'af1': 1.0, 'baseSize': 0.33000001311302185, 'curveRes': (8, 5, 3, 1), 'leafDist': '6', 'scale': 13.0, 'rotate': (99.5, 137.5, 137.5, 137.5), 'branchDist': 1.350000023841858, 'splitRadiusRatio': 0.0, 'branches': (0, 60, 1, 10), 'wind': 1.0, 'leafType': '0', 'pruneWidthPeak': 0.6000000238418579, 'splitStraight': 0.0, 'frameRate': 1.0, 'leafObjZ': '+2', 'loopFrames': 0, 'armLevels': 2, 'splitByLen': True, 'scaleV0': 0.05000000074505806, 'lengthV': (0.05000000074505806, 0.10000000149011612, 0.15000000596046448, 0.25), 'scale0': 1.0, 'attractUp': (0.0, 0.0, 0.25, 0.25), 'taperCrown': 0.0, 'splitAngleV': (2.0, 5.0, 5.0, 5.0), 'leafShape': 'hex', 'pruneWidth': 0.4000000059604645, 'leaves': 25, 'leafRotateV': 10.0, 'showLeaves': False, 'armAnim': False, 'af2': 1.0, 'leafRotate': 90.0, 'curveBack': (0.0, 0.0, 0.0, 0.0), 'leafScaleX': 1.0, 'autoTaper': True, 'leafBaseSize': 0.20000000298023224, 'nrings': 0, 'useOldDownAngle': False, 'splitAngle': (8.0, 20.0, 25.0, 30.0), 'leafScaleV': 0.25, 'curve': (0.0, -40.0, -40.0, 0.0), 'splitLength': 0.0, 'horzLeaves': True, 'leafDownAngle': 60.0, 'splitBias': 0.0, 'previewArm': False, 'bevelRes': 1, 'leafObjY': '+1'} -------------------------------------------------------------------------------- /pastChanges.md: -------------------------------------------------------------------------------- 1 | This addon has been [added](https://developer.blender.org/rBAc3a6d9132a44afd254fa120157c66e72b751e6f1) to blender master as of version [f7cca89](https://github.com/abpy/improved-sapling-tree-generator/commit/720f312cb083c7a1b866f006b38fcf67521a6f39) with small changes. 2 | 3 | ### Big Changes 4 | Branch splitting is now much improved, especially for trunk splits. Splitting is controlable, more realistic, and works with auto curve handles. 5 | Splitting is more balanced and uniformly random. 6 | 7 | Braches now sprout from the tip of the parent branch, these branches grow straight out, ignoring down angle. This creates the apperance of the branch transitioning from one split level to the next. On the trunk, this creates a more realistic crown for central leader trees. This also means branches will always end with the last split level, so there are no branches ending without leaves. 8 | 9 | New branch rotation method (for first level only) to grow branches outward from the center of the tree, and setting the rotation so that the distribution of branches on the outside is even. 10 | The rotation method can be changed with the 'Branching Mode' property 11 | 12 | New leaf rotation options can set the leaf orientation so that the leaves face upwards and outwards in a much more realistic way. 13 | 14 | An object can now be set to use for leaves with dupliverts or duplifaces 15 | 16 | Curves can now be converted into a mesh that uses the skin modifier. With the mesh it is now possible to simplfy the armature greatly reducing the number of bones and the time it takes to generate the armature. You can now set the number of branching levels to make bones for, and the number of bones in each branch. 17 | 18 | ### Change Log 19 | * Rearranged Interface 20 | * Moved radius settings to a seperate panel 21 | * Branch spliting now works more predictably 22 | * Back curvature now adds to curvature 23 | * 'Conical' shape is narrower at tip like real conifers 24 | * Curvature variation now bends branches in multiple directions and increases along length of branch 25 | * Auto curve handles is now enabled for branch splits 26 | * fixed how child branch start points are calculated 27 | * branch length variation now works in the range 0 - 1 and no longer produces errors 28 | * Leaf orientation is much improved, leaves now face upwards and outwards and have correct normals 29 | * The last stem on a branch now grows straight out, ignoring down angle. 30 | * Taper can now be calculated automaticly based on branch lengths to make the branch radius change linearly from each split level to the next. 31 | * 'Use UV for mapping' is now enabled by default 32 | * leaf down angle and rotation now have their own parameters in the leaf panel 33 | * negative down angle values for leaves now works similarly to branches 34 | * leaf scale taper works for palmate compound leaves (negative number of leaves) 35 | * leaf bend removed, is set to zero for old presets with leaf bend 36 | * Length variation now affects split branch stems individually 37 | * Down angle is calculated differently and should be easier to use, the old method is still available. 38 | * (10-12-15) changes to improve split angle, for levels > 0, this results in the angle being a third as much as before, but more like the angle of trunk splits 39 | * leaf down angle now works like the new branch down angle, and negative down angle variation is random 40 | * down angle variation is now on a curve so it affects branches less at the bottom of the tree 41 | * changed order of shapes, added Inverse Tapered Cylindrical shape 42 | * consistent method of calculating the number of child stems and leaves, and more even distribution 43 | * hexagonal leaves now have UVs, and UVs are centered in the map 44 | * (11-4-15) Merge code from Garfield96, leaf settings can now be changed without updating the tree if leaves is disabled. 45 | * 11-17 Made changes to armature and animation 46 | * added leaf bones, and animation looping 47 | * fix issues with auto curve handels and intersections 48 | * changed how amplitude and frequency are calculated 49 | * directional wind, and new controls for wind animation 50 | 51 | * Presets are now saved to the user presets folder 52 | * Trunk splitting now uses the rotate angle to control the direction of splits, trees are now rounder and more even than before when direction was just random 53 | * leaves parameter now controls amount of leaves even if levels is 1 54 | * added random variation to make branch rings work with branching mode at rotate 55 | * (5-15-16) New easier, more intuitive settings for leaf rotation and orientation 56 | * options for oppositely attached leaves 57 | * 'horizontal leaves' replaced with better method of making leaves rotate to face upwards 58 | * added option to set base size for leaves 59 | * add way of setting the direction of the leaf dupli object 60 | * add new 'Distance' Branching Mode that removes overlapping branches based on distance. 61 | this mode works about as good as 'rotate' but it particularly improves branching at the top of multi trunked trees where rotate would produce gaps. This should be considered experemental, but it probably won't change much. 62 | * New default tree with better starting settings 63 | * added operator to generate multiple trees 64 | 65 | * (3/25/18) 3 commits 66 | * Unicode fix 67 | * Down angle now works to set the trunk angle 68 | * Automatically save backup of previous settings 69 | 70 | * (6/10/18) added new options for splitting 71 | * control of straightness of splits 72 | * setting for length of split branches releative the the parent branch 73 | * outward attraction now works on the trunk, (not that it's very usefull, but atleast it does something) 74 | 75 | In case of exiting or crash a preset is saved. To recover the previous tree this must be loaded immediately or it will be overwritten 76 | 77 | 78 | ###### New features 79 | * Branch distribution to adjust how the first level is distributed along the height of the tree 80 | * Option to grow branches in rings, like pine trees 81 | * Control the shape of secondary branch split levels 82 | * Minimum branch radius to prevent needle-thin branches 83 | * Close tip for branch radius 84 | * Option to make number of splits proportional to branch length 85 | * Root flare to make trunk wider at base 86 | * Leaf rotation can now use negetive values like branches do 87 | * Vertical atraction can now be set individually for each split level 88 | * 'split bias' for trunk splits to put more splits at top or bottom of tree 89 | * Split start height for longer trunk before splitting 90 | * Outward attraction to make branches point out from the center of the tree 91 | * added 'horizontal leaves' and 'leaf angle' to control how leaves are rotated 92 | * 'Leaf Scale Taper' and 'Leaf Scale Variation' to control leaf scale along branch and random variation in scale 93 | * The shape for branch lengths can now be set to a custom shape 94 | * new method to rotate branches evenly around a tree with splits in the trunk 95 | * leaf shape can now be set to make mesh for dupliFaces or dupliVerts 96 | * crown taper to shorten trunk splits farther from the center of the tree 97 | * the height that pruning starts can be set separately from trunk height 98 | * base size for secondary branch levels 99 | * leaf animation 100 | * animation looping 101 | * option to show only the armature for fast animation playback 102 | 103 | ###### notes 104 | 'leaf bend' seems to be broken and probably shouldn't be used, it may be removed soon 105 | 106 | *update*: leaf bend removed form the interface 107 | 108 | *update*: split bias works better now 109 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /add_curve_sapling_3/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | #====================== BEGIN GPL LICENSE BLOCK ====================== 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software Foundation, 17 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | # 19 | #======================= END GPL LICENSE BLOCK ======================== 20 | 21 | bl_info = { 22 | "name": "Sapling_3", 23 | "author": "Andrew Hale (TrumanBlending), modified by Aaron Buchler 2015-2018", 24 | "version": (0, 3, 3), 25 | "blender": (2, 64, 0), 26 | "location": "View3D > Add > Curve", 27 | "description": ("Adds a parametric tree. The method is presented by " 28 | "Jason Weber & Joseph Penn in their paper 'Creation and Rendering of " 29 | "Realistic Trees'."), 30 | "category": "Add Curve"} 31 | 32 | if "bpy" in locals(): 33 | import importlib 34 | importlib.reload(utils) 35 | else: 36 | from add_curve_sapling_3 import utils 37 | 38 | import bpy 39 | import time 40 | import os 41 | import ast 42 | 43 | #import cProfile 44 | 45 | from mathutils import * 46 | from math import pi, sin, degrees, radians, atan2, copysign, ceil 47 | from random import random, uniform, seed, choice, getstate, setstate 48 | from bpy.props import * 49 | 50 | from add_curve_sapling_3.utils import * 51 | 52 | useSet = False 53 | is_first = False 54 | 55 | shapeList = [('0', 'Conical (0)', 'Shape = 0'), 56 | ('1', 'Spherical (1)', 'Shape = 1'), 57 | ('2', 'Hemispherical (2)', 'Shape = 2'), 58 | ('3', 'Cylindrical (3)', 'Shape = 3'), 59 | ('4', 'Tapered Cylindrical (4)', 'Shape = 4'), 60 | ('5', 'Flame (5)', 'Shape = 5'), 61 | ('6', 'Inverse Conical (6)', 'Shape = 6'), 62 | ('7', 'Tend Flame (7)', 'Shape = 7')] 63 | 64 | shapeList3 = [('0', 'Conical', ''), 65 | ('6', 'Inverse Conical', ''), 66 | ('1', 'Spherical', ''), 67 | ('2', 'Hemispherical', ''), 68 | ('3', 'Cylindrical', ''), 69 | ('4', 'Tapered Cylindrical', ''), 70 | ('10', 'Inverse Tapered Cylindrical', ''), 71 | ('5', 'Flame', ''), 72 | ('7', 'Tend Flame', ''), 73 | ('8', 'Custom Shape', '')] 74 | 75 | shapeList4 = [('0', 'Conical', ''), 76 | ('6', 'Inverse Conical', ''), 77 | ('1', 'Spherical', ''), 78 | ('2', 'Hemispherical', ''), 79 | ('3', 'Cylindrical', ''), 80 | ('4', 'Tapered Cylindrical', ''), 81 | ('10', 'Inverse Tapered Cylindrical', ''), 82 | ('5', 'Flame', ''), 83 | ('7', 'Tend Flame', '')] 84 | 85 | leaftypes = [('0', 'Rotated Alternate', 'leaves rotate around the stem and face upwards'), 86 | ('1', 'Rotated Opposite', 'pairs of leaves rotate around the stem and face upwards'), 87 | ('2', 'Alternate', 'leaves sprout alternately from each side of the stem, uses rotate angle'), 88 | ('3', 'Opposite', 'pairs of leaves sprout from opposite sides of stem, uses rotate angle'), 89 | ('4', 'Palmately Compound', 'multiple leaves radiating from stem tip, uses rotate angle for spread angle'), 90 | ('5', 'Radial', 'leaves rotate around the stem (for needles)')] 91 | 92 | axes = [(("+0"), "X", ""), 93 | (("+1"), "Y", ""), 94 | (("+2"), "Z", ""), 95 | (("-0"), "-X", ""), 96 | (("-1"), "-Y", ""), 97 | (("-2"), "-Z", "")] 98 | 99 | 100 | handleList = [('0', 'Auto', 'Auto'), 101 | ('1', 'Vector', 'Vector')] 102 | 103 | settings = [('0', 'Geometry', 'Geometry'), 104 | ('1', 'Branch Radius', 'Branch Radius'), 105 | ('2', 'Branch Splitting', 'Branch Splitting'), 106 | ('3', 'Branch Growth', 'Branch Growth'), 107 | ('4', 'Pruning', 'Pruning'), 108 | ('5', 'Leaves', 'Leaves'), 109 | ('6', 'Armature', 'Armature')] 110 | 111 | branchmodes = [("original", "Original", "rotate around each branch"), 112 | ("rotate", "Rotate", "evenly distribute branches to point outward from center of tree"), 113 | ("distance", "Distance", "remove overlapping branches")] 114 | 115 | 116 | def getPresetpaths(): 117 | """Return paths for both local and user preset folders""" 118 | userDir = os.path.join(bpy.utils.script_path_user(), 'presets', 'operator', 'add_curve_sapling_3') 119 | 120 | if os.path.isdir(userDir): 121 | pass 122 | else: 123 | os.makedirs(userDir) 124 | 125 | script_file = os.path.realpath(__file__) 126 | directory = os.path.dirname(script_file) 127 | localDir = os.path.join(directory, "presets") 128 | 129 | return (localDir, userDir) 130 | 131 | 132 | class ExportData(bpy.types.Operator): 133 | """This operator handles writing presets to file""" 134 | bl_idname = 'sapling.exportdata' 135 | bl_label = 'Export Preset' 136 | 137 | data = StringProperty() 138 | 139 | def execute(self, context): 140 | # Unpack some data from the input 141 | data, filename, overwrite = eval(self.data) 142 | 143 | fpath1 = os.path.join(getPresetpaths()[0], filename + '.py') 144 | fpath2 = os.path.join(getPresetpaths()[1], filename + '.py') 145 | 146 | if os.path.exists(fpath1): 147 | # If it exists in built-in presets then report an error 148 | self.report({'ERROR_INVALID_INPUT'}, 'Can\'t have same name as built-in preset') 149 | return {'CANCELLED'} 150 | elif (not os.path.exists(fpath2)) or (os.path.exists(fpath2) and overwrite): 151 | #if (it does not exist) or (exists and overwrite) then write file 152 | if data: 153 | # If it doesn't exist, create the file with the required data 154 | f = open(os.path.join(getPresetpaths()[1], filename + '.py'), 'w') 155 | f.write(data) 156 | f.close() 157 | return {'FINISHED'} 158 | else: 159 | return {'CANCELLED'} 160 | else: 161 | # If it exists then report an error 162 | self.report({'ERROR_INVALID_INPUT'}, 'Preset Already Exists') 163 | return {'CANCELLED'} 164 | 165 | 166 | class ImportData(bpy.types.Operator): 167 | """This operator handles importing existing presets""" 168 | bl_idname = 'sapling.importdata' 169 | bl_label = 'Import Preset' 170 | 171 | filename = StringProperty() 172 | 173 | def execute(self, context): 174 | # Make sure the operator knows about the global variables 175 | global settings, useSet, is_first 176 | # Read the preset data into the global settings 177 | try: 178 | f = open(os.path.join(getPresetpaths()[0], self.filename), 'r') 179 | except (FileNotFoundError, IOError): 180 | f = open(os.path.join(getPresetpaths()[1], self.filename), 'r') 181 | settings = f.readline() 182 | f.close() 183 | #print(settings) 184 | settings = ast.literal_eval(settings) 185 | 186 | #use old attractup 187 | if type(settings['attractUp']) == float: 188 | atr = settings['attractUp'] 189 | settings['attractUp'] = [0, 0, atr, atr] 190 | 191 | #use old leaf rotations 192 | if 'leafDownAngle' not in settings: 193 | l = settings['levels'] 194 | settings['leafDownAngle'] = settings['downAngle'][min(l, 3)] 195 | settings['leafDownAngleV'] = settings['downAngleV'][min(l, 3)] 196 | settings['leafRotate'] = settings['rotate'][min(l, 3)] 197 | settings['leafRotateV'] = settings['rotateV'][min(l, 3)] 198 | 199 | #zero leaf bend 200 | settings['bend'] = 0 201 | 202 | #use old leaf settings 203 | if 'leafType' not in settings: 204 | settings['leafType'] = '0' 205 | if settings['leaves'] < 0: 206 | settings['leaves'] = abs(settings['leaves']) 207 | settings['leafType'] = '4' 208 | if settings['leafRotate'] < 1: 209 | settings['leafType'] = '2' 210 | 211 | if 'noTip' not in settings: 212 | settings['noTip'] = False 213 | 214 | # Set the flag to use the settings 215 | useSet = True 216 | is_first = True 217 | return {'FINISHED'} 218 | 219 | 220 | def presetAsDict(filename): 221 | try: 222 | f = open(os.path.join(getPresetpaths()[0], filename), 'r') 223 | except (FileNotFoundError, IOError): 224 | f = open(os.path.join(getPresetpaths()[1], filename), 'r') 225 | settings = f.readline() 226 | f.close() 227 | settings = ast.literal_eval(settings) 228 | return settings 229 | 230 | 231 | class PresetMenu(bpy.types.Menu): 232 | """Create the preset menu by finding all preset files 233 | in the preset directory""" 234 | bl_idname = "sapling.presetmenu" 235 | bl_label = "Presets" 236 | 237 | def draw(self, context): 238 | # Get all the sapling presets 239 | presets = [a for a in os.listdir(getPresetpaths()[0]) if a[-3:] == '.py'] 240 | presets.extend([a for a in os.listdir(getPresetpaths()[1]) if a[-3:] == '.py']) 241 | layout = self.layout 242 | # Append all to the menu 243 | for p in presets: 244 | layout.operator("sapling.importdata", text=p[:-3]).filename = p 245 | 246 | 247 | class AddTree(bpy.types.Operator): 248 | bl_idname = "curve.tree_add" 249 | bl_label = "Sapling: Add Tree" 250 | bl_options = {'REGISTER', 'UNDO'} 251 | 252 | def objectList(self, context): 253 | objects = [] 254 | bObjects = bpy.data.objects 255 | for obj in bObjects: 256 | if (obj.type in ['MESH', 'CURVE', 'SURFACE']) and (obj.name not in ['tree', 'leaves', 'envelope']): 257 | objects.append((obj.name, obj.name, "")) 258 | 259 | return objects 260 | 261 | def update_tree(self, context): 262 | self.do_update = True 263 | 264 | def update_leaves(self, context): 265 | if self.showLeaves: 266 | self.do_update = True 267 | else: 268 | self.do_update = False 269 | 270 | def no_update_tree(self, context): 271 | self.do_update = False 272 | 273 | do_update = BoolProperty(name='Do Update', 274 | default=True, options={'HIDDEN'}) 275 | 276 | chooseSet = EnumProperty(name='Settings', 277 | description='Choose the settings to modify', 278 | items=settings, 279 | default='0', update=no_update_tree) 280 | 281 | bevel = BoolProperty(name='Bevel', 282 | description='Whether the curve is beveled', 283 | default=False, update=update_tree) 284 | prune = BoolProperty(name='Prune', 285 | description='Whether the tree is pruned', 286 | default=False, update=update_tree) 287 | showLeaves = BoolProperty(name='Show Leaves', 288 | description='Whether the leaves are shown', 289 | default=False, update=update_tree) 290 | useArm = BoolProperty(name='Use Armature', 291 | description='Whether the armature is generated', 292 | default=False, update=update_tree) 293 | seed = IntProperty(name='Random Seed', 294 | description='The seed of the random number generator', 295 | default=0, update=update_tree) 296 | handleType = EnumProperty(name='Handle Type', 297 | description='The type of bezier curve handles', 298 | items=handleList, 299 | default='0', update=update_tree) 300 | bevelRes = IntProperty(name='Bevel Resolution', 301 | description='The bevel resolution of the curves', 302 | min=0, 303 | max=32, 304 | default=0, update=update_tree) 305 | resU = IntProperty(name='Curve Resolution', 306 | description='The resolution along the curves', 307 | min=1, 308 | default=4, update=update_tree) 309 | 310 | levels = IntProperty(name='Levels', 311 | description='Number of recursive branches', 312 | min=1, 313 | max=6, 314 | soft_max=4, 315 | default=3, update=update_tree) 316 | length = FloatVectorProperty(name='Length', 317 | description='The relative lengths of each branch level', 318 | min=0.000001, 319 | default=[1, 0.3, 0.6, 0.45], 320 | size=4, update=update_tree) 321 | lengthV = FloatVectorProperty(name='Length Variation', 322 | description='Branch and split length variations for each level', 323 | min=0.0, 324 | max=1.0, 325 | default=[0, 0, 0, 0], 326 | size=4, update=update_tree) 327 | taperCrown = FloatProperty(name='Taper Crown', 328 | description='Shorten trunk splits toward outside of tree', 329 | min=0.0, 330 | soft_max=1.0, 331 | default=0, update=update_tree) 332 | branches = IntVectorProperty(name='Branches', 333 | description='The number of branches grown at each level', 334 | min=0, 335 | default=[50, 30, 10, 10], 336 | size=4, update=update_tree) 337 | curveRes = IntVectorProperty(name='Curve Resolution', 338 | description='The number of segments on each branch', 339 | min=1, 340 | default=[3, 5, 3, 1], 341 | size=4, update=update_tree) 342 | curve = FloatVectorProperty(name='Curvature', 343 | description='The angle of the end of the branch', 344 | default=[0, -40, -40, 0], 345 | size=4, update=update_tree) 346 | curveV = FloatVectorProperty(name='Curvature Variation', 347 | description='Variation of the curvature', 348 | default=[20, 50, 75, 0], 349 | size=4, update=update_tree) 350 | curveBack = FloatVectorProperty(name='Back Curvature', 351 | description='Curvature for the second half of a branch', 352 | default=[0, 0, 0, 0], 353 | size=4, update=update_tree) 354 | baseSplits = IntProperty(name='Base Splits', 355 | description='Number of trunk splits at its base', 356 | min=0, 357 | default=0, update=update_tree) 358 | segSplits = FloatVectorProperty(name='Segment Splits', 359 | description='Number of splits per segment', 360 | min=0, 361 | soft_max=3, 362 | default=[0, 0, 0, 0], 363 | size=4, update=update_tree) 364 | splitByLen = BoolProperty(name='Split relative to length', 365 | description='Split proportional to branch length', 366 | default=False, update=update_tree) 367 | rMode = EnumProperty(name="", #"Branching Mode" 368 | description='Branching and Rotation Mode', 369 | items=branchmodes, 370 | default="rotate", update=update_tree) 371 | splitStraight = FloatProperty(name="Split Straight", 372 | description="Straightness of trunk branch splits", 373 | min=0.0, 374 | max=1.0, 375 | default=0, update=update_tree) 376 | splitLength = FloatProperty(name="Split Length", 377 | description="Length of trunk branch splits, (similar to length variation but not random)", 378 | min=0.0, 379 | max=1.0, 380 | default=0, update=update_tree) 381 | splitAngle = FloatVectorProperty(name='Split Angle', 382 | description='Angle of branch splitting', 383 | default=[0, 0, 0, 0], 384 | size=4, update=update_tree) 385 | splitAngleV = FloatVectorProperty(name='Split Angle Variation', 386 | description='Variation in the split angle', 387 | default=[0, 0, 0, 0], 388 | size=4, update=update_tree) 389 | scale = FloatProperty(name='Scale', 390 | description='The tree scale', 391 | min=0.0, 392 | default=13.0, update=update_tree) 393 | scaleV = FloatProperty(name='Scale Variation', 394 | description='The variation in the tree scale', 395 | default=3.0, update=update_tree) 396 | attractUp = FloatVectorProperty(name='Vertical Attraction', 397 | description='Branch upward attraction', 398 | default=[0, 0, 0, 0], 399 | size=4, update=update_tree) 400 | attractOut = FloatVectorProperty(name='Outward Attraction', 401 | description='Branch outward attraction', 402 | default=[0, 0, 0, 0], 403 | min=0.0, 404 | max=1.0, 405 | size=4, update=update_tree) 406 | shape = EnumProperty(name='Shape', 407 | description='The overall shape of the tree', 408 | items=shapeList3, 409 | default='7', update=update_tree) 410 | shapeS = EnumProperty(name='Secondary Branches Shape', 411 | description='The shape of secondary splits', 412 | items=shapeList4, 413 | default='4', update=update_tree) 414 | customShape = FloatVectorProperty(name='Custom Shape', 415 | description='custom shape branch length at \n(Base, Middle, Middle Position, Top)', 416 | size=4, 417 | min=.01, 418 | max=1, 419 | default=[.5, 1.0, .3, .5], update=update_tree) 420 | branchDist = FloatProperty(name='Branch Distribution', 421 | description='Adjust branch spacing to put more branches at the top or bottom of the tree', 422 | min=0.1, 423 | soft_max=10, 424 | default=1.0, update=update_tree) 425 | nrings = IntProperty(name='Branch Rings', 426 | description='grow branches in whorls', 427 | min=0, 428 | default=0, update=update_tree) 429 | baseSize = FloatProperty(name='Trunk Height', 430 | description='Fraction of tree height with no branches (Base Size)', 431 | min=0.0, 432 | max=1.0, 433 | default=0.4, update=update_tree) 434 | baseSize_s = FloatProperty(name='Secondary Base Size', 435 | description='Factor to decrease base size for each level', 436 | min=0.0, 437 | max=1.0, 438 | default=0.25, update=update_tree) 439 | leafBaseSize = FloatProperty(name='Leaf Base Size', 440 | description='Fraction of stem length with no leaves', 441 | min=0.0, 442 | max=1.0, 443 | default=0.20, update=update_tree) 444 | splitHeight = FloatProperty(name='Split Height', 445 | description='Fraction of tree height with no splits', 446 | min=0.0, 447 | max=1.0, 448 | default=0.2, update=update_tree) 449 | splitBias = FloatProperty(name='Split Bias', 450 | description='Put more splits at the top or bottom of the tree', 451 | soft_min=-2.0, 452 | soft_max=2.0, 453 | default=0.0, update=update_tree) 454 | ratio = FloatProperty(name='Ratio', 455 | description='Ratio of tree scale to base radius', 456 | min=0.0, 457 | default=0.015, update=update_tree) 458 | minRadius = FloatProperty(name='Minimum Radius', 459 | description='Minimum branch Radius', 460 | min=0.0, 461 | default=0.0, update=update_tree) 462 | closeTip = BoolProperty(name='Close Tip', 463 | description='Set radius at branch tips to zero', 464 | default=False, update=update_tree) 465 | rootFlare = FloatProperty(name='Root Flare', 466 | description='Root radius factor', 467 | min=1.0, 468 | default=1.0, update=update_tree) 469 | splitRadiusRatio = FloatProperty(name='Split Radius Ratio', 470 | description='Reduce radius after branch splits', 471 | min=-1.0, 472 | max=1.0, 473 | default=0.75, update=update_tree) 474 | autoTaper = BoolProperty(name='Auto Taper', 475 | description='Calculate taper automaticly based on branch lengths', 476 | default=True, update=update_tree) 477 | taper = FloatVectorProperty(name='Taper', 478 | description='The fraction of tapering on each branch', 479 | min=0.0, 480 | max=1.0, 481 | default=[1, 1, 1, 1], 482 | size=4, update=update_tree) 483 | noTip = BoolProperty(name='No branch at stem tip', 484 | description='Useful for non-typical / abstract trees', 485 | default=False, update=update_tree) 486 | radiusTweak = FloatVectorProperty(name='Tweak Radius', 487 | description='multiply radius by this factor', 488 | min=0.0, 489 | max=1.0, 490 | default=[1, 1, 1, 1], 491 | size=4, update=update_tree) 492 | ratioPower = FloatProperty(name='Radius Ratio Power', 493 | description='Power which defines the radius of a branch compared to the radius of the branch it grew from', 494 | min=0.0, 495 | soft_min=1.0, 496 | default=1.2, update=update_tree) 497 | downAngle = FloatVectorProperty(name='Down Angle', 498 | description='The angle between a new branch and the one it grew from', 499 | default=[90, 60, 45, 45], 500 | size=4, update=update_tree) 501 | downAngleV = FloatVectorProperty(name='Down Angle Variation', 502 | description='Angle to decrease Down Angle by towards end of parent branch \n(negative values add random variation)', 503 | default=[0, -50, 10, 10], 504 | size=4, update=update_tree) 505 | useOldDownAngle = BoolProperty(name='Use old down angle variation', 506 | default=False, update=update_tree) 507 | useParentAngle = BoolProperty(name = 'Use parent angle', 508 | description = '(first level) Rotate branch to match parent branch', 509 | default=True, update=update_tree) 510 | rotate = FloatVectorProperty(name='Rotate Angle', 511 | description='The angle of a new branch around the one it grew from \n(negative values make branches rotate opposite from the previous one)', 512 | default=[137.5, 137.5, 137.5, 137.5], 513 | size=4, update=update_tree) 514 | rotateV = FloatVectorProperty(name='Rotate Angle Variation', 515 | description='Variation in the rotate angle', 516 | default=[0, 0, 0, 0], 517 | size=4, update=update_tree) 518 | scale0 = FloatProperty(name='Radius Scale', 519 | description='The scale of the trunk radius', 520 | min=0.0, 521 | default=1.0, update=update_tree) 522 | scaleV0 = FloatProperty(name='Radius Scale Variation', 523 | description='Variation in the radius scale', 524 | min=0.0, 525 | max=1.0, 526 | default=0.2, update=update_tree) 527 | pruneWidth = FloatProperty(name='Prune Width', 528 | description='The width of the envelope', 529 | min=0.0, 530 | default=0.4, update=update_tree) 531 | pruneBase = FloatProperty(name='Prune Base Height', 532 | description='The height of the base of the envelope, bound by trunk height', 533 | min=0.0, 534 | max=1.0, 535 | default=0.3, update=update_tree) 536 | pruneWidthPeak = FloatProperty(name='Prune Width Peak', 537 | description='Fraction of envelope height where the maximum width occurs', 538 | min=0.0, 539 | default=0.6, update=update_tree) 540 | prunePowerHigh = FloatProperty(name='Prune Power High', 541 | description='Power which determines the shape of the upper portion of the envelope', 542 | default=0.5, update=update_tree) 543 | prunePowerLow = FloatProperty(name='Prune Power Low', 544 | description='Power which determines the shape of the lower portion of the envelope', 545 | default=0.001, update=update_tree) 546 | pruneRatio = FloatProperty(name='Prune Ratio', 547 | description='Proportion of pruned length', 548 | min=0.0, 549 | max=1.0, 550 | default=1.0, update=update_tree) 551 | leaves = IntProperty(name='Leaves', 552 | description='Maximum number of leaves per branch', 553 | min=0, 554 | default=25, update=update_tree) 555 | leafType = EnumProperty(name='Leaf Type', 556 | description='Type of leaf arrangment', 557 | items=leaftypes[::-1], 558 | default='0', update=update_leaves) #update_leaves update_tree 559 | 560 | leafDownAngle = FloatProperty(name='Leaf Down Angle', 561 | description='The angle between a new leaf and the branch it grew from', 562 | default=45, update=update_leaves) 563 | leafDownAngleV = FloatProperty(name='Leaf Down Angle Variation', 564 | description='Angle to decrease Down Angle by towards end of parent branch', 565 | min=0, 566 | default=10, update=update_tree) 567 | leafRotate = FloatProperty(name='Leaf Rotate Angle', 568 | description='The rotate angle for Alternate and Opposite leaves', 569 | default=90, update=update_tree) 570 | leafRotateV = FloatProperty(name='Rotation Variation', 571 | description='Add randomness to leaf orientation', 572 | default=0.0, update=update_leaves) 573 | 574 | leafObjZ = EnumProperty(name='', 575 | description='leaf tip axis', 576 | items=axes, 577 | default="+2", update=update_leaves) 578 | leafObjY = EnumProperty(name='', 579 | description='leaf top axis', 580 | items=axes, 581 | default="+1", update=update_leaves) 582 | #leafObjX = EnumProperty(name='', 583 | # description='leaf side axis', 584 | # items=axes, 585 | # default="+0", update=update_leaves) 586 | 587 | leafScale = FloatProperty(name='Leaf Scale', 588 | description='The scaling applied to the whole leaf', 589 | min=0.0, 590 | default=0.17, update=update_leaves) 591 | leafScaleX = FloatProperty(name='Leaf Scale X', 592 | description='The scaling applied to the x direction of the leaf', 593 | min=0.0, 594 | default=1.0, update=update_leaves) 595 | leafScaleT = FloatProperty(name='Leaf Scale Taper', 596 | description='scale leaves toward the tip or base of the patent branch', 597 | min = -1.0, 598 | max = 1.0, 599 | default=0.0, update=update_leaves) 600 | leafScaleV = FloatProperty(name='Leaf Scale Variation', 601 | description='randomize leaf scale', 602 | min = 0.0, 603 | max = 1.0, 604 | default=0.0, update=update_leaves) 605 | leafShape = EnumProperty(name='Leaf Shape', 606 | description='The shape of the leaves', 607 | items=(('hex', 'Hexagonal', '0'), ('rect', 'Rectangular', '1'), ('dFace', 'DupliFaces', '2'), ('dVert', 'DupliVerts', '3')), 608 | default='hex', update=update_leaves) 609 | leafDupliObj = EnumProperty(name='Leaf Object', 610 | description='Object to use for leaf instancing if Leaf Shape is DupliFaces or DupliVerts', 611 | items=objectList, 612 | update=update_leaves) 613 | 614 | leafangle = FloatProperty(name='Leaf Angle', 615 | description='Leaf vertical attraction', 616 | default=0.0, update=update_leaves) 617 | horzLeaves = BoolProperty(name='Horizontal leaves', 618 | description='Leaves face upwards', 619 | default=True, update=update_leaves) 620 | leafDist = EnumProperty(name='Leaf Distribution', 621 | description='The way leaves are distributed on branches', 622 | items=shapeList4, 623 | default='6', update=update_tree) 624 | 625 | armAnim = BoolProperty(name='Armature Animation', 626 | description='Whether animation is added to the armature', 627 | default=False, update=update_tree) 628 | previewArm = BoolProperty(name='Fast Preview', 629 | description=('Disable armature modifier, hide tree, and set bone display to wire, for fast playback \n' 630 | 'If Make Mesh is enabled: \nDisable skin modifier, hide curve tree and armature'), 631 | default=False, update=update_tree) 632 | leafAnim = BoolProperty(name='Leaf Animation', 633 | description='Whether animation is added to the leaves', 634 | default=False, update=update_tree) 635 | frameRate = FloatProperty(name='Animation Speed', 636 | description='Adjust speed of animation, relative to scene frame rate', 637 | min=0.001, 638 | default=1, update=update_tree) 639 | loopFrames = IntProperty(name='Loop Frames', 640 | description='Number of frames to make the animation loop for, zero is disabled', 641 | min=0, 642 | default=0, update=update_tree) 643 | 644 | # windSpeed = FloatProperty(name='Wind Speed', 645 | # description='The wind speed to apply to the armature', 646 | # default=2.0, update=update_tree) 647 | # windGust = FloatProperty(name='Wind Gust', 648 | # description='The greatest increase over Wind Speed', 649 | # default=0.0, update=update_tree) 650 | 651 | wind= FloatProperty(name='Overall Wind Strength', 652 | description='The intensity of the wind to apply to the armature', 653 | default=1.0, update=update_tree) 654 | 655 | gust = FloatProperty(name='Wind Gust Strength', 656 | description='The amount of directional movement, (from the positive Y direction)', 657 | default=1.0, update=update_tree) 658 | 659 | gustF = FloatProperty(name='Wind Gust Fequency', 660 | description='The Fequency of directional movement', 661 | default=0.075, update=update_tree) 662 | 663 | af1 = FloatProperty(name='Amplitude', 664 | description='Multiplier for noise amplitude', 665 | default=1.0, update=update_tree) 666 | af2 = FloatProperty(name='Frequency', 667 | description='Multiplier for noise fequency', 668 | default=1.0, update=update_tree) 669 | af3 = FloatProperty(name='Randomness', 670 | description='Random offset in noise', 671 | default=4.0, update=update_tree) 672 | 673 | makeMesh = BoolProperty(name='Make Mesh', 674 | description='Convert curves to mesh, uses skin modifier, enables armature simplification', 675 | default=False, update=update_tree) 676 | armLevels = IntProperty(name='Armature Levels', 677 | description='Number of branching levels to make bones for, 0 is all levels', 678 | min=0, 679 | default=2, update=update_tree) 680 | boneStep = IntVectorProperty(name='Bone Length', 681 | description='Number of stem segments per bone', 682 | min=1, 683 | default=[1, 1, 1, 1], 684 | size=4, update=update_tree) 685 | matIndex = IntVectorProperty(name='Material Index', 686 | description='Material index for each split level (curves only)', 687 | min=0, 688 | max=3, 689 | default=[0, 0, 0, 0], 690 | size=4, update=update_tree) 691 | 692 | presetName = StringProperty(name='Preset Name', 693 | description='The name of the preset to be saved', 694 | default='', 695 | subtype='FILE_NAME', update=no_update_tree) 696 | limitImport = BoolProperty(name='Limit Import', 697 | description='Limit imported tree to 2 levels & no leaves for speed', 698 | default=True, update=no_update_tree) 699 | overwrite = BoolProperty(name='Overwrite', 700 | description='When checked, overwrite existing preset files when saving', 701 | default=False, update=no_update_tree) 702 | 703 | @classmethod 704 | def poll(cls, context): 705 | return context.mode == 'OBJECT' 706 | 707 | def draw(self, context): 708 | 709 | layout = self.layout 710 | 711 | layout.prop(self, 'chooseSet') 712 | 713 | if self.chooseSet == '0': 714 | box = layout.box() 715 | box.label("Geometry:") 716 | row = box.row() 717 | row.prop(self, 'bevel') 718 | row.prop(self, 'makeMesh') 719 | 720 | row = box.row() 721 | row.prop(self, 'bevelRes') 722 | row.prop(self, 'resU') 723 | 724 | box.prop(self, 'handleType') 725 | box.prop(self, 'shape') 726 | 727 | row = box.row() 728 | row.prop(self, 'customShape') 729 | 730 | box.prop(self, 'shapeS') 731 | box.prop(self, 'branchDist') 732 | box.prop(self, 'nrings') 733 | 734 | row = box.row() 735 | row.prop(self, 'matIndex') 736 | 737 | box.label("") 738 | box.prop(self, 'seed') 739 | 740 | box.label("Tree Scale:") 741 | row = box.row() 742 | row.prop(self, 'scale') 743 | row.prop(self, 'scaleV') 744 | 745 | # Here we create a dict of all the properties. 746 | # Unfortunately as_keyword doesn't work with vector properties, 747 | # so we need something custom. This is it 748 | data = [] 749 | for a, b in (self.as_keywords(ignore=("chooseSet", "presetName", "limitImport", "do_update", "overwrite", "leafDupliObj"))).items(): 750 | # If the property is a vector property then add the slice to the list 751 | try: 752 | len(b) 753 | data.append((a, b[:])) 754 | # Otherwise, it is fine so just add it 755 | except: 756 | data.append((a, b)) 757 | # Create the dict from the list 758 | data = dict(data) 759 | 760 | row = box.row() 761 | row.prop(self, 'presetName') 762 | # Send the data dict and the file name to the exporter 763 | row.operator('sapling.exportdata').data = repr([repr(data), self.presetName, self.overwrite]) 764 | row = box.row() 765 | row.label(" ") 766 | row.prop(self, 'overwrite') 767 | row = box.row() 768 | row.menu('sapling.presetmenu', text='Load Preset') 769 | row.prop(self, 'limitImport') 770 | 771 | elif self.chooseSet == '1': 772 | box = layout.box() 773 | box.label("Branch Radius:") 774 | 775 | row = box.row() 776 | row.prop(self, 'bevel') 777 | row.prop(self, 'bevelRes') 778 | 779 | box.prop(self, 'ratio') 780 | 781 | box.prop(self, 'minRadius') 782 | box.prop(self, 'closeTip') 783 | box.prop(self, 'rootFlare') 784 | box.prop(self, 'splitRadiusRatio') 785 | 786 | box.label("") 787 | box.label("Other:") 788 | 789 | row = box.row() 790 | row.prop(self, 'autoTaper') 791 | row.prop(self, 'noTip') 792 | 793 | row = box.row() 794 | row.prop(self, 'scale0') 795 | row.prop(self, 'scaleV0') 796 | box.prop(self, 'ratioPower') 797 | 798 | split = box.split() 799 | col = split.column() 800 | col.prop(self, 'taper') 801 | col = split.column() 802 | col.prop(self, 'radiusTweak') 803 | 804 | elif self.chooseSet == '2': 805 | box = layout.box() 806 | box.label("Branch Splitting:") 807 | box.prop(self, 'levels') 808 | box.prop(self, 'baseSplits') 809 | row = box.row() 810 | row.prop(self, 'baseSize') 811 | row.prop(self, 'baseSize_s') 812 | box.prop(self, 'splitHeight') 813 | box.prop(self, 'splitBias') 814 | box.prop(self, 'splitByLen') 815 | 816 | split = box.split() 817 | 818 | col = split.column() 819 | col.prop(self, 'branches') 820 | col.prop(self, 'splitAngle') 821 | col.prop(self, 'rotate') 822 | col.prop(self, 'attractOut') 823 | 824 | col = split.column() 825 | col.prop(self, 'segSplits') 826 | col.prop(self, 'splitAngleV') 827 | col.prop(self, 'rotateV') 828 | 829 | col.label("Branching Mode:") 830 | col.prop(self, 'rMode') 831 | col.prop(self, 'splitStraight') 832 | col.prop(self, 'splitLength') 833 | 834 | box.column().prop(self, 'curveRes') 835 | 836 | elif self.chooseSet == '3': 837 | box = layout.box() 838 | box.label("Branch Growth:") 839 | 840 | box.prop(self, 'taperCrown') 841 | 842 | split = box.split() 843 | 844 | col = split.column() 845 | col.prop(self, 'length') 846 | col.prop(self, 'downAngle') 847 | col.prop(self, 'curve') 848 | col.prop(self, 'curveBack') 849 | 850 | col = split.column() 851 | col.prop(self, 'lengthV') 852 | col.prop(self, 'downAngleV') 853 | col.prop(self, 'curveV') 854 | col.prop(self, 'attractUp') 855 | 856 | box.prop(self, 'useOldDownAngle') 857 | box.prop(self, 'useParentAngle') 858 | 859 | elif self.chooseSet == '4': 860 | box = layout.box() 861 | box.label("Pruning:") 862 | box.prop(self, 'prune') 863 | box.prop(self, 'pruneRatio') 864 | row = box.row() 865 | row.prop(self, 'pruneWidth') 866 | row.prop(self, 'pruneBase') 867 | box.prop(self, 'pruneWidthPeak') 868 | 869 | row = box.row() 870 | row.prop(self, 'prunePowerHigh') 871 | row.prop(self, 'prunePowerLow') 872 | 873 | elif self.chooseSet == '5': 874 | box = layout.box() 875 | box.label("Leaves:") 876 | box.prop(self, 'showLeaves') 877 | box.prop(self, 'leafShape') 878 | box.prop(self, 'leafDupliObj') 879 | 880 | 881 | row = box.row() 882 | row.label("Leaf Object Axes:") 883 | row.prop(self, 'leafObjZ') 884 | row.prop(self, 'leafObjY') 885 | #row.prop(self, 'leafObjX') 886 | 887 | 888 | box.prop(self, 'leaves') 889 | box.prop(self, 'leafBaseSize') 890 | box.prop(self, 'leafDist') 891 | 892 | box.label("") 893 | box.prop(self, 'leafType') 894 | box.prop(self, 'leafangle') 895 | row = box.row() 896 | row.prop(self, 'leafDownAngle') 897 | row.prop(self, 'leafDownAngleV') 898 | 899 | row = box.row() 900 | row.prop(self, 'leafRotate') 901 | row.prop(self, 'leafRotateV') 902 | box.label("") 903 | 904 | row = box.row() 905 | row.prop(self, 'leafScale') 906 | row.prop(self, 'leafScaleX') 907 | 908 | row = box.row() 909 | row.prop(self, 'leafScaleT') 910 | row.prop(self, 'leafScaleV') 911 | 912 | #box.prop(self, 'horzLeaves') 913 | 914 | elif self.chooseSet == '6': 915 | box = layout.box() 916 | box.label("Armature and Animation:") 917 | 918 | row = box.row() 919 | row.prop(self, 'useArm') 920 | row.prop(self, 'previewArm') 921 | 922 | row = box.row() 923 | row.prop(self, 'armAnim') 924 | row.prop(self, 'leafAnim') 925 | 926 | box.prop(self, 'frameRate') 927 | box.prop(self, 'loopFrames') 928 | 929 | #row = box.row() 930 | #row.prop(self, 'windSpeed') 931 | #row.prop(self, 'windGust') 932 | 933 | box.label('Wind Settings:') 934 | box.prop(self, 'wind') 935 | row = box.row() 936 | row.prop(self, 'gust') 937 | row.prop(self, 'gustF') 938 | 939 | box.label('Leaf Wind Settings:') 940 | box.prop(self, 'af1') 941 | box.prop(self, 'af2') 942 | box.prop(self, 'af3') 943 | 944 | box.label("") 945 | box.prop(self, 'makeMesh') 946 | box.label("Armature Simplification:") 947 | box.prop(self, 'armLevels') 948 | box.prop(self, 'boneStep') 949 | 950 | def execute(self, context): 951 | # Ensure the use of the global variables 952 | global settings, useSet, is_first 953 | start_time = time.time() 954 | # If we need to set the properties from a preset then do it here 955 | if useSet: 956 | for a, b in settings.items(): 957 | setattr(self, a, b) 958 | if self.limitImport: 959 | setattr(self, 'levels', min(settings['levels'], 2)) 960 | setattr(self, 'showLeaves', False) 961 | useSet = False 962 | if self.do_update: 963 | addTree(self) 964 | #cProfile.runctx("addTree(self)", globals(), locals()) 965 | print("Tree creation in %0.1fs" %(time.time()-start_time)) 966 | 967 | #backup most recent setengs in case of exit 968 | if not is_first: 969 | # Here we create a dict of all the properties. 970 | data = [] 971 | for a, b in (self.as_keywords(ignore=("chooseSet", "presetName", "limitImport", "do_update", "overwrite", "leafDupliObj"))).items(): 972 | # If the property is a vector property then add the slice to the list 973 | try: 974 | len(b) 975 | data.append((a, b[:])) 976 | # Otherwise, it is fine so just add it 977 | except: 978 | data.append((a, b)) 979 | # Create the dict from the list 980 | data = dict(data) 981 | 982 | #then save 983 | bpy.ops.sapling.exportdata("INVOKE_DEFAULT", data = repr([repr(data), "PreviousSettings", True])) 984 | 985 | is_first = False 986 | 987 | return {'FINISHED'} 988 | else: 989 | return {'PASS_THROUGH'} 990 | 991 | def invoke(self, context, event): 992 | global is_first 993 | is_first = True 994 | bpy.ops.sapling.importdata(filename = "Default Tree.py") 995 | return self.execute(context) 996 | 997 | 998 | class AddMultipleTrees(bpy.types.Operator): 999 | bl_idname = "curve.trees_add" 1000 | bl_label = "Sapling: Add Trees" 1001 | bl_options = {'REGISTER', 'UNDO'} 1002 | 1003 | def objectList(self, context): 1004 | objects = [] 1005 | bObjects = bpy.data.objects 1006 | # try: 1007 | # bObjects = bpy.data.objects 1008 | # except AttributeError: 1009 | # pass 1010 | # else: 1011 | for obj in bObjects: 1012 | if (obj.type in ['MESH', 'CURVE', 'SURFACE']) and (obj.name not in ['tree', 'leaves']): 1013 | objects.append((obj.name, obj.name, "")) 1014 | return objects 1015 | 1016 | do_update = BoolProperty(name='Re-grow Trees', 1017 | default=True) 1018 | 1019 | bevel = BoolProperty(name='Bevel', 1020 | description='Whether the curve is beveled', 1021 | default=False) 1022 | showLeaves = BoolProperty(name='Show Leaves', 1023 | description='Whether the leaves are shown', 1024 | default=False) 1025 | useArm = BoolProperty(name='Use Armature', 1026 | description='Whether the armature is generated', 1027 | default=False) 1028 | seed = IntProperty(name='Random Seed', 1029 | description='The seed of the random number generator', 1030 | default=0) 1031 | numTrees = IntProperty(name='Number of trees', 1032 | description='Number of trees to generate while incrementing the seed', 1033 | min=1, 1034 | default=1) 1035 | 1036 | scale = FloatProperty(name='Scale', 1037 | description='The tree scale (Scale)', 1038 | min=0.0, 1039 | default=13.0) 1040 | scaleV = FloatProperty(name='Scale Variation', 1041 | description='The variation in the tree scale', 1042 | default=3.0) 1043 | 1044 | bevelRes = IntProperty(name='Bevel Resolution', 1045 | description='The bevel resolution of the curves', 1046 | min=0, 1047 | max=32, 1048 | default=0) 1049 | resU = IntProperty(name='Curve Resolution', 1050 | description='The resolution along the curves', 1051 | min=1, 1052 | default=4) 1053 | 1054 | leafShape = EnumProperty(name='Leaf Shape', 1055 | description='The shape of the leaves', 1056 | items=(('hex', 'Hexagonal', '0'), ('rect', 'Rectangular', '1'), ('dFace', 'DupliFaces', '2'), ('dVert', 'DupliVerts', '3')), 1057 | default='hex') 1058 | leafDupliObj = EnumProperty(name='Leaf Object', 1059 | description='Object to use for leaf instancing if Leaf Shape is DupliFaces or DupliVerts', 1060 | items=objectList) 1061 | leafObjZ = EnumProperty(name='', 1062 | description='leaf tip axis', 1063 | items=axes, 1064 | default="+2") 1065 | leafObjY = EnumProperty(name='', 1066 | description='leaf top axis', 1067 | items=axes, 1068 | default="+1") 1069 | leafScale = FloatProperty(name='Leaf Scale', 1070 | description='The scaling applied to the whole leaf (LeafScale)', 1071 | min=0.0, 1072 | default=0.17) 1073 | 1074 | armAnim = BoolProperty(name='Armature Animation', 1075 | description='Whether animation is added to the armature', 1076 | default=False) 1077 | previewArm = BoolProperty(name='Fast Preview', 1078 | description='Disable armature modifier, hide tree, and set bone display to wire, for fast playback', 1079 | ##Disable skin modifier and hide tree and armature, for fast playback 1080 | default=False) 1081 | leafAnim = BoolProperty(name='Leaf Animation', 1082 | description='Whether animation is added to the leaves', 1083 | default=False) 1084 | frameRate = FloatProperty(name='Animation Speed', 1085 | description=('Adjust speed of animation, relative to scene frame rate'), 1086 | min=0.001, 1087 | default=1) 1088 | loopFrames = IntProperty(name='Loop Frames', 1089 | description='Number of frames to make the animation loop for, zero is disabled', 1090 | min=0, 1091 | default=0) 1092 | 1093 | makeMesh = BoolProperty(name='Make Mesh', 1094 | description='Convert curves to mesh, uses skin modifier, enables armature simplification', 1095 | default=False) 1096 | armLevels = IntProperty(name='Armature Levels', 1097 | description='Number of branching levels to make bones for, 0 is all levels', 1098 | min=0, 1099 | default=2) 1100 | boneStep = IntVectorProperty(name='Bone Length', 1101 | description='Number of stem segments per bone', 1102 | min=1, 1103 | default=[1, 1, 1, 1], 1104 | size=4) 1105 | 1106 | @classmethod 1107 | def poll(cls, context): 1108 | return context.mode == 'OBJECT' 1109 | 1110 | def draw(self, context): 1111 | 1112 | layout = self.layout 1113 | 1114 | layout.prop(self, 'do_update', icon='CURVE_DATA') 1115 | 1116 | box = layout.box() 1117 | box.label("Geometry:") 1118 | 1119 | row = box.row() 1120 | row.menu('sapling.presetmenu', text='Load Preset') 1121 | 1122 | box.prop(self, 'seed') 1123 | box.prop(self, 'numTrees') 1124 | 1125 | box.prop(self, 'bevel') 1126 | 1127 | row = box.row() 1128 | row.prop(self, 'bevelRes') 1129 | row.prop(self, 'resU') 1130 | 1131 | box.label("Tree Scale:") 1132 | row = box.row() 1133 | row.prop(self, 'scale') 1134 | row.prop(self, 'scaleV') 1135 | 1136 | box = layout.box() 1137 | box.label("Leaves:") 1138 | 1139 | box.prop(self, 'showLeaves') 1140 | box.prop(self, 'leafShape') 1141 | box.prop(self, 'leafDupliObj') 1142 | row = box.row() 1143 | row.label("Leaf Object Axes:") 1144 | row.prop(self, 'leafObjZ') 1145 | row.prop(self, 'leafObjY') 1146 | 1147 | #box.prop(self, 'leaves') 1148 | box.prop(self, 'leafScale') 1149 | 1150 | box = layout.box() 1151 | box.label("Armature and Animation:") 1152 | 1153 | row = box.row() 1154 | row.prop(self, 'useArm') 1155 | row.prop(self, 'previewArm') 1156 | 1157 | row = box.row() 1158 | row.prop(self, 'armAnim') 1159 | row.prop(self, 'leafAnim') 1160 | 1161 | box.prop(self, 'frameRate') 1162 | box.prop(self, 'loopFrames') 1163 | 1164 | box.label("") 1165 | box.prop(self, 'makeMesh') 1166 | box.label("Armature Simplification:") 1167 | box.prop(self, 'armLevels') 1168 | box.prop(self, 'boneStep') 1169 | 1170 | 1171 | def execute(self, context): 1172 | # Ensure the use of the global variables 1173 | global settings, useSet 1174 | # If we need to set the properties from a preset then do it here 1175 | #presetAsDict 1176 | if useSet: 1177 | for a, b in settings.items(): 1178 | setattr(self, a, b) 1179 | useSet = False 1180 | if self.do_update: 1181 | #loop for multiple trees 1182 | initSeed = self.seed 1183 | for n in range(self.numTrees): 1184 | setattr(self, 'seed', self.seed + n) 1185 | space = 6 1186 | grid = ceil(self.numTrees ** .5) 1187 | x = (n // grid) * space 1188 | y = (n % grid) * space 1189 | bpy.context.scene.cursor_location = (x, y, 0) 1190 | addTree(self) 1191 | setattr(self, 'seed', initSeed) 1192 | self.do_update = False 1193 | return {'FINISHED'} 1194 | else: 1195 | return {'PASS_THROUGH'} 1196 | 1197 | def invoke(self, context, event): 1198 | # global settings, useSet 1199 | # useSet = True 1200 | bpy.ops.sapling.importdata(filename = "Default Tree.py") 1201 | return self.execute(context) 1202 | 1203 | 1204 | def menu_func(self, context): 1205 | self.layout.operator(AddTree.bl_idname, text="Add Tree 3.1", icon='PLUGIN') 1206 | def menu_func2(self, context): 1207 | self.layout.operator(AddMultipleTrees.bl_idname, text="Add Multiple Trees", icon='PLUGIN') 1208 | 1209 | 1210 | def register(): 1211 | bpy.utils.register_module(__name__) 1212 | 1213 | bpy.types.INFO_MT_curve_add.append(menu_func) 1214 | bpy.types.INFO_MT_curve_add.append(menu_func2) 1215 | 1216 | 1217 | def unregister(): 1218 | bpy.utils.unregister_module(__name__) 1219 | 1220 | bpy.types.INFO_MT_curve_add.remove(menu_func) 1221 | bpy.types.INFO_MT_curve_add.remove(menu_func2) 1222 | 1223 | if __name__ == "__main__": 1224 | register() 1225 | -------------------------------------------------------------------------------- /sapling_4/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | #====================== BEGIN GPL LICENSE BLOCK ====================== 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software Foundation, 17 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | # 19 | #======================= END GPL LICENSE BLOCK ======================== 20 | 21 | bl_info = { 22 | "name": "Sapling_4", 23 | "author": "Andrew Hale (TrumanBlending), modified by Aaron Buchler 2015-2020", 24 | "version": (0, 4, 0), 25 | "blender": (2, 80, 0), 26 | "location": "View3D > Add > Curve", 27 | "description": "Adds a parametric tree.", 28 | "category": "Add Curve"} 29 | ##"Originally based on the method presented by Jason Weber & Joseph Penn in their paper 'Creation and Rendering of Realistic Trees'."## 30 | 31 | if "bpy" in locals(): 32 | import importlib 33 | importlib.reload(utils) 34 | else: 35 | from sapling_4 import utils 36 | 37 | import bpy 38 | import time 39 | import os 40 | import ast 41 | 42 | #import cProfile 43 | 44 | from mathutils import * 45 | from math import pi, sin, degrees, radians, atan2, copysign, ceil 46 | from random import random, uniform, seed, choice, getstate, setstate 47 | from bpy.props import * 48 | 49 | from sapling_4.utils import * 50 | 51 | useSet = False 52 | is_first = False 53 | 54 | shapeList = [('0', 'Conical (0)', 'Shape = 0'), 55 | ('1', 'Spherical (1)', 'Shape = 1'), 56 | ('2', 'Hemispherical (2)', 'Shape = 2'), 57 | ('3', 'Cylindrical (3)', 'Shape = 3'), 58 | ('4', 'Tapered Cylindrical (4)', 'Shape = 4'), 59 | ('5', 'Flame (5)', 'Shape = 5'), 60 | ('6', 'Inverse Conical (6)', 'Shape = 6'), 61 | ('7', 'Tend Flame (7)', 'Shape = 7')] 62 | 63 | shapeList3 = [('0', 'Conical', ''), 64 | ('6', 'Inverse Conical', ''), 65 | ('1', 'Spherical', ''),# 66 | ('2', 'Hemispherical', ''),# 67 | ('3', 'Cylindrical', ''), 68 | ('4', 'Tapered Cylindrical', ''), 69 | ('10', 'Inverse Tapered Cylindrical', ''), 70 | ('5', 'Flame', ''),# 71 | ('7', 'Tend Flame', ''), 72 | ('8', 'Custom Shape', '')] 73 | 74 | shapeList4 = [('0', 'Conical', ''), 75 | ('6', 'Inverse Conical', ''), 76 | ('1', 'Spherical', ''), 77 | ('2', 'Hemispherical', ''), 78 | ('3', 'Cylindrical', ''), 79 | ('4', 'Tapered Cylindrical', ''), 80 | ('10', 'Inverse Tapered Cylindrical', ''), 81 | ('5', 'Flame', ''), 82 | ('7', 'Tend Flame', '')] 83 | 84 | leaftypes = [('0', 'Rotated Alternate', 'leaves rotate around the stem and face upwards'), 85 | ('1', 'Rotated Opposite', 'pairs of leaves rotate around the stem and face upwards'), 86 | ('2', 'Alternate', 'leaves sprout alternately from each side of the stem, uses rotate angle'), 87 | ('3', 'Opposite', 'pairs of leaves sprout from opposite sides of stem, uses rotate angle'), 88 | ('4', 'Palmately Compound', 'multiple leaves radiating from stem tip, uses rotate angle for spread angle'), 89 | ('5', 'Radial', 'leaves rotate around the stem (for needles)')] 90 | 91 | axes = [(("+0"), "X", ""), 92 | (("+1"), "Y", ""), 93 | (("+2"), "Z", ""), 94 | (("-0"), "-X", ""), 95 | (("-1"), "-Y", ""), 96 | (("-2"), "-Z", "")] 97 | 98 | 99 | handleList = [('0', 'Auto', 'Auto'), 100 | ('1', 'Vector', 'Vector')] 101 | 102 | settings = [('0', 'Geometry', 'Geometry'), 103 | ('1', 'Branch Radius', 'Branch Radius'), 104 | ('2', 'Branch Splitting', 'Branch Splitting'), 105 | ('3', 'Branch Growth', 'Branch Growth'), 106 | ('5', 'Leaves', 'Leaves'), 107 | ('6', 'Armature', 'Armature')] 108 | 109 | branchmodes = [("original", "Original", "rotate around each branch"), 110 | ("rotate", "Rotate", "evenly distribute branches to point outward from center of tree"), 111 | ("distance", "Distance", "remove overlapping branches")] 112 | 113 | attachmenttypes = [('0','Alternate', ''), ('1','Opposite', '')] 114 | 115 | 116 | def getPresetpaths(): 117 | """Return paths for both local and user preset folders""" 118 | userDir = os.path.join(bpy.utils.script_path_user(), 'presets', 'operator', 'sapling_4') 119 | 120 | if os.path.isdir(userDir): 121 | pass 122 | else: 123 | os.makedirs(userDir) 124 | 125 | script_file = os.path.realpath(__file__) 126 | directory = os.path.dirname(script_file) 127 | localDir = os.path.join(directory, "presets") 128 | 129 | return (localDir, userDir) 130 | 131 | 132 | class ExportData(bpy.types.Operator): 133 | """This operator handles writing presets to file""" 134 | bl_idname = 'sapling.exportdata' 135 | bl_label = 'Export Preset' 136 | 137 | data: StringProperty() 138 | 139 | def execute(self, context): 140 | # Unpack some data from the input 141 | data, filename, overwrite = eval(self.data) 142 | 143 | fpath1 = os.path.join(getPresetpaths()[0], filename + '.py') 144 | fpath2 = os.path.join(getPresetpaths()[1], filename + '.py') 145 | 146 | if os.path.exists(fpath1): 147 | # If it exists in built-in presets then report an error 148 | self.report({'ERROR_INVALID_INPUT'}, 'Can\'t have same name as built-in preset') 149 | return {'CANCELLED'} 150 | elif (not os.path.exists(fpath2)) or (os.path.exists(fpath2) and overwrite): 151 | #if (it does not exist) or (exists and overwrite) then write file 152 | if data: 153 | # If it doesn't exist, create the file with the required data 154 | f = open(os.path.join(getPresetpaths()[1], filename + '.py'), 'w') 155 | f.write(data) 156 | f.close() 157 | return {'FINISHED'} 158 | else: 159 | return {'CANCELLED'} 160 | else: 161 | # If it exists then report an error 162 | self.report({'ERROR_INVALID_INPUT'}, 'Preset Already Exists') 163 | return {'CANCELLED'} 164 | 165 | 166 | class ImportData(bpy.types.Operator): 167 | """This operator handles importing existing presets""" 168 | bl_idname = 'sapling.importdata' 169 | bl_label = 'Import Preset' 170 | 171 | filename: StringProperty() 172 | 173 | def execute(self, context): 174 | # Make sure the operator knows about the global variables 175 | global settings, useSet, is_first 176 | # Read the preset data into the global settings 177 | try: 178 | f = open(os.path.join(getPresetpaths()[0], self.filename), 'r') 179 | except (FileNotFoundError, IOError): 180 | f = open(os.path.join(getPresetpaths()[1], self.filename), 'r') 181 | settings = f.readline() 182 | f.close() 183 | #print(settings) 184 | settings = ast.literal_eval(settings) 185 | 186 | #use old attractup 187 | if type(settings['attractUp']) == float: 188 | atr = settings['attractUp'] 189 | settings['attractUp'] = [0, 0, atr, atr] 190 | 191 | #use old leaf rotations 192 | if 'leafDownAngle' not in settings: 193 | l = settings['levels'] 194 | settings['leafDownAngle'] = settings['downAngle'][min(l, 3)] 195 | settings['leafDownAngleV'] = settings['downAngleV'][min(l, 3)] 196 | settings['leafRotate'] = settings['rotate'][min(l, 3)] 197 | settings['leafRotateV'] = settings['rotateV'][min(l, 3)] 198 | 199 | #use old leaf settings 200 | if 'leafType' not in settings: 201 | settings['leafType'] = '0' 202 | if settings['leaves'] < 0: 203 | settings['leaves'] = abs(settings['leaves']) 204 | settings['leafType'] = '4' 205 | if settings['leafRotate'] < 1: 206 | settings['leafType'] = '2' 207 | 208 | if 'noTip' not in settings: 209 | settings['noTip'] = False 210 | 211 | #zero curveback 212 | if 'curveBack' in settings: 213 | settings['curveBack'] = [0, 0, 0, 0] 214 | 215 | # Set the flag to use the settings 216 | useSet = True 217 | is_first = True 218 | return {'FINISHED'} 219 | 220 | 221 | def presetAsDict(filename): 222 | try: 223 | f = open(os.path.join(getPresetpaths()[0], filename), 'r') 224 | except (FileNotFoundError, IOError): 225 | f = open(os.path.join(getPresetpaths()[1], filename), 'r') 226 | settings = f.readline() 227 | f.close() 228 | settings = ast.literal_eval(settings) 229 | return settings 230 | 231 | 232 | class PresetMenu(bpy.types.Menu): 233 | """Create the preset menu by finding all preset files 234 | in the preset directory""" 235 | bl_idname = "SAPLING_MT_preset" #was sapling.presetmenu 236 | bl_label = "Presets" 237 | 238 | def draw(self, context): 239 | # Get all the sapling presets 240 | presets = [a for a in os.listdir(getPresetpaths()[0]) if a[-3:] == '.py'] 241 | presetsUser = [a for a in os.listdir(getPresetpaths()[1]) if a[-3:] == '.py'] 242 | layout = self.layout 243 | # Append all to the menu 244 | if "PreviousSettings.py" in presetsUser: 245 | p = "PreviousSettings.py" 246 | layout.operator("sapling.importdata", text=p[:-3]).filename = p 247 | presetsUser.remove("PreviousSettings.py") 248 | layout.separator() 249 | for p in presets: 250 | layout.operator("sapling.importdata", text=p[:-3]).filename = p 251 | layout.separator() 252 | for p in presetsUser: 253 | layout.operator("sapling.importdata", text=p[:-3]).filename = p 254 | 255 | 256 | class AddTree(bpy.types.Operator): 257 | bl_idname = "curve.tree_add" 258 | bl_label = "Sapling: Add Tree" 259 | bl_options = {'REGISTER', 'UNDO'} 260 | 261 | def objectList(self, context): 262 | objects = [] 263 | bObjects = bpy.data.objects 264 | for obj in bObjects: 265 | if (obj.type in ['MESH', 'CURVE', 'SURFACE']) and (obj.name not in ['tree', 'leaves']): 266 | objects.append((obj.name, obj.name, "")) 267 | 268 | return objects 269 | 270 | def update_tree(self, context): 271 | self.do_update = True 272 | 273 | def update_leaves(self, context): 274 | if self.showLeaves: 275 | self.do_update = True 276 | else: 277 | self.do_update = False 278 | 279 | def no_update_tree(self, context): 280 | self.do_update = False 281 | 282 | do_update: BoolProperty(name='Do Update', 283 | default=True, options={'HIDDEN'}) 284 | 285 | chooseSet: EnumProperty(name='Settings', 286 | description='Choose the settings to modify', 287 | items=settings, 288 | default='0', update=no_update_tree) 289 | 290 | bevel: BoolProperty(name='Bevel', 291 | description='Whether the curve is beveled', 292 | default=False, update=update_tree) 293 | showLeaves: BoolProperty(name='Show Leaves', 294 | description='Whether the leaves are shown', 295 | default=False, update=update_tree) 296 | useArm: BoolProperty(name='Use Armature', 297 | description='Whether the armature is generated', 298 | default=False, update=update_tree) 299 | seed: IntProperty(name='Random Seed', 300 | description='The seed of the random number generator', 301 | default=0, update=update_tree) 302 | handleType: EnumProperty(name='Handle Type', 303 | description='The type of bezier curve handles', 304 | items=handleList, 305 | default='0', update=update_tree) 306 | bevelRes: IntProperty(name='Bevel Resolution', 307 | description='The bevel resolution of the curves', 308 | min=0, 309 | max=32, 310 | default=0, update=update_tree) 311 | resU: IntProperty(name='Curve Resolution', 312 | description='The resolution along the curves', 313 | min=1, 314 | default=4, update=update_tree) 315 | 316 | levels: IntProperty(name='Levels', 317 | description='Number of recursive branches', 318 | min=1, 319 | max=6, 320 | soft_max=4, 321 | default=3, update=update_tree) 322 | length: FloatVectorProperty(name='Length', 323 | description='The relative lengths of each branch level', 324 | min=0.000001, 325 | default=[1, 0.3, 0.6, 0.45], 326 | size=4, update=update_tree) 327 | lengthV: FloatVectorProperty(name='Length Variation', 328 | description='Branch and split length variations for each level', 329 | min=0.0, 330 | max=1.0, 331 | default=[0, 0, 0, 0], 332 | size=4, update=update_tree) 333 | taperCrown: FloatProperty(name='Taper Crown', 334 | description='Shorten trunk splits toward outside of tree', 335 | min=0.0, 336 | soft_max=1.0, 337 | default=0, update=update_tree) 338 | branches: IntVectorProperty(name='Branches', 339 | description='The number of branches grown at each level', 340 | min=0, 341 | default=[50, 30, 10, 10], 342 | size=4, update=update_tree) 343 | curveRes: IntVectorProperty(name='Curve Resolution', 344 | description='The number of segments on each branch', 345 | min=1, 346 | soft_max=16, 347 | default=[8, 5, 3, 1], 348 | size=4, update=update_tree) 349 | curve: FloatVectorProperty(name='Curvature', 350 | description='The angle of the end of the branch', 351 | default=[0, -40, -40, 0], 352 | size=4, update=update_tree) 353 | curveV: FloatVectorProperty(name='Curvature Variation', 354 | description='Variation of the curvature', 355 | default=[20, 50, 75, 0], 356 | size=4, update=update_tree) 357 | curveBack: FloatVectorProperty(name='Back Curvature', 358 | description='Curvature for the second half of a branch', 359 | default=[0, 0, 0, 0], 360 | size=4, update=update_tree) 361 | baseSplits: IntProperty(name='Base Splits', 362 | description='Number of trunk splits at its base', 363 | min=0, 364 | default=0, update=update_tree) 365 | segSplits: FloatVectorProperty(name='Segment Splits', 366 | description='Number of splits per segment', 367 | min=0, 368 | soft_max=1, 369 | max=3, 370 | default=[0, 0, 0, 0], 371 | size=4, update=update_tree) 372 | splitByLen: BoolProperty(name='Split relative to length', 373 | description='Split proportional to branch length', 374 | default=False, update=update_tree) 375 | rMode: EnumProperty(name="", #"Branching Mode" 376 | description='Branching and Rotation Mode', 377 | items=branchmodes, 378 | default="rotate", update=update_tree) 379 | splitStraight: FloatProperty(name="Split Straight", 380 | description="Straightness of trunk branch splits", 381 | min=0.0, 382 | max=1.0, 383 | default=0, update=update_tree) 384 | splitLength: FloatProperty(name="Split Length", 385 | description="Length of trunk branch splits, (similar to length variation but not random)", 386 | min=0.0, 387 | max=1.0, 388 | default=0, update=update_tree) 389 | splitAngle: FloatVectorProperty(name='Split Angle', 390 | description='Angle of branch splitting', 391 | default=[0, 0, 0, 0], 392 | size=4, update=update_tree) 393 | splitAngleV: FloatVectorProperty(name='Split Angle Variation', 394 | description='Variation in the split angle', 395 | default=[0, 0, 0, 0], 396 | size=4, update=update_tree) 397 | scale: FloatProperty(name='Scale', 398 | description='The tree scale', 399 | min=0.0, 400 | default=13.0, update=update_tree) 401 | scaleV: FloatProperty(name='Scale Variation', 402 | description='The variation in the tree scale', 403 | default=3.0, update=update_tree) 404 | attractUp: FloatVectorProperty(name='Vertical Attraction', 405 | description='Branch upward attraction', 406 | default=[0, 0, 0, 0], 407 | size=4, update=update_tree) 408 | attractOut: FloatVectorProperty(name='Outward Attraction', 409 | description='Branch outward attraction', 410 | default=[0, 0, 0, 0], 411 | min=0.0, 412 | max=1.0, 413 | size=4, update=update_tree) 414 | shape: EnumProperty(name='', #Shape 415 | description='The overall shape of the tree', 416 | items=shapeList3, 417 | default='7', update=update_tree) 418 | shapeS: EnumProperty(name='', #Secondary Branches Shape 419 | description='The shape of secondary splits', 420 | items=shapeList4, 421 | default='4', update=update_tree) 422 | customShape: FloatVectorProperty(name='',#Custom Shape 423 | description='Branch Length at \n(Base, Middle, Middle Position, Top)', 424 | size=4, 425 | min=.01, 426 | max=1, 427 | default=[.5, 1.0, .3, .5], update=update_tree) 428 | branchDist: FloatProperty(name='Branch Distribution', 429 | description='Adjust branch spacing to put more branches at the top or bottom of the tree', 430 | min=0.1, 431 | soft_max=10, 432 | default=1.0, update=update_tree) 433 | nrings: IntProperty(name='Whorls', 434 | description='number of whorls', 435 | min=0, 436 | default=0, update=update_tree) 437 | baseSize: FloatProperty(name='', # 'Trunk Height' 438 | description='Fraction of trunk with no branches (Base Size)', 439 | min=0.0, 440 | max=1.0, 441 | default=0.4, update=update_tree) 442 | baseSize_s: FloatProperty(name='', #Secondary Start Length 443 | description='Fraction of 2nd and higher levels with no branches', 444 | min=0.0, 445 | max=1.0, 446 | default=0.25, update=update_tree) 447 | leafBaseSize: FloatProperty(name='Leaf Start Length', 448 | description='Fraction of stem length with no leaves', 449 | min=0.0, 450 | max=1.0, 451 | default=0.20, update=update_tree) 452 | splitHeight: FloatProperty(name='Split Height', 453 | description='Fraction of tree height with no splits', 454 | min=0.0, 455 | max=1.0, 456 | default=0.2, update=update_tree) 457 | splitBias: FloatProperty(name='Split Bias', 458 | description='Put more splits at the top or bottom of the tree', 459 | soft_min=-2.0, 460 | soft_max=2.0, 461 | default=0.0, update=update_tree) 462 | ratio: FloatProperty(name='Ratio', 463 | description='Ratio of tree scale to base radius', 464 | min=0.0, 465 | default=0.015, update=update_tree) 466 | minRadius: FloatProperty(name='Minimum Radius', 467 | description='Minimum branch Radius', 468 | min=0.0, 469 | default=0.0, update=update_tree) 470 | closeTip: BoolProperty(name='Close Tip', 471 | description='Set radius at branch tips to zero', 472 | default=False, update=update_tree) 473 | rootFlare: FloatProperty(name='Root Flare', 474 | description='Root radius factor', 475 | min=1.0, 476 | default=1.0, update=update_tree) 477 | splitRadiusRatio: FloatProperty(name='Split Radius Ratio', 478 | description='Reduce radius after branch splits, (0 is auto)', 479 | min=0.0, 480 | max=1.0, 481 | default=0.75, update=update_tree) 482 | autoTaper: BoolProperty(name='Auto Taper', 483 | description='Calculate taper automaticly based on branch lengths', 484 | default=True, update=update_tree) 485 | taper: FloatVectorProperty(name='Taper', 486 | description='The fraction of tapering on each branch', 487 | min=0.0, 488 | max=1.0, 489 | default=[1, 1, 1, 1], 490 | size=4, update=update_tree) 491 | noTip: BoolProperty(name='No branch at stem tip', 492 | description='Useful for non-typical / abstract trees', 493 | default=False, update=update_tree) 494 | radiusTweak: FloatVectorProperty(name='Tweak Radius', 495 | description='multiply radius by this factor', 496 | min=0.0, 497 | max=1.0, 498 | default=[1, 1, 1, 1], 499 | size=4, update=update_tree) 500 | ratioPower: FloatProperty(name='Radius Ratio Power', 501 | description='Power which defines the radius of a branch compared to the radius of the branch it grew from', 502 | min=0.0, 503 | soft_min=1.0, 504 | default=1.2, update=update_tree) 505 | downAngle: FloatVectorProperty(name='Down Angle', 506 | description='The angle between a new branch and the one it grew from', 507 | default=[90, 60, 45, 45], 508 | size=4, update=update_tree) 509 | downAngleV: FloatVectorProperty(name='Down Angle Variation', 510 | description='Angle to decrease Down Angle by towards end of parent branch \n(negative values add random variation)', 511 | default=[0, -50, 10, 10], 512 | size=4, update=update_tree) 513 | useOldDownAngle: BoolProperty(name='Use old down angle variation', 514 | default=False, update=update_tree) 515 | useParentAngle: BoolProperty(name='Use parent angle', 516 | description='(first level) Rotate branch to match parent branch', 517 | default=True, update=update_tree) 518 | rotate: FloatVectorProperty(name='Rotate Angle', 519 | description='The angle of a new branch around the one it grew from \n(negative values make branches rotate opposite from the previous one)', 520 | default=[137.5, 137.5, 137.5, 137.5], 521 | size=4, update=update_tree) 522 | rotateV: FloatVectorProperty(name='Rotate Angle Variation', 523 | description='Variation in the rotate angle', 524 | default=[0, 0, 0, 0], 525 | size=4, update=update_tree) 526 | scale0: FloatProperty(name='Radius Scale', 527 | description='The scale of the trunk radius', 528 | min=0.0, 529 | default=1.0, update=update_tree) 530 | scaleV0: FloatProperty(name='Radius Scale Variation', 531 | description='Variation in the radius scale', 532 | min=0.0, 533 | max=1.0, 534 | default=0.2, update=update_tree) 535 | attachment: EnumProperty(name='Attachment', 536 | description='Type of branch arrangment', 537 | items=attachmenttypes, 538 | default='0', update=update_tree) 539 | leaves: IntProperty(name='Leaves', 540 | description='Maximum number of leaves per branch', 541 | min=0, 542 | default=25, update=update_tree) 543 | leafType: EnumProperty(name='Leaf Type', 544 | description='Type of leaf arrangment', 545 | items=leaftypes, 546 | default='0', update=update_leaves) #update_leaves update_tree 547 | 548 | leafDownAngle: FloatProperty(name='Leaf Down Angle', 549 | description='The angle between a new leaf and the branch it grew from', 550 | default=45, update=update_leaves) 551 | leafDownAngleV: FloatProperty(name='Leaf Down Angle Variation', 552 | description='Angle to decrease Down Angle by towards end of parent branch', 553 | min=0, 554 | default=10, update=update_tree) 555 | leafRotate: FloatProperty(name='Leaf Rotate Angle', 556 | description='The rotate angle for Alternate and Opposite leaves', 557 | default=90, update=update_tree) 558 | leafRotateV: FloatProperty(name='Rotation Variation', 559 | description='Add randomness to leaf orientation', 560 | default=0.0, update=update_leaves) 561 | 562 | leafObjZ: EnumProperty(name='', 563 | description='leaf tip axis', 564 | items=axes, 565 | default="+2", update=update_leaves) 566 | leafObjY: EnumProperty(name='', 567 | description='leaf top axis', 568 | items=axes, 569 | default="+1", update=update_leaves) 570 | #leafObjX: EnumProperty(name='', 571 | # description='leaf side axis', 572 | # items=axes, 573 | # default="+0", update=update_leaves) 574 | 575 | leafScale: FloatProperty(name='Leaf Scale', 576 | description='The scaling applied to the whole leaf', 577 | min=0.0, 578 | default=0.17, update=update_leaves) 579 | leafScaleX: FloatProperty(name='Leaf Scale X', 580 | description='The scaling applied to the x direction of the leaf', 581 | min=0.0, 582 | default=1.0, update=update_leaves) 583 | leafScaleT: FloatProperty(name='Leaf Scale Taper', 584 | description='scale leaves toward the tip or base of the patent branch', 585 | min=-1.0, 586 | max=1.0, 587 | default=0.0, update=update_leaves) 588 | leafScaleV: FloatProperty(name='Leaf Scale Variation', 589 | description='randomize leaf scale', 590 | min=0.0, 591 | max=1.0, 592 | default=0.0, update=update_leaves) 593 | leafShape: EnumProperty(name='Leaf Shape', 594 | description='The shape of the leaves', 595 | items=(('hex', 'Hexagonal', '0'), ('rect', 'Rectangular', '1'), ('dFace', 'DupliFaces', '2'), ('dVert', 'DupliVerts', '3')), 596 | default='hex', update=update_leaves) 597 | leafDupliObj: EnumProperty(name='Leaf Object', 598 | description='Object to use for leaf instancing if Leaf Shape is DupliFaces or DupliVerts', 599 | items=objectList, 600 | update=update_leaves) 601 | 602 | leafangle: FloatProperty(name='Leaf Angle', 603 | description='Leaf vertical attraction', 604 | default=0.0, update=update_leaves) 605 | leafDist: EnumProperty(name='Leaf Distribution', 606 | description='The way leaves are distributed on branches', 607 | items=shapeList4, 608 | default='6', update=update_tree) 609 | 610 | armAnim: BoolProperty(name='Armature Animation', 611 | description='Whether animation is added to the armature', 612 | default=False, update=update_tree) 613 | previewArm: BoolProperty(name='Fast Preview', 614 | description=('Disable armature modifier, hide tree, and set bone display to wire, for fast playback \n' 615 | 'If Make Mesh is enabled: \nDisable skin modifier, hide curve tree and armature'), 616 | default=False, update=update_tree) 617 | leafAnim: BoolProperty(name='Leaf Animation', 618 | description='Whether animation is added to the leaves', 619 | default=False, update=update_tree) 620 | frameRate: FloatProperty(name='Animation Speed', 621 | description='Adjust speed of animation, relative to scene frame rate', 622 | min=0.001, 623 | default=1, update=update_tree) 624 | loopFrames: IntProperty(name='Loop Frames', 625 | description='Number of frames to make the animation loop for, zero is disabled', 626 | min=0, 627 | default=0, update=update_tree) 628 | 629 | # windSpeed: FloatProperty(name='Wind Speed', 630 | # description='The wind speed to apply to the armature', 631 | # default=2.0, update=update_tree) 632 | # windGust: FloatProperty(name='Wind Gust', 633 | # description='The greatest increase over Wind Speed', 634 | # default=0.0, update=update_tree) 635 | 636 | wind: FloatProperty(name='Overall Wind Strength', 637 | description='The intensity of the wind to apply to the armature', 638 | default=1.0, update=update_tree) 639 | 640 | gust: FloatProperty(name='Wind Gust Strength', 641 | description='The amount of directional movement, (from the positive Y direction)', 642 | default=1.0, update=update_tree) 643 | 644 | gustF: FloatProperty(name='Wind Gust Fequency', 645 | description='The Fequency of directional movement', 646 | default=0.075, update=update_tree) 647 | 648 | af1: FloatProperty(name='Amplitude', 649 | description='Multiplier for noise amplitude', 650 | default=1.0, update=update_tree) 651 | af2: FloatProperty(name='Frequency', 652 | description='Multiplier for noise fequency', 653 | default=1.0, update=update_tree) 654 | af3: FloatProperty(name='Randomness', 655 | description='Random offset in noise', 656 | default=4.0, update=update_tree) 657 | 658 | makeMesh: BoolProperty(name='Make Mesh', 659 | description='Convert curves to mesh, uses skin modifier, enables armature simplification', 660 | default=False, update=update_tree) 661 | armLevels: IntProperty(name='Armature Levels', 662 | description='Number of branching levels to make bones for, 0 is all levels', 663 | min=0, 664 | default=2, update=update_tree) 665 | boneStep: IntVectorProperty(name='Bone Length', 666 | description='Number of stem segments per bone', 667 | min=1, 668 | default=[1, 1, 1, 1], 669 | size=4, update=update_tree) 670 | matIndex: IntVectorProperty(name='Material Index', 671 | description='Material index for each split level (curves only)', 672 | min=0, 673 | max=3, 674 | default=[0, 0, 0, 0], 675 | size=4, update=update_tree) 676 | 677 | presetName: StringProperty(name='Preset Name', 678 | description='The name of the preset to be saved', 679 | default='', 680 | subtype='FILE_NAME', update=no_update_tree) 681 | limitImport: BoolProperty(name='Limit Import', 682 | description='Limited imported tree to 2 levels & no leaves for speed', 683 | default=True, update=no_update_tree) 684 | overwrite: BoolProperty(name='Overwrite', 685 | description='When checked, overwrite existing preset files when saving', 686 | default=False, update=no_update_tree) 687 | 688 | @classmethod 689 | def poll(cls, context): 690 | return context.mode == 'OBJECT' 691 | 692 | def draw(self, context): 693 | 694 | layout = self.layout 695 | 696 | layout.prop(self, 'chooseSet') 697 | 698 | if self.chooseSet == '0': 699 | box = layout.box() 700 | box.label(text="Geometry:") 701 | row = box.row() 702 | row.prop(self, 'bevel') 703 | row.prop(self, 'makeMesh') 704 | 705 | row = box.row() 706 | row.prop(self, 'bevelRes') 707 | row.prop(self, 'resU') 708 | 709 | box.prop(self, 'handleType') 710 | row = box.row() 711 | row.prop(self, 'matIndex') 712 | 713 | #box.prop(self, 'shape') 714 | #row = box.row() 715 | #row.prop(self, 'customShape') 716 | #box.prop(self, 'shapeS') 717 | 718 | #box.label(text="") 719 | #box.prop(self, 'branchDist') 720 | #box.prop(self, 'nrings') 721 | 722 | box.label(text="") 723 | box.prop(self, 'seed') 724 | 725 | box.label(text="Tree Scale:") 726 | row = box.row() 727 | row.prop(self, 'scale') 728 | row.prop(self, 'scaleV') 729 | 730 | # Here we create a dict of all the properties. 731 | # Unfortunately as_keyword doesn't work with vector properties, 732 | # so we need something custom. This is it 733 | data = [] 734 | for a, b in (self.as_keywords(ignore=("chooseSet", "presetName", "limitImport", "do_update", "overwrite", "leafDupliObj"))).items(): 735 | # If the property is a vector property then add the slice to the list 736 | try: 737 | len(b) 738 | data.append((a, b[:])) 739 | # Otherwise, it is fine so just add it 740 | except: 741 | data.append((a, b)) 742 | # Create the dict from the list 743 | data = dict(data) 744 | 745 | row = box.row() 746 | row.prop(self, 'presetName') 747 | # Send the data dict and the file name to the exporter 748 | row.operator('sapling.exportdata').data = repr([repr(data), self.presetName, self.overwrite]) 749 | row = box.row() 750 | row.label(text=" ") 751 | row.prop(self, 'overwrite') 752 | row = box.row() 753 | row.menu('SAPLING_MT_preset', text='Load Preset') 754 | row.prop(self, 'limitImport') 755 | 756 | elif self.chooseSet == '1': 757 | box = layout.box() 758 | box.label(text="Branch Radius:") 759 | 760 | row = box.row() 761 | row.prop(self, 'bevel') 762 | row.prop(self, 'bevelRes') 763 | 764 | box.prop(self, 'ratio') 765 | 766 | box.prop(self, 'minRadius') 767 | box.prop(self, 'closeTip') 768 | box.prop(self, 'rootFlare') 769 | box.prop(self, 'splitRadiusRatio') 770 | 771 | box.label(text="") 772 | box.label(text="Other:") 773 | 774 | row = box.row() 775 | row.prop(self, 'autoTaper') 776 | row.prop(self, 'noTip') 777 | 778 | row = box.row() 779 | row.prop(self, 'scale0') 780 | row.prop(self, 'scaleV0') 781 | box.prop(self, 'ratioPower') 782 | 783 | split = box.split() 784 | col = split.column() 785 | col.prop(self, 'taper') 786 | col = split.column() 787 | col.prop(self, 'radiusTweak') 788 | 789 | elif self.chooseSet == '2': 790 | box = layout.box() 791 | box.label(text="Branch Splitting:") 792 | box.prop(self, 'levels') 793 | box.prop(self, 'baseSplits') 794 | 795 | row = box.row() 796 | row.prop(self, 'splitHeight') 797 | row.prop(self, 'splitBias') 798 | 799 | row = box.row() 800 | split = row.split() 801 | col = split.column() 802 | col.label(text="Start Length:") 803 | col = split.column() 804 | col.prop(self, 'baseSize') 805 | col.prop(self, 'baseSize_s') 806 | 807 | #box.label(text="") 808 | box.prop(self, 'branchDist') 809 | box.prop(self, 'nrings') 810 | 811 | split = box.split() 812 | 813 | col = split.column() 814 | col.prop(self, 'branches') 815 | col.prop(self, 'splitAngle') 816 | col.prop(self, 'rotate') 817 | #col.prop(self, 'attractOut') 818 | 819 | col.label(text="Branch Attachment:") 820 | row = col.row() 821 | row.prop(self, 'attachment', expand=True) 822 | col.prop(self, 'splitByLen') 823 | #col.prop(self, 'taperCrown') 824 | 825 | col = split.column() 826 | col.prop(self, 'segSplits') 827 | col.prop(self, 'splitAngleV') 828 | col.prop(self, 'rotateV') 829 | 830 | col.label(text="Branching Mode:") 831 | col.prop(self, 'rMode') 832 | col.prop(self, 'splitStraight') 833 | col.prop(self, 'splitLength') 834 | 835 | 836 | box.column().prop(self, 'curveRes') 837 | 838 | elif self.chooseSet == '3': 839 | box = layout.box() 840 | box.label(text="Branch Growth:") 841 | 842 | #box.prop(self, 'taperCrown') 843 | 844 | row = box.row() 845 | split = row.split() 846 | col = split.column() 847 | #col.prop(self, 'length') 848 | col.label(text="Shape:") 849 | col = split.column() 850 | col.prop(self, 'shape') 851 | col.prop(self, 'shapeS') 852 | 853 | box.label(text="Custom Shape:") 854 | 855 | row = box.row() 856 | row.prop(self, 'customShape') 857 | 858 | split = box.split() 859 | 860 | col = split.column() 861 | col.prop(self, 'length') 862 | col.prop(self, 'downAngle') 863 | col.prop(self, 'curve') 864 | #col.prop(self, 'curveBack') 865 | col.prop(self, 'attractOut') 866 | 867 | col = split.column() 868 | 869 | col.prop(self, 'lengthV') 870 | col.prop(self, 'downAngleV') 871 | col.prop(self, 'curveV') 872 | col.prop(self, 'attractUp') 873 | 874 | #box.prop(self, 'useOldDownAngle') 875 | box.prop(self, 'useParentAngle') 876 | 877 | elif self.chooseSet == '5': 878 | box = layout.box() 879 | box.label(text="Leaves:") 880 | box.prop(self, 'showLeaves') 881 | box.prop(self, 'leafShape') 882 | box.prop(self, 'leafDupliObj') 883 | 884 | 885 | row = box.row() 886 | row.label(text="Leaf Object Axes:") 887 | row.prop(self, 'leafObjZ') 888 | row.prop(self, 'leafObjY') 889 | #row.prop(self, 'leafObjX') 890 | 891 | 892 | box.prop(self, 'leaves') 893 | box.prop(self, 'leafBaseSize') 894 | box.prop(self, 'leafDist') 895 | 896 | box.label(text="") 897 | box.prop(self, 'leafType') 898 | box.prop(self, 'leafangle') 899 | row = box.row() 900 | row.prop(self, 'leafDownAngle') 901 | row.prop(self, 'leafDownAngleV') 902 | 903 | row = box.row() 904 | row.prop(self, 'leafRotate') 905 | row.prop(self, 'leafRotateV') 906 | box.label(text="") 907 | 908 | row = box.row() 909 | row.prop(self, 'leafScale') 910 | row.prop(self, 'leafScaleX') 911 | 912 | row = box.row() 913 | row.prop(self, 'leafScaleT') 914 | row.prop(self, 'leafScaleV') 915 | 916 | elif self.chooseSet == '6': 917 | box = layout.box() 918 | box.label(text="Armature and Animation:") 919 | 920 | row = box.row() 921 | row.prop(self, 'useArm') 922 | row.prop(self, 'previewArm') 923 | 924 | row = box.row() 925 | row.prop(self, 'armAnim') 926 | row.prop(self, 'leafAnim') 927 | 928 | box.prop(self, 'frameRate') 929 | box.prop(self, 'loopFrames') 930 | 931 | #row = box.row() 932 | #row.prop(self, 'windSpeed') 933 | #row.prop(self, 'windGust') 934 | 935 | box.label(text='Wind Settings:') 936 | box.prop(self, 'wind') 937 | row = box.row() 938 | row.prop(self, 'gust') 939 | row.prop(self, 'gustF') 940 | 941 | box.label(text='Leaf Wind Settings:') 942 | box.prop(self, 'af1') 943 | box.prop(self, 'af2') 944 | box.prop(self, 'af3') 945 | 946 | box.label(text="") 947 | box.prop(self, 'makeMesh') 948 | box.label(text="Armature Simplification:") 949 | box.prop(self, 'armLevels') 950 | box.prop(self, 'boneStep') 951 | 952 | def execute(self, context): 953 | # Ensure the use of the global variables 954 | global settings, useSet, is_first 955 | start_time = time.time() 956 | # If we need to set the properties from a preset then do it here 957 | if useSet: 958 | for a, b in settings.items(): 959 | setattr(self, a, b) 960 | if self.limitImport: 961 | setattr(self, 'levels', min(settings['levels'], 2)) 962 | setattr(self, 'showLeaves', False) 963 | useSet = False 964 | if self.do_update: 965 | addTree(self) 966 | #cProfile.runctx("addTree(self)", globals(), locals()) 967 | print("Tree creation in %0.1fs" %(time.time()-start_time)) 968 | 969 | #backup most recent setengs in case of exit 970 | if not is_first: 971 | # Here we create a dict of all the properties. 972 | data = [] 973 | for a, b in (self.as_keywords(ignore=("chooseSet", "presetName", "limitImport", "do_update", "overwrite", "leafDupliObj"))).items(): 974 | # If the property is a vector property then add the slice to the list 975 | try: 976 | len(b) 977 | data.append((a, b[:])) 978 | # Otherwise, it is fine so just add it 979 | except: 980 | data.append((a, b)) 981 | # Create the dict from the list 982 | data = dict(data) 983 | 984 | #then save 985 | bpy.ops.sapling.exportdata("INVOKE_DEFAULT", data = repr([repr(data), "PreviousSettings", True])) 986 | 987 | is_first = False 988 | 989 | return {'FINISHED'} 990 | else: 991 | return {'PASS_THROUGH'} 992 | 993 | def invoke(self, context, event): 994 | global is_first 995 | is_first = True 996 | bpy.ops.sapling.importdata(filename = "Default Tree.py") 997 | return self.execute(context) 998 | 999 | 1000 | class AddMultipleTrees(bpy.types.Operator): 1001 | bl_idname = "curve.trees_add" 1002 | bl_label = "Sapling: Add Trees" 1003 | bl_options = {'REGISTER', 'UNDO'} 1004 | 1005 | def objectList(self, context): 1006 | objects = [] 1007 | bObjects = bpy.data.objects 1008 | # try: 1009 | # bObjects = bpy.data.objects 1010 | # except AttributeError: 1011 | # pass 1012 | # else: 1013 | for obj in bObjects: 1014 | if (obj.type in ['MESH', 'CURVE', 'SURFACE']) and (obj.name not in ['tree', 'leaves']): 1015 | objects.append((obj.name, obj.name, "")) 1016 | return objects 1017 | 1018 | do_update: BoolProperty(name='Re-grow Trees', 1019 | default=True) 1020 | 1021 | bevel: BoolProperty(name='Bevel', 1022 | description='Whether the curve is beveled', 1023 | default=False) 1024 | showLeaves: BoolProperty(name='Show Leaves', 1025 | description='Whether the leaves are shown', 1026 | default=False) 1027 | useArm: BoolProperty(name='Use Armature', 1028 | description='Whether the armature is generated', 1029 | default=False) 1030 | seed: IntProperty(name='Random Seed', 1031 | description='The seed of the random number generator', 1032 | default=0) 1033 | numTrees: IntProperty(name='Number of trees', 1034 | description='Number of trees to generate while incrementing the seed', 1035 | min=1, 1036 | default=1) 1037 | 1038 | scale: FloatProperty(name='Scale', 1039 | description='The tree scale (Scale)', 1040 | min=0.0, 1041 | default=13.0) 1042 | scaleV: FloatProperty(name='Scale Variation', 1043 | description='The variation in the tree scale', 1044 | default=3.0) 1045 | 1046 | bevelRes: IntProperty(name='Bevel Resolution', 1047 | description='The bevel resolution of the curves', 1048 | min=0, 1049 | max=32, 1050 | default=0) 1051 | resU: IntProperty(name='Curve Resolution', 1052 | description='The resolution along the curves', 1053 | min=1, 1054 | default=4) 1055 | 1056 | leafShape: EnumProperty(name='Leaf Shape', 1057 | description='The shape of the leaves', 1058 | items=(('hex', 'Hexagonal', '0'), ('rect', 'Rectangular', '1'), ('dFace', 'DupliFaces', '2'), ('dVert', 'DupliVerts', '3')), 1059 | default='hex') 1060 | leafDupliObj: EnumProperty(name='Leaf Object', 1061 | description='Object to use for leaf instancing if Leaf Shape is DupliFaces or DupliVerts', 1062 | items=objectList) 1063 | leafObjZ: EnumProperty(name='', 1064 | description='leaf tip axis', 1065 | items=axes, 1066 | default="+2") 1067 | leafObjY: EnumProperty(name='', 1068 | description='leaf top axis', 1069 | items=axes, 1070 | default="+1") 1071 | leafScale: FloatProperty(name='Leaf Scale', 1072 | description='The scaling applied to the whole leaf (LeafScale)', 1073 | min=0.0, 1074 | default=0.17) 1075 | 1076 | armAnim: BoolProperty(name='Armature Animation', 1077 | description='Whether animation is added to the armature', 1078 | default=False) 1079 | previewArm: BoolProperty(name='Fast Preview', 1080 | description='Disable armature modifier, hide tree, and set bone display to wire, for fast playback', 1081 | ##Disable skin modifier and hide tree and armature, for fast playback 1082 | default=False) 1083 | leafAnim: BoolProperty(name='Leaf Animation', 1084 | description='Whether animation is added to the leaves', 1085 | default=False) 1086 | frameRate: FloatProperty(name='Animation Speed', 1087 | description=('Adjust speed of animation, relative to scene frame rate'), 1088 | min=0.001, 1089 | default=1) 1090 | loopFrames: IntProperty(name='Loop Frames', 1091 | description='Number of frames to make the animation loop for, zero is disabled', 1092 | min=0, 1093 | default=0) 1094 | 1095 | makeMesh: BoolProperty(name='Make Mesh', 1096 | description='Convert curves to mesh, uses skin modifier, enables armature simplification', 1097 | default=False) 1098 | armLevels: IntProperty(name='Armature Levels', 1099 | description='Number of branching levels to make bones for, 0 is all levels', 1100 | min=0, 1101 | default=2) 1102 | boneStep: IntVectorProperty(name='Bone Length', 1103 | description='Number of stem segments per bone', 1104 | min=1, 1105 | default=[1, 1, 1, 1], 1106 | size=4) 1107 | 1108 | @classmethod 1109 | def poll(cls, context): 1110 | return context.mode == 'OBJECT' 1111 | 1112 | def draw(self, context): 1113 | 1114 | layout = self.layout 1115 | 1116 | layout.prop(self, 'do_update', icon='CURVE_DATA') 1117 | 1118 | box = layout.box() 1119 | box.label(text="Geometry:") 1120 | 1121 | row = box.row() 1122 | row.menu('SAPLING_MT_preset', text='Load Preset') 1123 | 1124 | box.prop(self, 'seed') 1125 | box.prop(self, 'numTrees') 1126 | 1127 | box.prop(self, 'bevel') 1128 | 1129 | row = box.row() 1130 | row.prop(self, 'bevelRes') 1131 | row.prop(self, 'resU') 1132 | 1133 | box.label(text="Tree Scale:") 1134 | row = box.row() 1135 | row.prop(self, 'scale') 1136 | row.prop(self, 'scaleV') 1137 | 1138 | box = layout.box() 1139 | box.label(text="Leaves:") 1140 | 1141 | box.prop(self, 'showLeaves') 1142 | box.prop(self, 'leafShape') 1143 | box.prop(self, 'leafDupliObj') 1144 | row = box.row() 1145 | row.label(text="Leaf Object Axes:") 1146 | row.prop(self, 'leafObjZ') 1147 | row.prop(self, 'leafObjY') 1148 | 1149 | #box.prop(self, 'leaves') 1150 | box.prop(self, 'leafScale') 1151 | 1152 | box = layout.box() 1153 | box.label(text="Armature and Animation:") 1154 | 1155 | row = box.row() 1156 | row.prop(self, 'useArm') 1157 | row.prop(self, 'previewArm') 1158 | 1159 | row = box.row() 1160 | row.prop(self, 'armAnim') 1161 | row.prop(self, 'leafAnim') 1162 | 1163 | box.prop(self, 'frameRate') 1164 | box.prop(self, 'loopFrames') 1165 | 1166 | box.label(text="") 1167 | box.prop(self, 'makeMesh') 1168 | box.label(text="Armature Simplification:") 1169 | box.prop(self, 'armLevels') 1170 | box.prop(self, 'boneStep') 1171 | 1172 | 1173 | def execute(self, context): 1174 | # Ensure the use of the global variables 1175 | global settings, useSet 1176 | # If we need to set the properties from a preset then do it here 1177 | #presetAsDict 1178 | if useSet: 1179 | for a, b in settings.items(): 1180 | setattr(self, a, b) 1181 | useSet = False 1182 | if self.do_update: 1183 | #loop for multiple trees 1184 | initSeed = self.seed 1185 | for n in range(self.numTrees): 1186 | setattr(self, 'seed', self.seed + n) 1187 | space = 6 1188 | grid = ceil(self.numTrees ** .5) 1189 | x = (n // grid) * space 1190 | y = (n % grid) * space 1191 | bpy.context.scene.cursor.location = (x, y, 0) 1192 | addTree(self) 1193 | setattr(self, 'seed', initSeed) 1194 | self.do_update = False 1195 | return {'FINISHED'} 1196 | else: 1197 | return {'PASS_THROUGH'} 1198 | 1199 | def invoke(self, context, event): 1200 | # global settings, useSet 1201 | # useSet = True 1202 | bpy.ops.sapling.importdata(filename = "Default Tree.py") 1203 | return self.execute(context) 1204 | 1205 | 1206 | def menu_func(self, context): 1207 | self.layout.operator(AddTree.bl_idname, text="Add Tree 4.0", icon='PLUGIN') 1208 | def menu_func2(self, context): 1209 | self.layout.operator(AddMultipleTrees.bl_idname, text="Add Multiple Trees", icon='PLUGIN') 1210 | 1211 | classes = ( 1212 | AddTree, 1213 | AddMultipleTrees, 1214 | PresetMenu, 1215 | ImportData, 1216 | ExportData, 1217 | ) 1218 | 1219 | 1220 | def register(): 1221 | from bpy.utils import register_class 1222 | for cls in classes: 1223 | register_class(cls) 1224 | bpy.types.VIEW3D_MT_curve_add.append(menu_func) 1225 | bpy.types.VIEW3D_MT_curve_add.append(menu_func2) 1226 | 1227 | def unregister(): 1228 | from bpy.utils import unregister_class 1229 | for cls in reversed(classes): 1230 | unregister_class(cls) 1231 | bpy.types.VIEW3D_MT_curve_add.remove(menu_func2) 1232 | bpy.types.VIEW3D_MT_curve_add.remove(menu_func) 1233 | 1234 | if __name__ == "__main__": 1235 | register() 1236 | -------------------------------------------------------------------------------- /add_curve_sapling_3_2_8/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | #====================== BEGIN GPL LICENSE BLOCK ====================== 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either version 2 8 | # of the License, or (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software Foundation, 17 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | # 19 | #======================= END GPL LICENSE BLOCK ======================== 20 | 21 | bl_info = { 22 | "name": "Sapling_3", 23 | "author": "Andrew Hale (TrumanBlending), modified by Aaron Buchler 2015-2018", 24 | "version": (0, 3, 4), 25 | "blender": (2, 80, 0), 26 | "location": "View3D > Add > Curve", 27 | "description": ("Adds a parametric tree. The method is presented by " 28 | "Jason Weber & Joseph Penn in their paper 'Creation and Rendering of " 29 | "Realistic Trees'."), 30 | "category": "Add Curve"} 31 | 32 | if "bpy" in locals(): 33 | import importlib 34 | importlib.reload(utils) 35 | else: 36 | from add_curve_sapling_3_2_8 import utils 37 | 38 | import bpy 39 | import time 40 | import os 41 | import ast 42 | 43 | #import cProfile 44 | 45 | from mathutils import * 46 | from math import pi, sin, degrees, radians, atan2, copysign, ceil 47 | from random import random, uniform, seed, choice, getstate, setstate 48 | from bpy.props import * 49 | 50 | from add_curve_sapling_3_2_8.utils import * 51 | 52 | useSet = False 53 | is_first = False 54 | 55 | shapeList = [('0', 'Conical (0)', 'Shape = 0'), 56 | ('1', 'Spherical (1)', 'Shape = 1'), 57 | ('2', 'Hemispherical (2)', 'Shape = 2'), 58 | ('3', 'Cylindrical (3)', 'Shape = 3'), 59 | ('4', 'Tapered Cylindrical (4)', 'Shape = 4'), 60 | ('5', 'Flame (5)', 'Shape = 5'), 61 | ('6', 'Inverse Conical (6)', 'Shape = 6'), 62 | ('7', 'Tend Flame (7)', 'Shape = 7')] 63 | 64 | shapeList3 = [('0', 'Conical', ''), 65 | ('6', 'Inverse Conical', ''), 66 | ('1', 'Spherical', ''), 67 | ('2', 'Hemispherical', ''), 68 | ('3', 'Cylindrical', ''), 69 | ('4', 'Tapered Cylindrical', ''), 70 | ('10', 'Inverse Tapered Cylindrical', ''), 71 | ('5', 'Flame', ''), 72 | ('7', 'Tend Flame', ''), 73 | ('8', 'Custom Shape', '')] 74 | 75 | shapeList4 = [('0', 'Conical', ''), 76 | ('6', 'Inverse Conical', ''), 77 | ('1', 'Spherical', ''), 78 | ('2', 'Hemispherical', ''), 79 | ('3', 'Cylindrical', ''), 80 | ('4', 'Tapered Cylindrical', ''), 81 | ('10', 'Inverse Tapered Cylindrical', ''), 82 | ('5', 'Flame', ''), 83 | ('7', 'Tend Flame', '')] 84 | 85 | leaftypes = [('0', 'Rotated Alternate', 'leaves rotate around the stem and face upwards'), 86 | ('1', 'Rotated Opposite', 'pairs of leaves rotate around the stem and face upwards'), 87 | ('2', 'Alternate', 'leaves sprout alternately from each side of the stem, uses rotate angle'), 88 | ('3', 'Opposite', 'pairs of leaves sprout from opposite sides of stem, uses rotate angle'), 89 | ('4', 'Palmately Compound', 'multiple leaves radiating from stem tip, uses rotate angle for spread angle'), 90 | ('5', 'Radial', 'leaves rotate around the stem (for needles)')] 91 | 92 | axes = [(("+0"), "X", ""), 93 | (("+1"), "Y", ""), 94 | (("+2"), "Z", ""), 95 | (("-0"), "-X", ""), 96 | (("-1"), "-Y", ""), 97 | (("-2"), "-Z", "")] 98 | 99 | 100 | handleList = [('0', 'Auto', 'Auto'), 101 | ('1', 'Vector', 'Vector')] 102 | 103 | settings = [('0', 'Geometry', 'Geometry'), 104 | ('1', 'Branch Radius', 'Branch Radius'), 105 | ('2', 'Branch Splitting', 'Branch Splitting'), 106 | ('3', 'Branch Growth', 'Branch Growth'), 107 | ('4', 'Pruning', 'Pruning'), 108 | ('5', 'Leaves', 'Leaves'), 109 | ('6', 'Armature', 'Armature')] 110 | 111 | branchmodes = [("original", "Original", "rotate around each branch"), 112 | ("rotate", "Rotate", "evenly distribute branches to point outward from center of tree"), 113 | ("distance", "Distance", "remove overlapping branches")] 114 | 115 | 116 | def getPresetpaths(): 117 | """Return paths for both local and user preset folders""" 118 | userDir = os.path.join(bpy.utils.script_path_user(), 'presets', 'operator', 'add_curve_sapling_3') 119 | 120 | if os.path.isdir(userDir): 121 | pass 122 | else: 123 | os.makedirs(userDir) 124 | 125 | script_file = os.path.realpath(__file__) 126 | directory = os.path.dirname(script_file) 127 | localDir = os.path.join(directory, "presets") 128 | 129 | return (localDir, userDir) 130 | 131 | 132 | class ExportData(bpy.types.Operator): 133 | """This operator handles writing presets to file""" 134 | bl_idname = 'sapling.exportdata' 135 | bl_label = 'Export Preset' 136 | 137 | data: StringProperty() 138 | 139 | def execute(self, context): 140 | # Unpack some data from the input 141 | data, filename, overwrite = eval(self.data) 142 | 143 | fpath1 = os.path.join(getPresetpaths()[0], filename + '.py') 144 | fpath2 = os.path.join(getPresetpaths()[1], filename + '.py') 145 | 146 | if os.path.exists(fpath1): 147 | # If it exists in built-in presets then report an error 148 | self.report({'ERROR_INVALID_INPUT'}, 'Can\'t have same name as built-in preset') 149 | return {'CANCELLED'} 150 | elif (not os.path.exists(fpath2)) or (os.path.exists(fpath2) and overwrite): 151 | #if (it does not exist) or (exists and overwrite) then write file 152 | if data: 153 | # If it doesn't exist, create the file with the required data 154 | f = open(os.path.join(getPresetpaths()[1], filename + '.py'), 'w') 155 | f.write(data) 156 | f.close() 157 | return {'FINISHED'} 158 | else: 159 | return {'CANCELLED'} 160 | else: 161 | # If it exists then report an error 162 | self.report({'ERROR_INVALID_INPUT'}, 'Preset Already Exists') 163 | return {'CANCELLED'} 164 | 165 | 166 | class ImportData(bpy.types.Operator): 167 | """This operator handles importing existing presets""" 168 | bl_idname = 'sapling.importdata' 169 | bl_label = 'Import Preset' 170 | 171 | filename: StringProperty() 172 | 173 | def execute(self, context): 174 | # Make sure the operator knows about the global variables 175 | global settings, useSet, is_first 176 | # Read the preset data into the global settings 177 | try: 178 | f = open(os.path.join(getPresetpaths()[0], self.filename), 'r') 179 | except (FileNotFoundError, IOError): 180 | f = open(os.path.join(getPresetpaths()[1], self.filename), 'r') 181 | settings = f.readline() 182 | f.close() 183 | #print(settings) 184 | settings = ast.literal_eval(settings) 185 | 186 | #use old attractup 187 | if type(settings['attractUp']) == float: 188 | atr = settings['attractUp'] 189 | settings['attractUp'] = [0, 0, atr, atr] 190 | 191 | #use old leaf rotations 192 | if 'leafDownAngle' not in settings: 193 | l = settings['levels'] 194 | settings['leafDownAngle'] = settings['downAngle'][min(l, 3)] 195 | settings['leafDownAngleV'] = settings['downAngleV'][min(l, 3)] 196 | settings['leafRotate'] = settings['rotate'][min(l, 3)] 197 | settings['leafRotateV'] = settings['rotateV'][min(l, 3)] 198 | 199 | #zero leaf bend 200 | settings['bend'] = 0 201 | 202 | #use old leaf settings 203 | if 'leafType' not in settings: 204 | settings['leafType'] = '0' 205 | if settings['leaves'] < 0: 206 | settings['leaves'] = abs(settings['leaves']) 207 | settings['leafType'] = '4' 208 | if settings['leafRotate'] < 1: 209 | settings['leafType'] = '2' 210 | 211 | if 'noTip' not in settings: 212 | settings['noTip'] = False 213 | 214 | # Set the flag to use the settings 215 | useSet = True 216 | is_first = True 217 | return {'FINISHED'} 218 | 219 | 220 | def presetAsDict(filename): 221 | try: 222 | f = open(os.path.join(getPresetpaths()[0], filename), 'r') 223 | except (FileNotFoundError, IOError): 224 | f = open(os.path.join(getPresetpaths()[1], filename), 'r') 225 | settings = f.readline() 226 | f.close() 227 | settings = ast.literal_eval(settings) 228 | return settings 229 | 230 | 231 | class PresetMenu(bpy.types.Menu): 232 | """Create the preset menu by finding all preset files 233 | in the preset directory""" 234 | bl_idname = "sapling.presetmenu" #2.8 235 | bl_label = "Presets" 236 | 237 | def draw(self, context): 238 | # Get all the sapling presets 239 | presets = [a for a in os.listdir(getPresetpaths()[0]) if a[-3:] == '.py'] 240 | presets.extend([a for a in os.listdir(getPresetpaths()[1]) if a[-3:] == '.py']) 241 | layout = self.layout 242 | # Append all to the menu 243 | for p in presets: 244 | layout.operator("sapling.importdata", text=p[:-3]).filename = p 245 | 246 | 247 | class AddTree(bpy.types.Operator): 248 | bl_idname = "curve.tree_add" 249 | bl_label = "Sapling: Add Tree" 250 | bl_options = {'REGISTER', 'UNDO'} 251 | 252 | def objectList(self, context): 253 | objects = [] 254 | bObjects = bpy.data.objects 255 | for obj in bObjects: 256 | if (obj.type in ['MESH', 'CURVE', 'SURFACE']) and (obj.name not in ['tree', 'leaves', 'envelope']): 257 | objects.append((obj.name, obj.name, "")) 258 | 259 | return objects 260 | 261 | def update_tree(self, context): 262 | self.do_update = True 263 | 264 | def update_leaves(self, context): 265 | if self.showLeaves: 266 | self.do_update = True 267 | else: 268 | self.do_update = False 269 | 270 | def no_update_tree(self, context): 271 | self.do_update = False 272 | 273 | do_update: BoolProperty(name='Do Update', 274 | default=True, options={'HIDDEN'}) 275 | 276 | chooseSet: EnumProperty(name='Settings', 277 | description='Choose the settings to modify', 278 | items=settings, 279 | default='0', update=no_update_tree) 280 | 281 | bevel: BoolProperty(name='Bevel', 282 | description='Whether the curve is beveled', 283 | default=False, update=update_tree) 284 | prune: BoolProperty(name='Prune', 285 | description='Whether the tree is pruned', 286 | default=False, update=update_tree) 287 | showLeaves: BoolProperty(name='Show Leaves', 288 | description='Whether the leaves are shown', 289 | default=False, update=update_tree) 290 | useArm: BoolProperty(name='Use Armature', 291 | description='Whether the armature is generated', 292 | default=False, update=update_tree) 293 | seed: IntProperty(name='Random Seed', 294 | description='The seed of the random number generator', 295 | default=0, update=update_tree) 296 | handleType: EnumProperty(name='Handle Type', 297 | description='The type of bezier curve handles', 298 | items=handleList, 299 | default='0', update=update_tree) 300 | bevelRes: IntProperty(name='Bevel Resolution', 301 | description='The bevel resolution of the curves', 302 | min=0, 303 | max=32, 304 | default=0, update=update_tree) 305 | resU: IntProperty(name='Curve Resolution', 306 | description='The resolution along the curves', 307 | min=1, 308 | default=4, update=update_tree) 309 | 310 | levels: IntProperty(name='Levels', 311 | description='Number of recursive branches', 312 | min=1, 313 | max=6, 314 | soft_max=4, 315 | default=3, update=update_tree) 316 | length: FloatVectorProperty(name='Length', 317 | description='The relative lengths of each branch level', 318 | min=0.000001, 319 | default=[1, 0.3, 0.6, 0.45], 320 | size=4, update=update_tree) 321 | lengthV: FloatVectorProperty(name='Length Variation', 322 | description='Branch and split length variations for each level', 323 | min=0.0, 324 | max=1.0, 325 | default=[0, 0, 0, 0], 326 | size=4, update=update_tree) 327 | taperCrown: FloatProperty(name='Taper Crown', 328 | description='Shorten trunk splits toward outside of tree', 329 | min=0.0, 330 | soft_max=1.0, 331 | default=0, update=update_tree) 332 | branches: IntVectorProperty(name='Branches', 333 | description='The number of branches grown at each level', 334 | min=0, 335 | default=[50, 30, 10, 10], 336 | size=4, update=update_tree) 337 | curveRes: IntVectorProperty(name='Curve Resolution', 338 | description='The number of segments on each branch', 339 | min=1, 340 | default=[3, 5, 3, 1], 341 | size=4, update=update_tree) 342 | curve: FloatVectorProperty(name='Curvature', 343 | description='The angle of the end of the branch', 344 | default=[0, -40, -40, 0], 345 | size=4, update=update_tree) 346 | curveV: FloatVectorProperty(name='Curvature Variation', 347 | description='Variation of the curvature', 348 | default=[20, 50, 75, 0], 349 | size=4, update=update_tree) 350 | curveBack: FloatVectorProperty(name='Back Curvature', 351 | description='Curvature for the second half of a branch', 352 | default=[0, 0, 0, 0], 353 | size=4, update=update_tree) 354 | baseSplits: IntProperty(name='Base Splits', 355 | description='Number of trunk splits at its base', 356 | min=0, 357 | default=0, update=update_tree) 358 | segSplits: FloatVectorProperty(name='Segment Splits', 359 | description='Number of splits per segment', 360 | min=0, 361 | soft_max=3, 362 | default=[0, 0, 0, 0], 363 | size=4, update=update_tree) 364 | splitByLen: BoolProperty(name='Split relative to length', 365 | description='Split proportional to branch length', 366 | default=False, update=update_tree) 367 | rMode: EnumProperty(name="", #"Branching Mode" 368 | description='Branching and Rotation Mode', 369 | items=branchmodes, 370 | default="rotate", update=update_tree) 371 | splitStraight: FloatProperty(name="Split Straight", 372 | description="Straightness of trunk branch splits", 373 | min=0.0, 374 | max=1.0, 375 | default=0, update=update_tree) 376 | splitLength: FloatProperty(name="Split Length", 377 | description="Length of trunk branch splits, (similar to length variation but not random)", 378 | min=0.0, 379 | max=1.0, 380 | default=0, update=update_tree) 381 | splitAngle: FloatVectorProperty(name='Split Angle', 382 | description='Angle of branch splitting', 383 | default=[0, 0, 0, 0], 384 | size=4, update=update_tree) 385 | splitAngleV: FloatVectorProperty(name='Split Angle Variation', 386 | description='Variation in the split angle', 387 | default=[0, 0, 0, 0], 388 | size=4, update=update_tree) 389 | scale: FloatProperty(name='Scale', 390 | description='The tree scale', 391 | min=0.0, 392 | default=13.0, update=update_tree) 393 | scaleV: FloatProperty(name='Scale Variation', 394 | description='The variation in the tree scale', 395 | default=3.0, update=update_tree) 396 | attractUp: FloatVectorProperty(name='Vertical Attraction', 397 | description='Branch upward attraction', 398 | default=[0, 0, 0, 0], 399 | size=4, update=update_tree) 400 | attractOut: FloatVectorProperty(name='Outward Attraction', 401 | description='Branch outward attraction', 402 | default=[0, 0, 0, 0], 403 | min=0.0, 404 | max=1.0, 405 | size=4, update=update_tree) 406 | shape: EnumProperty(name='Shape', 407 | description='The overall shape of the tree', 408 | items=shapeList3, 409 | default='7', update=update_tree) 410 | shapeS: EnumProperty(name='Secondary Branches Shape', 411 | description='The shape of secondary splits', 412 | items=shapeList4, 413 | default='4', update=update_tree) 414 | customShape: FloatVectorProperty(name='Custom Shape', 415 | description='custom shape branch length at \n(Base, Middle, Middle Position, Top)', 416 | size=4, 417 | min=.01, 418 | max=1, 419 | default=[.5, 1.0, .3, .5], update=update_tree) 420 | branchDist: FloatProperty(name='Branch Distribution', 421 | description='Adjust branch spacing to put more branches at the top or bottom of the tree', 422 | min=0.1, 423 | soft_max=10, 424 | default=1.0, update=update_tree) 425 | nrings: IntProperty(name='Branch Rings', 426 | description='grow branches in whorls', 427 | min=0, 428 | default=0, update=update_tree) 429 | baseSize: FloatProperty(name='Trunk Height', 430 | description='Fraction of tree height with no branches (Base Size)', 431 | min=0.0, 432 | max=1.0, 433 | default=0.4, update=update_tree) 434 | baseSize_s: FloatProperty(name='Secondary Base Size', 435 | description='Factor to decrease base size for each level', 436 | min=0.0, 437 | max=1.0, 438 | default=0.25, update=update_tree) 439 | leafBaseSize: FloatProperty(name='Leaf Base Size', 440 | description='Fraction of stem length with no leaves', 441 | min=0.0, 442 | max=1.0, 443 | default=0.20, update=update_tree) 444 | splitHeight: FloatProperty(name='Split Height', 445 | description='Fraction of tree height with no splits', 446 | min=0.0, 447 | max=1.0, 448 | default=0.2, update=update_tree) 449 | splitBias: FloatProperty(name='Split Bias', 450 | description='Put more splits at the top or bottom of the tree', 451 | soft_min=-2.0, 452 | soft_max=2.0, 453 | default=0.0, update=update_tree) 454 | ratio: FloatProperty(name='Ratio', 455 | description='Ratio of tree scale to base radius', 456 | min=0.0, 457 | default=0.015, update=update_tree) 458 | minRadius: FloatProperty(name='Minimum Radius', 459 | description='Minimum branch Radius', 460 | min=0.0, 461 | default=0.0, update=update_tree) 462 | closeTip: BoolProperty(name='Close Tip', 463 | description='Set radius at branch tips to zero', 464 | default=False, update=update_tree) 465 | rootFlare: FloatProperty(name='Root Flare', 466 | description='Root radius factor', 467 | min=1.0, 468 | default=1.0, update=update_tree) 469 | splitRadiusRatio: FloatProperty(name='Split Radius Ratio', 470 | description='Reduce radius after branch splits', 471 | min=-1.0, 472 | max=1.0, 473 | default=0.75, update=update_tree) 474 | autoTaper: BoolProperty(name='Auto Taper', 475 | description='Calculate taper automaticly based on branch lengths', 476 | default=True, update=update_tree) 477 | taper: FloatVectorProperty(name='Taper', 478 | description='The fraction of tapering on each branch', 479 | min=0.0, 480 | max=1.0, 481 | default=[1, 1, 1, 1], 482 | size=4, update=update_tree) 483 | noTip: BoolProperty(name='No branch at stem tip', 484 | description='Useful for non-typical / abstract trees', 485 | default=False, update=update_tree) 486 | radiusTweak: FloatVectorProperty(name='Tweak Radius', 487 | description='multiply radius by this factor', 488 | min=0.0, 489 | max=1.0, 490 | default=[1, 1, 1, 1], 491 | size=4, update=update_tree) 492 | ratioPower: FloatProperty(name='Radius Ratio Power', 493 | description='Power which defines the radius of a branch compared to the radius of the branch it grew from', 494 | min=0.0, 495 | soft_min=1.0, 496 | default=1.2, update=update_tree) 497 | downAngle: FloatVectorProperty(name='Down Angle', 498 | description='The angle between a new branch and the one it grew from', 499 | default=[90, 60, 45, 45], 500 | size=4, update=update_tree) 501 | downAngleV: FloatVectorProperty(name='Down Angle Variation', 502 | description='Angle to decrease Down Angle by towards end of parent branch \n(negative values add random variation)', 503 | default=[0, -50, 10, 10], 504 | size=4, update=update_tree) 505 | useOldDownAngle: BoolProperty(name='Use old down angle variation', 506 | default=False, update=update_tree) 507 | useParentAngle: BoolProperty(name='Use parent angle', 508 | description='(first level) Rotate branch to match parent branch', 509 | default=True, update=update_tree) 510 | rotate: FloatVectorProperty(name='Rotate Angle', 511 | description='The angle of a new branch around the one it grew from \n(negative values make branches rotate opposite from the previous one)', 512 | default=[137.5, 137.5, 137.5, 137.5], 513 | size=4, update=update_tree) 514 | rotateV: FloatVectorProperty(name='Rotate Angle Variation', 515 | description='Variation in the rotate angle', 516 | default=[0, 0, 0, 0], 517 | size=4, update=update_tree) 518 | scale0: FloatProperty(name='Radius Scale', 519 | description='The scale of the trunk radius', 520 | min=0.0, 521 | default=1.0, update=update_tree) 522 | scaleV0: FloatProperty(name='Radius Scale Variation', 523 | description='Variation in the radius scale', 524 | min=0.0, 525 | max=1.0, 526 | default=0.2, update=update_tree) 527 | pruneWidth: FloatProperty(name='Prune Width', 528 | description='The width of the envelope', 529 | min=0.0, 530 | default=0.4, update=update_tree) 531 | pruneBase: FloatProperty(name='Prune Base Height', 532 | description='The height of the base of the envelope, bound by trunk height', 533 | min=0.0, 534 | max=1.0, 535 | default=0.3, update=update_tree) 536 | pruneWidthPeak: FloatProperty(name='Prune Width Peak', 537 | description='Fraction of envelope height where the maximum width occurs', 538 | min=0.0, 539 | default=0.6, update=update_tree) 540 | prunePowerHigh: FloatProperty(name='Prune Power High', 541 | description='Power which determines the shape of the upper portion of the envelope', 542 | default=0.5, update=update_tree) 543 | prunePowerLow: FloatProperty(name='Prune Power Low', 544 | description='Power which determines the shape of the lower portion of the envelope', 545 | default=0.001, update=update_tree) 546 | pruneRatio: FloatProperty(name='Prune Ratio', 547 | description='Proportion of pruned length', 548 | min=0.0, 549 | max=1.0, 550 | default=1.0, update=update_tree) 551 | leaves: IntProperty(name='Leaves', 552 | description='Maximum number of leaves per branch', 553 | min=0, 554 | default=25, update=update_tree) 555 | leafType: EnumProperty(name='Leaf Type', 556 | description='Type of leaf arrangment', 557 | items=leaftypes[::-1], 558 | default='0', update=update_leaves) #update_leaves update_tree 559 | 560 | leafDownAngle: FloatProperty(name='Leaf Down Angle', 561 | description='The angle between a new leaf and the branch it grew from', 562 | default=45, update=update_leaves) 563 | leafDownAngleV: FloatProperty(name='Leaf Down Angle Variation', 564 | description='Angle to decrease Down Angle by towards end of parent branch', 565 | min=0, 566 | default=10, update=update_tree) 567 | leafRotate: FloatProperty(name='Leaf Rotate Angle', 568 | description='The rotate angle for Alternate and Opposite leaves', 569 | default=90, update=update_tree) 570 | leafRotateV: FloatProperty(name='Rotation Variation', 571 | description='Add randomness to leaf orientation', 572 | default=0.0, update=update_leaves) 573 | 574 | leafObjZ: EnumProperty(name='', 575 | description='leaf tip axis', 576 | items=axes, 577 | default="+2", update=update_leaves) 578 | leafObjY: EnumProperty(name='', 579 | description='leaf top axis', 580 | items=axes, 581 | default="+1", update=update_leaves) 582 | #leafObjX: EnumProperty(name='', 583 | # description='leaf side axis', 584 | # items=axes, 585 | # default="+0", update=update_leaves) 586 | 587 | leafScale: FloatProperty(name='Leaf Scale', 588 | description='The scaling applied to the whole leaf', 589 | min=0.0, 590 | default=0.17, update=update_leaves) 591 | leafScaleX: FloatProperty(name='Leaf Scale X', 592 | description='The scaling applied to the x direction of the leaf', 593 | min=0.0, 594 | default=1.0, update=update_leaves) 595 | leafScaleT: FloatProperty(name='Leaf Scale Taper', 596 | description='scale leaves toward the tip or base of the patent branch', 597 | min=-1.0, 598 | max=1.0, 599 | default=0.0, update=update_leaves) 600 | leafScaleV: FloatProperty(name='Leaf Scale Variation', 601 | description='randomize leaf scale', 602 | min=0.0, 603 | max=1.0, 604 | default=0.0, update=update_leaves) 605 | leafShape: EnumProperty(name='Leaf Shape', 606 | description='The shape of the leaves', 607 | items=(('hex', 'Hexagonal', '0'), ('rect', 'Rectangular', '1'), ('dFace', 'DupliFaces', '2'), ('dVert', 'DupliVerts', '3')), 608 | default='hex', update=update_leaves) 609 | leafDupliObj: EnumProperty(name='Leaf Object', 610 | description='Object to use for leaf instancing if Leaf Shape is DupliFaces or DupliVerts', 611 | items=objectList, 612 | update=update_leaves) 613 | 614 | leafangle: FloatProperty(name='Leaf Angle', 615 | description='Leaf vertical attraction', 616 | default=0.0, update=update_leaves) 617 | horzLeaves: BoolProperty(name='Horizontal leaves', 618 | description='Leaves face upwards', 619 | default=True, update=update_leaves) 620 | leafDist: EnumProperty(name='Leaf Distribution', 621 | description='The way leaves are distributed on branches', 622 | items=shapeList4, 623 | default='6', update=update_tree) 624 | 625 | armAnim: BoolProperty(name='Armature Animation', 626 | description='Whether animation is added to the armature', 627 | default=False, update=update_tree) 628 | previewArm: BoolProperty(name='Fast Preview', 629 | description=('Disable armature modifier, hide tree, and set bone display to wire, for fast playback \n' 630 | 'If Make Mesh is enabled: \nDisable skin modifier, hide curve tree and armature'), 631 | default=False, update=update_tree) 632 | leafAnim: BoolProperty(name='Leaf Animation', 633 | description='Whether animation is added to the leaves', 634 | default=False, update=update_tree) 635 | frameRate: FloatProperty(name='Animation Speed', 636 | description='Adjust speed of animation, relative to scene frame rate', 637 | min=0.001, 638 | default=1, update=update_tree) 639 | loopFrames: IntProperty(name='Loop Frames', 640 | description='Number of frames to make the animation loop for, zero is disabled', 641 | min=0, 642 | default=0, update=update_tree) 643 | 644 | # windSpeed: FloatProperty(name='Wind Speed', 645 | # description='The wind speed to apply to the armature', 646 | # default=2.0, update=update_tree) 647 | # windGust: FloatProperty(name='Wind Gust', 648 | # description='The greatest increase over Wind Speed', 649 | # default=0.0, update=update_tree) 650 | 651 | wind: FloatProperty(name='Overall Wind Strength', 652 | description='The intensity of the wind to apply to the armature', 653 | default=1.0, update=update_tree) 654 | 655 | gust: FloatProperty(name='Wind Gust Strength', 656 | description='The amount of directional movement, (from the positive Y direction)', 657 | default=1.0, update=update_tree) 658 | 659 | gustF: FloatProperty(name='Wind Gust Fequency', 660 | description='The Fequency of directional movement', 661 | default=0.075, update=update_tree) 662 | 663 | af1: FloatProperty(name='Amplitude', 664 | description='Multiplier for noise amplitude', 665 | default=1.0, update=update_tree) 666 | af2: FloatProperty(name='Frequency', 667 | description='Multiplier for noise fequency', 668 | default=1.0, update=update_tree) 669 | af3: FloatProperty(name='Randomness', 670 | description='Random offset in noise', 671 | default=4.0, update=update_tree) 672 | 673 | makeMesh: BoolProperty(name='Make Mesh', 674 | description='Convert curves to mesh, uses skin modifier, enables armature simplification', 675 | default=False, update=update_tree) 676 | armLevels: IntProperty(name='Armature Levels', 677 | description='Number of branching levels to make bones for, 0 is all levels', 678 | min=0, 679 | default=2, update=update_tree) 680 | boneStep: IntVectorProperty(name='Bone Length', 681 | description='Number of stem segments per bone', 682 | min=1, 683 | default=[1, 1, 1, 1], 684 | size=4, update=update_tree) 685 | matIndex: IntVectorProperty(name='Material Index', 686 | description='Material index for each split level (curves only)', 687 | min=0, 688 | max=3, 689 | default=[0, 0, 0, 0], 690 | size=4, update=update_tree) 691 | 692 | presetName: StringProperty(name='Preset Name', 693 | description='The name of the preset to be saved', 694 | default='', 695 | subtype='FILE_NAME', update=no_update_tree) 696 | limitImport: BoolProperty(name='Limit Import', 697 | description='Limited imported tree to 2 levels & no leaves for speed', 698 | default=True, update=no_update_tree) 699 | overwrite: BoolProperty(name='Overwrite', 700 | description='When checked, overwrite existing preset files when saving', 701 | default=False, update=no_update_tree) 702 | 703 | @classmethod 704 | def poll(cls, context): 705 | return context.mode == 'OBJECT' 706 | 707 | def draw(self, context): 708 | 709 | layout = self.layout 710 | 711 | layout.prop(self, 'chooseSet') 712 | 713 | if self.chooseSet == '0': 714 | box = layout.box() 715 | box.label(text="Geometry:") 716 | row = box.row() 717 | row.prop(self, 'bevel') 718 | row.prop(self, 'makeMesh') 719 | 720 | row = box.row() 721 | row.prop(self, 'bevelRes') 722 | row.prop(self, 'resU') 723 | 724 | box.prop(self, 'handleType') 725 | box.prop(self, 'shape') 726 | 727 | row = box.row() 728 | row.prop(self, 'customShape') 729 | 730 | box.prop(self, 'shapeS') 731 | box.prop(self, 'branchDist') 732 | box.prop(self, 'nrings') 733 | 734 | row = box.row() 735 | row.prop(self, 'matIndex') 736 | 737 | box.label(text="") 738 | box.prop(self, 'seed') 739 | 740 | box.label(text="Tree Scale:") 741 | row = box.row() 742 | row.prop(self, 'scale') 743 | row.prop(self, 'scaleV') 744 | 745 | # Here we create a dict of all the properties. 746 | # Unfortunately as_keyword doesn't work with vector properties, 747 | # so we need something custom. This is it 748 | data = [] 749 | for a, b in (self.as_keywords(ignore=("chooseSet", "presetName", "limitImport", "do_update", "overwrite", "leafDupliObj"))).items(): 750 | # If the property is a vector property then add the slice to the list 751 | try: 752 | len(b) 753 | data.append((a, b[:])) 754 | # Otherwise, it is fine so just add it 755 | except: 756 | data.append((a, b)) 757 | # Create the dict from the list 758 | data = dict(data) 759 | 760 | row = box.row() 761 | row.prop(self, 'presetName') 762 | # Send the data dict and the file name to the exporter 763 | row.operator('sapling.exportdata').data = repr([repr(data), self.presetName, self.overwrite]) 764 | row = box.row() 765 | row.label(text=" ") 766 | row.prop(self, 'overwrite') 767 | row = box.row() 768 | row.menu('sapling.presetmenu', text='Load Preset') 769 | row.prop(self, 'limitImport') 770 | 771 | elif self.chooseSet == '1': 772 | box = layout.box() 773 | box.label(text="Branch Radius:") 774 | 775 | row = box.row() 776 | row.prop(self, 'bevel') 777 | row.prop(self, 'bevelRes') 778 | 779 | box.prop(self, 'ratio') 780 | 781 | box.prop(self, 'minRadius') 782 | box.prop(self, 'closeTip') 783 | box.prop(self, 'rootFlare') 784 | box.prop(self, 'splitRadiusRatio') 785 | 786 | box.label(text="") 787 | box.label(text="Other:") 788 | 789 | row = box.row() 790 | row.prop(self, 'autoTaper') 791 | row.prop(self, 'noTip') 792 | 793 | row = box.row() 794 | row.prop(self, 'scale0') 795 | row.prop(self, 'scaleV0') 796 | box.prop(self, 'ratioPower') 797 | 798 | split = box.split() 799 | col = split.column() 800 | col.prop(self, 'taper') 801 | col = split.column() 802 | col.prop(self, 'radiusTweak') 803 | 804 | elif self.chooseSet == '2': 805 | box = layout.box() 806 | box.label(text="Branch Splitting:") 807 | box.prop(self, 'levels') 808 | box.prop(self, 'baseSplits') 809 | row = box.row() 810 | row.prop(self, 'baseSize') 811 | row.prop(self, 'baseSize_s') 812 | box.prop(self, 'splitHeight') 813 | box.prop(self, 'splitBias') 814 | box.prop(self, 'splitByLen') 815 | 816 | split = box.split() 817 | 818 | col = split.column() 819 | col.prop(self, 'branches') 820 | col.prop(self, 'splitAngle') 821 | col.prop(self, 'rotate') 822 | col.prop(self, 'attractOut') 823 | 824 | col = split.column() 825 | col.prop(self, 'segSplits') 826 | col.prop(self, 'splitAngleV') 827 | col.prop(self, 'rotateV') 828 | 829 | col.label(text="Branching Mode:") 830 | col.prop(self, 'rMode') 831 | col.prop(self, 'splitStraight') 832 | col.prop(self, 'splitLength') 833 | 834 | box.column().prop(self, 'curveRes') 835 | 836 | elif self.chooseSet == '3': 837 | box = layout.box() 838 | box.label(text="Branch Growth:") 839 | 840 | box.prop(self, 'taperCrown') 841 | 842 | split = box.split() 843 | 844 | col = split.column() 845 | col.prop(self, 'length') 846 | col.prop(self, 'downAngle') 847 | col.prop(self, 'curve') 848 | col.prop(self, 'curveBack') 849 | 850 | col = split.column() 851 | col.prop(self, 'lengthV') 852 | col.prop(self, 'downAngleV') 853 | col.prop(self, 'curveV') 854 | col.prop(self, 'attractUp') 855 | 856 | box.prop(self, 'useOldDownAngle') 857 | box.prop(self, 'useParentAngle') 858 | 859 | elif self.chooseSet == '4': 860 | box = layout.box() 861 | box.label(text="Pruning:") 862 | box.prop(self, 'prune') 863 | box.prop(self, 'pruneRatio') 864 | row = box.row() 865 | row.prop(self, 'pruneWidth') 866 | row.prop(self, 'pruneBase') 867 | box.prop(self, 'pruneWidthPeak') 868 | 869 | row = box.row() 870 | row.prop(self, 'prunePowerHigh') 871 | row.prop(self, 'prunePowerLow') 872 | 873 | elif self.chooseSet == '5': 874 | box = layout.box() 875 | box.label(text="Leaves:") 876 | box.prop(self, 'showLeaves') 877 | box.prop(self, 'leafShape') 878 | box.prop(self, 'leafDupliObj') 879 | 880 | 881 | row = box.row() 882 | row.label(text="Leaf Object Axes:") 883 | row.prop(self, 'leafObjZ') 884 | row.prop(self, 'leafObjY') 885 | #row.prop(self, 'leafObjX') 886 | 887 | 888 | box.prop(self, 'leaves') 889 | box.prop(self, 'leafBaseSize') 890 | box.prop(self, 'leafDist') 891 | 892 | box.label(text="") 893 | box.prop(self, 'leafType') 894 | box.prop(self, 'leafangle') 895 | row = box.row() 896 | row.prop(self, 'leafDownAngle') 897 | row.prop(self, 'leafDownAngleV') 898 | 899 | row = box.row() 900 | row.prop(self, 'leafRotate') 901 | row.prop(self, 'leafRotateV') 902 | box.label(text="") 903 | 904 | row = box.row() 905 | row.prop(self, 'leafScale') 906 | row.prop(self, 'leafScaleX') 907 | 908 | row = box.row() 909 | row.prop(self, 'leafScaleT') 910 | row.prop(self, 'leafScaleV') 911 | 912 | #box.prop(self, 'horzLeaves') 913 | 914 | elif self.chooseSet == '6': 915 | box = layout.box() 916 | box.label(text="Armature and Animation:") 917 | 918 | row = box.row() 919 | row.prop(self, 'useArm') 920 | row.prop(self, 'previewArm') 921 | 922 | row = box.row() 923 | row.prop(self, 'armAnim') 924 | row.prop(self, 'leafAnim') 925 | 926 | box.prop(self, 'frameRate') 927 | box.prop(self, 'loopFrames') 928 | 929 | #row = box.row() 930 | #row.prop(self, 'windSpeed') 931 | #row.prop(self, 'windGust') 932 | 933 | box.label(text='Wind Settings:') 934 | box.prop(self, 'wind') 935 | row = box.row() 936 | row.prop(self, 'gust') 937 | row.prop(self, 'gustF') 938 | 939 | box.label(text='Leaf Wind Settings:') 940 | box.prop(self, 'af1') 941 | box.prop(self, 'af2') 942 | box.prop(self, 'af3') 943 | 944 | box.label(text="") 945 | box.prop(self, 'makeMesh') 946 | box.label(text="Armature Simplification:") 947 | box.prop(self, 'armLevels') 948 | box.prop(self, 'boneStep') 949 | 950 | def execute(self, context): 951 | # Ensure the use of the global variables 952 | global settings, useSet, is_first 953 | start_time = time.time() 954 | # If we need to set the properties from a preset then do it here 955 | if useSet: 956 | for a, b in settings.items(): 957 | setattr(self, a, b) 958 | if self.limitImport: 959 | setattr(self, 'levels', min(settings['levels'], 2)) 960 | setattr(self, 'showLeaves', False) 961 | useSet = False 962 | if self.do_update: 963 | addTree(self) 964 | #cProfile.runctx("addTree(self)", globals(), locals()) 965 | print("Tree creation in %0.1fs" %(time.time()-start_time)) 966 | 967 | #backup most recent setengs in case of exit 968 | if not is_first: 969 | # Here we create a dict of all the properties. 970 | data = [] 971 | for a, b in (self.as_keywords(ignore=("chooseSet", "presetName", "limitImport", "do_update", "overwrite", "leafDupliObj"))).items(): 972 | # If the property is a vector property then add the slice to the list 973 | try: 974 | len(b) 975 | data.append((a, b[:])) 976 | # Otherwise, it is fine so just add it 977 | except: 978 | data.append((a, b)) 979 | # Create the dict from the list 980 | data = dict(data) 981 | 982 | #then save 983 | bpy.ops.sapling.exportdata("INVOKE_DEFAULT", data = repr([repr(data), "PreviousSettings", True])) 984 | 985 | is_first = False 986 | 987 | return {'FINISHED'} 988 | else: 989 | return {'PASS_THROUGH'} 990 | 991 | def invoke(self, context, event): 992 | global is_first 993 | is_first = True 994 | bpy.ops.sapling.importdata(filename = "Default Tree.py") 995 | return self.execute(context) 996 | 997 | 998 | class AddMultipleTrees(bpy.types.Operator): 999 | bl_idname = "curve.trees_add" 1000 | bl_label = "Sapling: Add Trees" 1001 | bl_options = {'REGISTER', 'UNDO'} 1002 | 1003 | def objectList(self, context): 1004 | objects = [] 1005 | bObjects = bpy.data.objects 1006 | # try: 1007 | # bObjects = bpy.data.objects 1008 | # except AttributeError: 1009 | # pass 1010 | # else: 1011 | for obj in bObjects: 1012 | if (obj.type in ['MESH', 'CURVE', 'SURFACE']) and (obj.name not in ['tree', 'leaves']): 1013 | objects.append((obj.name, obj.name, "")) 1014 | return objects 1015 | 1016 | do_update: BoolProperty(name='Re-grow Trees', 1017 | default=True) 1018 | 1019 | bevel: BoolProperty(name='Bevel', 1020 | description='Whether the curve is beveled', 1021 | default=False) 1022 | showLeaves: BoolProperty(name='Show Leaves', 1023 | description='Whether the leaves are shown', 1024 | default=False) 1025 | useArm: BoolProperty(name='Use Armature', 1026 | description='Whether the armature is generated', 1027 | default=False) 1028 | seed: IntProperty(name='Random Seed', 1029 | description='The seed of the random number generator', 1030 | default=0) 1031 | numTrees: IntProperty(name='Number of trees', 1032 | description='Number of trees to generate while incrementing the seed', 1033 | min=1, 1034 | default=1) 1035 | 1036 | scale: FloatProperty(name='Scale', 1037 | description='The tree scale (Scale)', 1038 | min=0.0, 1039 | default=13.0) 1040 | scaleV: FloatProperty(name='Scale Variation', 1041 | description='The variation in the tree scale', 1042 | default=3.0) 1043 | 1044 | bevelRes: IntProperty(name='Bevel Resolution', 1045 | description='The bevel resolution of the curves', 1046 | min=0, 1047 | max=32, 1048 | default=0) 1049 | resU: IntProperty(name='Curve Resolution', 1050 | description='The resolution along the curves', 1051 | min=1, 1052 | default=4) 1053 | 1054 | leafShape: EnumProperty(name='Leaf Shape', 1055 | description='The shape of the leaves', 1056 | items=(('hex', 'Hexagonal', '0'), ('rect', 'Rectangular', '1'), ('dFace', 'DupliFaces', '2'), ('dVert', 'DupliVerts', '3')), 1057 | default='hex') 1058 | leafDupliObj: EnumProperty(name='Leaf Object', 1059 | description='Object to use for leaf instancing if Leaf Shape is DupliFaces or DupliVerts', 1060 | items=objectList) 1061 | leafObjZ: EnumProperty(name='', 1062 | description='leaf tip axis', 1063 | items=axes, 1064 | default="+2") 1065 | leafObjY: EnumProperty(name='', 1066 | description='leaf top axis', 1067 | items=axes, 1068 | default="+1") 1069 | leafScale: FloatProperty(name='Leaf Scale', 1070 | description='The scaling applied to the whole leaf (LeafScale)', 1071 | min=0.0, 1072 | default=0.17) 1073 | 1074 | armAnim: BoolProperty(name='Armature Animation', 1075 | description='Whether animation is added to the armature', 1076 | default=False) 1077 | previewArm: BoolProperty(name='Fast Preview', 1078 | description='Disable armature modifier, hide tree, and set bone display to wire, for fast playback', 1079 | ##Disable skin modifier and hide tree and armature, for fast playback 1080 | default=False) 1081 | leafAnim: BoolProperty(name='Leaf Animation', 1082 | description='Whether animation is added to the leaves', 1083 | default=False) 1084 | frameRate: FloatProperty(name='Animation Speed', 1085 | description=('Adjust speed of animation, relative to scene frame rate'), 1086 | min=0.001, 1087 | default=1) 1088 | loopFrames: IntProperty(name='Loop Frames', 1089 | description='Number of frames to make the animation loop for, zero is disabled', 1090 | min=0, 1091 | default=0) 1092 | 1093 | makeMesh: BoolProperty(name='Make Mesh', 1094 | description='Convert curves to mesh, uses skin modifier, enables armature simplification', 1095 | default=False) 1096 | armLevels: IntProperty(name='Armature Levels', 1097 | description='Number of branching levels to make bones for, 0 is all levels', 1098 | min=0, 1099 | default=2) 1100 | boneStep: IntVectorProperty(name='Bone Length', 1101 | description='Number of stem segments per bone', 1102 | min=1, 1103 | default=[1, 1, 1, 1], 1104 | size=4) 1105 | 1106 | @classmethod 1107 | def poll(cls, context): 1108 | return context.mode == 'OBJECT' 1109 | 1110 | def draw(self, context): 1111 | 1112 | layout = self.layout 1113 | 1114 | layout.prop(self, 'do_update', icon='CURVE_DATA') 1115 | 1116 | box = layout.box() 1117 | box.label(text="Geometry:") 1118 | 1119 | row = box.row() 1120 | row.menu('sapling.presetmenu', text='Load Preset') 1121 | 1122 | box.prop(self, 'seed') 1123 | box.prop(self, 'numTrees') 1124 | 1125 | box.prop(self, 'bevel') 1126 | 1127 | row = box.row() 1128 | row.prop(self, 'bevelRes') 1129 | row.prop(self, 'resU') 1130 | 1131 | box.label(text="Tree Scale:") 1132 | row = box.row() 1133 | row.prop(self, 'scale') 1134 | row.prop(self, 'scaleV') 1135 | 1136 | box = layout.box() 1137 | box.label(text="Leaves:") 1138 | 1139 | box.prop(self, 'showLeaves') 1140 | box.prop(self, 'leafShape') 1141 | box.prop(self, 'leafDupliObj') 1142 | row = box.row() 1143 | row.label(text="Leaf Object Axes:") 1144 | row.prop(self, 'leafObjZ') 1145 | row.prop(self, 'leafObjY') 1146 | 1147 | #box.prop(self, 'leaves') 1148 | box.prop(self, 'leafScale') 1149 | 1150 | box = layout.box() 1151 | box.label(text="Armature and Animation:") 1152 | 1153 | row = box.row() 1154 | row.prop(self, 'useArm') 1155 | row.prop(self, 'previewArm') 1156 | 1157 | row = box.row() 1158 | row.prop(self, 'armAnim') 1159 | row.prop(self, 'leafAnim') 1160 | 1161 | box.prop(self, 'frameRate') 1162 | box.prop(self, 'loopFrames') 1163 | 1164 | box.label(text="") 1165 | box.prop(self, 'makeMesh') 1166 | box.label(text="Armature Simplification:") 1167 | box.prop(self, 'armLevels') 1168 | box.prop(self, 'boneStep') 1169 | 1170 | 1171 | def execute(self, context): 1172 | # Ensure the use of the global variables 1173 | global settings, useSet 1174 | # If we need to set the properties from a preset then do it here 1175 | #presetAsDict 1176 | if useSet: 1177 | for a, b in settings.items(): 1178 | setattr(self, a, b) 1179 | useSet = False 1180 | if self.do_update: 1181 | #loop for multiple trees 1182 | initSeed = self.seed 1183 | for n in range(self.numTrees): 1184 | setattr(self, 'seed', self.seed + n) 1185 | space = 6 1186 | grid = ceil(self.numTrees ** .5) 1187 | x = (n // grid) * space 1188 | y = (n % grid) * space 1189 | bpy.context.scene.cursor.location = (x, y, 0) 1190 | addTree(self) 1191 | setattr(self, 'seed', initSeed) 1192 | self.do_update = False 1193 | return {'FINISHED'} 1194 | else: 1195 | return {'PASS_THROUGH'} 1196 | 1197 | def invoke(self, context, event): 1198 | # global settings, useSet 1199 | # useSet = True 1200 | bpy.ops.sapling.importdata(filename = "Default Tree.py") 1201 | return self.execute(context) 1202 | 1203 | 1204 | def menu_func(self, context): 1205 | self.layout.operator(AddTree.bl_idname, text="Add Tree 3.4", icon='PLUGIN') 1206 | def menu_func2(self, context): 1207 | self.layout.operator(AddMultipleTrees.bl_idname, text="Add Multiple Trees", icon='PLUGIN') 1208 | 1209 | classes = ( 1210 | AddTree, 1211 | AddMultipleTrees, 1212 | PresetMenu, 1213 | ImportData, 1214 | ExportData, 1215 | ) 1216 | 1217 | 1218 | def register(): 1219 | from bpy.utils import register_class 1220 | for cls in classes: 1221 | register_class(cls) 1222 | bpy.types.VIEW3D_MT_curve_add.append(menu_func) 1223 | bpy.types.VIEW3D_MT_curve_add.append(menu_func2) 1224 | 1225 | def unregister(): 1226 | from bpy.utils import unregister_class 1227 | for cls in reversed(classes): 1228 | unregister_class(cls) 1229 | bpy.types.VIEW3D_MT_curve_add.remove(menu_func2) 1230 | bpy.types.VIEW3D_MT_curve_add.remove(menu_func) 1231 | 1232 | if __name__ == "__main__": 1233 | register() 1234 | --------------------------------------------------------------------------------