Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijenstina <lijenstina@gmail.com>2017-04-08 01:24:05 +0300
committerlijenstina <lijenstina@gmail.com>2017-04-08 01:24:05 +0300
commit2aa13cb25adfe95bbc57f4c7442c91f020df5f2d (patch)
tree1c69c0adba1e4fc2105167bc040e32a31f44ec5e /add_curve_sapling/__init__.py
parent9bc76f9902e756c149695b2b3d86ebe2d690ae65 (diff)
Sapling Tree Gen: Cleanup, fix warning
Bumped version to 0.3.3 Fix star imports Pep8 cleanup Fix RNA Warning: Current value "0" matches no enum The EnumProperty function were passed an empty list if there were no adequate objects in the scene
Diffstat (limited to 'add_curve_sapling/__init__.py')
-rw-r--r--add_curve_sapling/__init__.py788
1 files changed, 495 insertions, 293 deletions
diff --git a/add_curve_sapling/__init__.py b/add_curve_sapling/__init__.py
index fd6f5e97..1c91c1c7 100644
--- a/add_curve_sapling/__init__.py
+++ b/add_curve_sapling/__init__.py
@@ -1,4 +1,4 @@
-#====================== BEGIN GPL LICENSE BLOCK ======================
+# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -14,18 +14,18 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-#======================= END GPL LICENSE BLOCK ========================
+# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "Sapling Tree Gen",
"author": "Andrew Hale (TrumanBlending), Aaron Buchler",
- "version": (0, 3, 2),
+ "version": (0, 3, 3),
"blender": (2, 77, 0),
"location": "View3D > Add > Curve",
"description": ("Adds a parametric tree. The method is presented by "
"Jason Weber & Joseph Penn in their paper 'Creation and Rendering of "
- "Realistic Trees'."),
- "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+ "Realistic Trees'"),
+ "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
"Scripts/Curve/Sapling_Tree",
"category": "Add Curve"}
@@ -40,14 +40,21 @@ import time
import os
import ast
-#import cProfile
-
-from mathutils import *
-from math import pi, sin, degrees, radians, atan2, copysign
-from random import random, uniform, seed, choice, getstate, setstate
-from bpy.props import *
-
-from add_curve_sapling.utils import *
+# import cProfile
+
+from bpy.types import (
+ Operator,
+ Menu,
+ )
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ FloatVectorProperty,
+ IntProperty,
+ IntVectorProperty,
+ StringProperty,
+ )
useSet = False
@@ -97,16 +104,17 @@ branchmodes = [("original", "Original", "rotate around each branch"),
("rotate", "Rotate", "evenly distribute branches to point outward from center of tree"),
("random", "Random", "choose random point")]
+
def getPresetpath():
"""Support user defined scripts directory
Find the first ocurrence of add_curve_sapling/presets in possible script paths
and return it as preset path"""
- #presetpath = ""
- #for p in bpy.utils.script_paths():
+ # presetpath = ""
+ # for p in bpy.utils.script_paths():
# presetpath = os.path.join(p, 'addons', 'add_curve_sapling_3', 'presets')
# if os.path.exists(presetpath):
# break
- #return presetpath
+ # return presetpath
# why not just do this
script_file = os.path.realpath(__file__)
@@ -114,6 +122,7 @@ def getPresetpath():
directory = os.path.join(directory, "presets")
return directory
+
def getPresetpaths():
"""Return paths for both local and user preset folders"""
userDir = os.path.join(bpy.utils.script_path_user(), 'presets', 'operator', 'add_curve_sapling')
@@ -129,7 +138,8 @@ def getPresetpaths():
return (localDir, userDir)
-class ExportData(bpy.types.Operator):
+
+class ExportData(Operator):
"""This operator handles writing presets to file"""
bl_idname = 'sapling.exportdata'
bl_label = 'Export Preset'
@@ -139,24 +149,24 @@ class ExportData(bpy.types.Operator):
def execute(self, context):
# Unpack some data from the input
data, filename, overwrite = eval(self.data)
-
-# try:
-# # Check whether the file exists by trying to open it.
-# f = open(os.path.join(getPresetpaths()[1], filename + '.py'), 'r')
-# f.close()
-# # If it exists then report an error
-# self.report({'ERROR_INVALID_INPUT'}, 'Preset Already Exists')
-# return {'CANCELLED'}
-# except IOError:
-# if data:
-# # If it doesn't exist, create the file with the required data
-# f = open(os.path.join(getPresetpaths()[1], filename + '.py'), 'w')
-# f.write(data)
-# f.close()
-# return {'FINISHED'}
-# else:
-# return {'CANCELLED'}
-
+ """
+ try:
+ # Check whether the file exists by trying to open it.
+ f = open(os.path.join(getPresetpaths()[1], filename + '.py'), 'r')
+ f.close()
+ # If it exists then report an error
+ self.report({'ERROR_INVALID_INPUT'}, 'Preset Already Exists')
+ return {'CANCELLED'}
+ except IOError:
+ if data:
+ # If it doesn't exist, create the file with the required data
+ f = open(os.path.join(getPresetpaths()[1], filename + '.py'), 'w')
+ f.write(data)
+ f.close()
+ return {'FINISHED'}
+ else:
+ return {'CANCELLED'}
+ """
fpath1 = os.path.join(getPresetpaths()[0], filename + '.py')
fpath2 = os.path.join(getPresetpaths()[1], filename + '.py')
@@ -165,7 +175,7 @@ class ExportData(bpy.types.Operator):
self.report({'ERROR_INVALID_INPUT'}, 'Can\'t have same name as built-in preset')
return {'CANCELLED'}
elif (not os.path.exists(fpath2)) or (os.path.exists(fpath2) and overwrite):
- #if (it does not exist) or (exists and overwrite) then write file
+ # if (it does not exist) or (exists and overwrite) then write file
if data:
# If it doesn't exist, create the file with the required data
f = open(os.path.join(getPresetpaths()[1], filename + '.py'), 'w')
@@ -179,10 +189,11 @@ class ExportData(bpy.types.Operator):
self.report({'ERROR_INVALID_INPUT'}, 'Preset Already Exists')
return {'CANCELLED'}
-class ImportData(bpy.types.Operator):
+
+class ImportData(Operator):
"""This operator handles importing existing presets"""
- bl_idname = 'sapling.importdata'
- bl_label = 'Import Preset'
+ bl_idname = "sapling.importdata"
+ bl_label = "Import Preset"
filename = StringProperty()
@@ -196,15 +207,15 @@ class ImportData(bpy.types.Operator):
f = open(os.path.join(getPresetpaths()[1], self.filename), 'r')
settings = f.readline()
f.close()
- #print(settings)
+ # print(settings)
settings = ast.literal_eval(settings)
- #use old attractup
+ # use old attractup
if type(settings['attractUp']) == float:
atr = settings['attractUp']
settings['attractUp'] = [0, 0, atr, atr]
- #use old leaf rotations
+ # use old leaf rotations
if 'leafDownAngle' not in settings:
l = settings['levels']
settings['leafDownAngle'] = settings['downAngle'][min(l, 3)]
@@ -212,14 +223,15 @@ class ImportData(bpy.types.Operator):
settings['leafRotate'] = settings['rotate'][min(l, 3)]
settings['leafRotateV'] = settings['rotateV'][min(l, 3)]
- #zero leaf bend
+ # zero leaf bend
settings['bend'] = 0
# Set the flag to use the settings
useSet = True
return {'FINISHED'}
-class PresetMenu(bpy.types.Menu):
+
+class PresetMenu(Menu):
"""Create the preset menu by finding all preset files
in the preset directory"""
bl_idname = "sapling.presetmenu"
@@ -234,7 +246,8 @@ class PresetMenu(bpy.types.Menu):
for p in presets:
layout.operator("sapling.importdata", text=p[:-3]).filename = p
-class AddTree(bpy.types.Operator):
+
+class AddTree(Operator):
bl_idname = "curve.tree_add"
bl_label = "Sapling: Add Tree"
bl_options = {'REGISTER', 'UNDO'}
@@ -242,16 +255,13 @@ class AddTree(bpy.types.Operator):
def objectList(self, context):
objects = []
bObjects = bpy.data.objects
-# try:
-# bObjects = bpy.data.objects
-# except AttributeError:
-# pass
-# else:
+
for obj in bObjects:
if (obj.type in ['MESH', 'CURVE', 'SURFACE']) and (obj.name not in ['tree', 'leaves']):
objects.append((obj.name, obj.name, ""))
- return objects
+ return (objects if objects else
+ [('NONE', "No objects", "No appropriate objects in the Scene")])
def update_tree(self, context):
self.do_update = True
@@ -265,419 +275,606 @@ class AddTree(bpy.types.Operator):
def no_update_tree(self, context):
self.do_update = False
- do_update = BoolProperty(name='Do Update',
- default=True, options={'HIDDEN'})
-
- chooseSet = EnumProperty(name='Settings',
+ do_update = BoolProperty(
+ name='Do Update',
+ default=True, options={'HIDDEN'}
+ )
+ chooseSet = EnumProperty(
+ name='Settings',
description='Choose the settings to modify',
items=settings,
- default='0', update=no_update_tree)
- bevel = BoolProperty(name='Bevel',
+ default='0', update=no_update_tree
+ )
+ bevel = BoolProperty(
+ name='Bevel',
description='Whether the curve is beveled',
- default=False, update=update_tree)
- prune = BoolProperty(name='Prune',
+ default=False, update=update_tree
+ )
+ prune = BoolProperty(
+ name='Prune',
description='Whether the tree is pruned',
- default=False, update=update_tree)
- showLeaves = BoolProperty(name='Show Leaves',
+ default=False, update=update_tree
+ )
+ showLeaves = BoolProperty(
+ name='Show Leaves',
description='Whether the leaves are shown',
- default=False, update=update_tree)
- useArm = BoolProperty(name='Use Armature',
+ default=False, update=update_tree
+ )
+ useArm = BoolProperty(
+ name='Use Armature',
description='Whether the armature is generated',
- default=False, update=update_tree)
- seed = IntProperty(name='Random Seed',
+ default=False, update=update_tree
+ )
+ seed = IntProperty(
+ name='Random Seed',
description='The seed of the random number generator',
- default=0, update=update_tree)
- handleType = IntProperty(name='Handle Type',
+ default=0, update=update_tree
+ )
+ handleType = IntProperty(
+ name='Handle Type',
description='The type of curve handles',
min=0,
max=1,
- default=0, update=update_tree)
- levels = IntProperty(name='Levels',
+ default=0, update=update_tree
+ )
+ levels = IntProperty(
+ name='Levels',
description='Number of recursive branches (Levels)',
min=1,
max=6,
soft_max=4,
- default=3, update=update_tree)
- length = FloatVectorProperty(name='Length',
+ default=3, update=update_tree
+ )
+ length = FloatVectorProperty(
+ name='Length',
description='The relative lengths of each branch level (nLength)',
min=0.000001,
default=[1, 0.3, 0.6, 0.45],
- size=4, update=update_tree)
- lengthV = FloatVectorProperty(name='Length Variation',
+ size=4, update=update_tree
+ )
+ lengthV = FloatVectorProperty(
+ name='Length Variation',
description='The relative length variations of each level (nLengthV)',
min=0.0,
max=1.0,
default=[0, 0, 0, 0],
- size=4, update=update_tree)
- taperCrown = FloatProperty(name='Taper Crown',
+ size=4, update=update_tree
+ )
+ taperCrown = FloatProperty(
+ name='Taper Crown',
description='Shorten trunk splits toward outside of tree',
min=0.0,
soft_max=1.0,
- default=0, update=update_tree)
- branches = IntVectorProperty(name='Branches',
+ default=0, update=update_tree
+ )
+ branches = IntVectorProperty(
+ name='Branches',
description='The number of branches grown at each level (nBranches)',
min=0,
default=[50, 30, 10, 10],
- size=4, update=update_tree)
- curveRes = IntVectorProperty(name='Curve Resolution',
+ size=4, update=update_tree
+ )
+ curveRes = IntVectorProperty(
+ name='Curve Resolution',
description='The number of segments on each branch (nCurveRes)',
min=1,
default=[3, 5, 3, 1],
- size=4, update=update_tree)
- curve = FloatVectorProperty(name='Curvature',
+ size=4, update=update_tree
+ )
+ curve = FloatVectorProperty(
+ name='Curvature',
description='The angle of the end of the branch (nCurve)',
default=[0, -40, -40, 0],
- size=4, update=update_tree)
- curveV = FloatVectorProperty(name='Curvature Variation',
+ size=4, update=update_tree
+ )
+ curveV = FloatVectorProperty(
+ name='Curvature Variation',
description='Variation of the curvature (nCurveV)',
default=[20, 50, 75, 0],
- size=4, update=update_tree)
- curveBack = FloatVectorProperty(name='Back Curvature',
+ size=4, update=update_tree
+ )
+ curveBack = FloatVectorProperty(
+ name='Back Curvature',
description='Curvature for the second half of a branch (nCurveBack)',
default=[0, 0, 0, 0],
- size=4, update=update_tree)
- baseSplits = IntProperty(name='Base Splits',
+ size=4, update=update_tree
+ )
+ baseSplits = IntProperty(
+ name='Base Splits',
description='Number of trunk splits at its base (nBaseSplits)',
min=0,
- default=0, update=update_tree)
- segSplits = FloatVectorProperty(name='Segment Splits',
+ default=0, update=update_tree
+ )
+ segSplits = FloatVectorProperty(
+ name='Segment Splits',
description='Number of splits per segment (nSegSplits)',
min=0,
soft_max=3,
default=[0, 0, 0, 0],
- size=4, update=update_tree)
- splitByLen = BoolProperty(name='Split relative to length',
+ size=4, update=update_tree
+ )
+ splitByLen = BoolProperty(
+ name='Split relative to length',
description='Split proportional to branch length',
- default=False, update=update_tree)
- rMode = EnumProperty(name="", #"Branching Mode"
+ default=False, update=update_tree
+ )
+ rMode = EnumProperty(
+ name="", # "Branching Mode"
description='Branching and Rotation Mode',
items=branchmodes,
- default="rotate", update=update_tree)
- splitAngle = FloatVectorProperty(name='Split Angle',
+ default="rotate", update=update_tree
+ )
+ splitAngle = FloatVectorProperty(
+ name='Split Angle',
description='Angle of branch splitting (nSplitAngle)',
default=[0, 0, 0, 0],
- size=4, update=update_tree)
- splitAngleV = FloatVectorProperty(name='Split Angle Variation',
+ size=4, update=update_tree
+ )
+ splitAngleV = FloatVectorProperty(
+ name='Split Angle Variation',
description='Variation in the split angle (nSplitAngleV)',
default=[0, 0, 0, 0],
- size=4, update=update_tree)
- scale = FloatProperty(name='Scale',
+ size=4, update=update_tree
+ )
+ scale = FloatProperty(
+ name='Scale',
description='The tree scale (Scale)',
min=0.0,
default=13.0, update=update_tree)
scaleV = FloatProperty(name='Scale Variation',
description='The variation in the tree scale (ScaleV)',
- default=3.0, update=update_tree)
- attractUp = FloatVectorProperty(name='Vertical Attraction',
+ default=3.0, update=update_tree
+ )
+ attractUp = FloatVectorProperty(
+ name='Vertical Attraction',
description='Branch upward attraction',
default=[0, 0, 0, 0],
- size=4, update=update_tree)
- attractOut = FloatVectorProperty(name='Outward Attraction',
+ size=4, update=update_tree
+ )
+ attractOut = FloatVectorProperty(
+ name='Outward Attraction',
description='Branch outward attraction',
default=[0, 0, 0, 0],
min=0.0,
max=1.0,
- size=4, update=update_tree)
- shape = EnumProperty(name='Shape',
+ size=4, update=update_tree
+ )
+ shape = EnumProperty(
+ name='Shape',
description='The overall shape of the tree (Shape)',
items=shapeList3,
- default='7', update=update_tree)
- shapeS = EnumProperty(name='Secondary Branches Shape',
+ default='7', update=update_tree
+ )
+ shapeS = EnumProperty(
+ name='Secondary Branches Shape',
description='The shape of secondary splits',
items=shapeList4,
- default='4', update=update_tree)
- customShape = FloatVectorProperty(name='Custom Shape',
+ default='4', update=update_tree
+ )
+ customShape = FloatVectorProperty(
+ name='Custom Shape',
description='custom shape branch length at (Base, Middle, Middle Position, Top)',
size=4,
min=.01,
max=1,
- default=[.5, 1.0, .3, .5], update=update_tree)
- branchDist = FloatProperty(name='Branch Distribution',
+ default=[.5, 1.0, .3, .5], update=update_tree
+ )
+ branchDist = FloatProperty(
+ name='Branch Distribution',
description='Adjust branch spacing to put more branches at the top or bottom of the tree',
min=0.1,
soft_max=10,
- default=1.0, update=update_tree)
- nrings = IntProperty(name='Branch Rings',
+ default=1.0, update=update_tree
+ )
+ nrings = IntProperty(
+ name='Branch Rings',
description='grow branches in rings',
min=0,
- default=0, update=update_tree)
- baseSize = FloatProperty(name='Trunk Height',
+ default=0, update=update_tree
+ )
+ baseSize = FloatProperty(
+ name='Trunk Height',
description='Fraction of tree height with no branches (Base Size)',
min=0.0,
max=1.0,
- default=0.4, update=update_tree)
- baseSize_s = FloatProperty(name='Secondary Base Size',
+ default=0.4, update=update_tree
+ )
+ baseSize_s = FloatProperty(
+ name='Secondary Base Size',
description='Factor to decrease base size for each level',
min=0.0,
max=1.0,
- default=0.25, update=update_tree)
- splitHeight = FloatProperty(name='Split Height',
+ default=0.25, update=update_tree
+ )
+ splitHeight = FloatProperty(
+ name='Split Height',
description='Fraction of tree height with no splits',
min=0.0,
max=1.0,
- default=0.2, update=update_tree)
- splitBias = FloatProperty(name='splitBias',
+ default=0.2, update=update_tree
+ )
+ splitBias = FloatProperty(
+ name='splitBias',
description='Put more splits at the top or bottom of the tree',
soft_min=-2.0,
soft_max=2.0,
- default=0.0, update=update_tree)
- ratio = FloatProperty(name='Ratio',
+ default=0.0, update=update_tree
+ )
+ ratio = FloatProperty(
+ name='Ratio',
description='Base radius size (Ratio)',
min=0.0,
- default=0.015, update=update_tree)
- minRadius = FloatProperty(name='Minimum Radius',
+ default=0.015, update=update_tree
+ )
+ minRadius = FloatProperty(
+ name='Minimum Radius',
description='Minimum branch Radius',
min=0.0,
- default=0.0, update=update_tree)
- closeTip = BoolProperty(name='Close Tip',
+ default=0.0, update=update_tree
+ )
+ closeTip = BoolProperty(
+ name='Close Tip',
description='Set radius at branch tips to zero',
- default=False, update=update_tree)
- rootFlare = FloatProperty(name='Root Flare',
+ default=False, update=update_tree
+ )
+ rootFlare = FloatProperty(
+ name='Root Flare',
description='Root radius factor',
min=1.0,
- default=1.0, update=update_tree)
- autoTaper = BoolProperty(name='Auto Taper',
+ default=1.0, update=update_tree
+ )
+ autoTaper = BoolProperty(
+ name='Auto Taper',
description='Calculate taper automaticly based on branch lengths',
- default=True, update=update_tree)
- taper = FloatVectorProperty(name='Taper',
+ default=True, update=update_tree
+ )
+ taper = FloatVectorProperty(
+ name='Taper',
description='The fraction of tapering on each branch (nTaper)',
min=0.0,
max=1.0,
default=[1, 1, 1, 1],
- size=4, update=update_tree)
- radiusTweak = FloatVectorProperty(name='Tweak Radius',
+ size=4, update=update_tree
+ )
+ radiusTweak = FloatVectorProperty(
+ name='Tweak Radius',
description='multiply radius by this factor',
min=0.0,
max=1.0,
default=[1, 1, 1, 1],
- size=4, update=update_tree)
- ratioPower = FloatProperty(name='Branch Radius Ratio',
+ size=4, update=update_tree
+ )
+ ratioPower = FloatProperty(
+ name='Branch Radius Ratio',
description=('Power which defines the radius of a branch compared to '
'the radius of the branch it grew from (RatioPower)'),
min=0.0,
- default=1.2, update=update_tree)
- downAngle = FloatVectorProperty(name='Down Angle',
+ default=1.2, update=update_tree
+ )
+ downAngle = FloatVectorProperty(
+ name='Down Angle',
description=('The angle between a new branch and the one it grew '
'from (nDownAngle)'),
default=[90, 60, 45, 45],
- size=4, update=update_tree)
- downAngleV = FloatVectorProperty(name='Down Angle Variation',
- description='Angle to decrease Down Angle by towards end of parent branch (negative values add random variation)',
+ size=4, update=update_tree
+ )
+ downAngleV = FloatVectorProperty(
+ name='Down Angle Variation',
+ description="Angle to decrease Down Angle by towards end of parent branch "
+ "(negative values add random variation)",
default=[0, -50, 10, 10],
- size=4, update=update_tree)
- useOldDownAngle = BoolProperty(name='Use old down angle variation',
- default=False, update=update_tree)
- useParentAngle = BoolProperty(name = 'Use parent angle',
- description = '(first level) Rotate branch to match parent branch',
- default=True, update=update_tree)
- rotate = FloatVectorProperty(name='Rotate Angle',
- description='The angle of a new branch around the one it grew from (negative values rotate opposite from the previous)',
+ size=4, update=update_tree
+ )
+ useOldDownAngle = BoolProperty(
+ name='Use old down angle variation',
+ default=False, update=update_tree
+ )
+ useParentAngle = BoolProperty(
+ name='Use parent angle',
+ description='(first level) Rotate branch to match parent branch',
+ default=True, update=update_tree
+ )
+ rotate = FloatVectorProperty(
+ name='Rotate Angle',
+ description="The angle of a new branch around the one it grew from "
+ "(negative values rotate opposite from the previous)",
default=[137.5, 137.5, 137.5, 137.5],
- size=4, update=update_tree)
- rotateV = FloatVectorProperty(name='Rotate Angle Variation',
+ size=4, update=update_tree
+ )
+ rotateV = FloatVectorProperty(
+ name='Rotate Angle Variation',
description='Variation in the rotate angle (nRotateV)',
default=[0, 0, 0, 0],
- size=4, update=update_tree)
- scale0 = FloatProperty(name='Radius Scale',
+ size=4, update=update_tree
+ )
+ scale0 = FloatProperty(
+ name='Radius Scale',
description='The scale of the trunk radius (0Scale)',
min=0.0,
- default=1.0, update=update_tree)
- scaleV0 = FloatProperty(name='Radius Scale Variation',
+ default=1.0, update=update_tree
+ )
+ scaleV0 = FloatProperty(
+ name='Radius Scale Variation',
description='Variation in the radius scale (0ScaleV)',
min=0.0,
max=1.0,
- default=0.2, update=update_tree)
- pruneWidth = FloatProperty(name='Prune Width',
+ default=0.2, update=update_tree
+ )
+ pruneWidth = FloatProperty(
+ name='Prune Width',
description='The width of the envelope (PruneWidth)',
min=0.0,
- default=0.4, update=update_tree)
- pruneBase = FloatProperty(name='Prune Base Height',
+ default=0.4, update=update_tree
+ )
+ pruneBase = FloatProperty(
+ name='Prune Base Height',
description='The height of the base of the envelope, bound by trunk height',
min=0.0,
max=1.0,
- default=0.3, update=update_tree)
- pruneWidthPeak = FloatProperty(name='Prune Width Peak',
- description=('Fraction of envelope height where the maximum width '
- 'occurs (PruneWidthPeak)'),
+ default=0.3, update=update_tree
+ )
+ pruneWidthPeak = FloatProperty(
+ name='Prune Width Peak',
+ description=("Fraction of envelope height where the maximum width "
+ "occurs (PruneWidthPeak)"),
min=0.0,
- default=0.6, update=update_tree)
- prunePowerHigh = FloatProperty(name='Prune Power High',
+ default=0.6, update=update_tree
+ )
+ prunePowerHigh = FloatProperty(
+ name='Prune Power High',
description=('Power which determines the shape of the upper portion '
'of the envelope (PrunePowerHigh)'),
- default=0.5, update=update_tree)
- prunePowerLow = FloatProperty(name='Prune Power Low',
+ default=0.5, update=update_tree
+ )
+ prunePowerLow = FloatProperty(
+ name='Prune Power Low',
description=('Power which determines the shape of the lower portion '
'of the envelope (PrunePowerLow)'),
- default=0.001, update=update_tree)
- pruneRatio = FloatProperty(name='Prune Ratio',
+ default=0.001, update=update_tree
+ )
+ pruneRatio = FloatProperty(
+ name='Prune Ratio',
description='Proportion of pruned length (PruneRatio)',
min=0.0,
max=1.0,
- default=1.0, update=update_tree)
- leaves = IntProperty(name='Leaves',
- description='Maximum number of leaves per branch (negative values grow leaves from branch tip (palmate compound leaves))',
- default=25, update=update_tree)
-
- leafDownAngle = FloatProperty(name='Leaf Down Angle',
+ default=1.0, update=update_tree
+ )
+ leaves = IntProperty(
+ name='Leaves',
+ description="Maximum number of leaves per branch (negative values grow "
+ "leaves from branch tip (palmate compound leaves))",
+ default=25, update=update_tree
+ )
+ leafDownAngle = FloatProperty(
+ name='Leaf Down Angle',
description='The angle between a new leaf and the branch it grew from',
- default=45, update=update_leaves)
- leafDownAngleV = FloatProperty(name='Leaf Down Angle Variation',
- description='Angle to decrease Down Angle by towards end of parent branch (negative values add random variation)',
- default=10, update=update_tree)
- leafRotate = FloatProperty(name='Leaf Rotate Angle',
- description='The angle of a new leaf around the one it grew from (negative values rotate opposite from previous)',
- default=137.5, update=update_tree)
- leafRotateV = FloatProperty(name='Leaf Rotate Angle Variation',
+ default=45, update=update_leaves
+ )
+ leafDownAngleV = FloatProperty(
+ name='Leaf Down Angle Variation',
+ description="Angle to decrease Down Angle by towards end of parent branch "
+ "(negative values add random variation)",
+ default=10, update=update_tree
+ )
+ leafRotate = FloatProperty(
+ name='Leaf Rotate Angle',
+ description="The angle of a new leaf around the one it grew from "
+ "(negative values rotate opposite from previous)",
+ default=137.5, update=update_tree
+ )
+ leafRotateV = FloatProperty(
+ name='Leaf Rotate Angle Variation',
description='Variation in the rotate angle',
- default=0.0, update=update_leaves)
-
- leafScale = FloatProperty(name='Leaf Scale',
+ default=0.0, update=update_leaves
+ )
+ leafScale = FloatProperty(
+ name='Leaf Scale',
description='The scaling applied to the whole leaf (LeafScale)',
min=0.0,
- default=0.17, update=update_leaves)
- leafScaleX = FloatProperty(name='Leaf Scale X',
+ default=0.17, update=update_leaves
+ )
+ leafScaleX = FloatProperty(
+ name='Leaf Scale X',
description=('The scaling applied to the x direction of the leaf '
'(LeafScaleX)'),
min=0.0,
- default=1.0, update=update_leaves)
- leafScaleT = FloatProperty(name='Leaf Scale Taper',
+ default=1.0, update=update_leaves
+ )
+ leafScaleT = FloatProperty(
+ name='Leaf Scale Taper',
description='scale leaves toward the tip or base of the patent branch',
- min = -1.0,
- max = 1.0,
- default=0.0, update=update_leaves)
- leafScaleV = FloatProperty(name='Leaf Scale Variation',
+ min=-1.0,
+ max=1.0,
+ default=0.0, update=update_leaves
+ )
+ leafScaleV = FloatProperty(
+ name='Leaf Scale Variation',
description='randomize leaf scale',
- min = 0.0,
- max = 1.0,
- default=0.0, update=update_leaves)
- leafShape = EnumProperty(name='Leaf Shape',
+ min=0.0,
+ max=1.0,
+ default=0.0, update=update_leaves
+ )
+ leafShape = EnumProperty(
+ name='Leaf Shape',
description='The shape of the leaves',
- items=(('hex', 'Hexagonal', '0'), ('rect', 'Rectangular', '1'), ('dFace', 'DupliFaces', '2'), ('dVert', 'DupliVerts', '3')),
- default='hex', update=update_leaves)
- leafDupliObj = EnumProperty(name='Leaf Object',
+ items=(('hex', 'Hexagonal', '0'), ('rect', 'Rectangular', '1'),
+ ('dFace', 'DupliFaces', '2'), ('dVert', 'DupliVerts', '3')),
+ default='hex', update=update_leaves
+ )
+ leafDupliObj = EnumProperty(
+ name='Leaf Object',
description='Object to use for leaf instancing if Leaf Shape is DupliFaces or DupliVerts',
items=objectList,
- update=update_leaves)
-
-# bend = FloatProperty(name='Leaf Bend',
-# description='The proportion of bending applied to the leaf (Bend)',
-# min=0.0,
-# max=1.0,
-# default=0.0, update=update_leaves)
-
- leafangle = FloatProperty(name='Leaf Angle',
+ update=update_leaves
+ )
+ """
+ bend = FloatProperty(
+ name='Leaf Bend',
+ description='The proportion of bending applied to the leaf (Bend)',
+ min=0.0,
+ max=1.0,
+ default=0.0, update=update_leaves
+ )
+ """
+ leafangle = FloatProperty(
+ name='Leaf Angle',
description='Leaf vertical attraction',
- default=0.0, update=update_leaves)
- horzLeaves = BoolProperty(name='Horizontal leaves',
+ default=0.0, update=update_leaves
+ )
+ horzLeaves = BoolProperty(
+ name='Horizontal leaves',
description='Leaves face upwards',
- default=True, update=update_leaves)
- leafDist = EnumProperty(name='Leaf Distribution',
+ default=True, update=update_leaves
+ )
+ leafDist = EnumProperty(
+ name='Leaf Distribution',
description='The way leaves are distributed on branches',
items=shapeList4,
- default='6', update=update_tree)
- bevelRes = IntProperty(name='Bevel Resolution',
+ default='6', update=update_tree
+ )
+ bevelRes = IntProperty(
+ name='Bevel Resolution',
description='The bevel resolution of the curves',
min=0,
max=32,
- default=0, update=update_tree)
- resU = IntProperty(name='Curve Resolution',
+ default=0, update=update_tree
+ )
+ resU = IntProperty(
+ name='Curve Resolution',
description='The resolution along the curves',
min=1,
- default=4, update=update_tree)
- handleType = EnumProperty(name='Handle Type',
+ default=4, update=update_tree
+ )
+ handleType = EnumProperty(
+ name='Handle Type',
description='The type of handles used in the spline',
items=handleList,
- default='0', update=update_tree)
-
- armAnim = BoolProperty(name='Armature Animation',
+ default='0', update=update_tree
+ )
+ armAnim = BoolProperty(
+ name='Armature Animation',
description='Whether animation is added to the armature',
- default=False, update=update_tree)
- previewArm = BoolProperty(name='Fast Preview',
+ default=False, update=update_tree
+ )
+ previewArm = BoolProperty(
+ name='Fast Preview',
description='Disable armature modifier, hide tree, and set bone display to wire, for fast playback',
- ##Disable skin modifier and hide tree and armature, for fast playback
- default=False, update=update_tree)
- leafAnim = BoolProperty(name='Leaf Animation',
+ # Disable skin modifier and hide tree and armature, for fast playback
+ default=False, update=update_tree
+ )
+ leafAnim = BoolProperty(
+ name='Leaf Animation',
description='Whether animation is added to the leaves',
- default=False, update=update_tree)
- frameRate = FloatProperty(name='Animation Speed',
+ default=False, update=update_tree
+ )
+ frameRate = FloatProperty(
+ name='Animation Speed',
description=('Adjust speed of animation, relative to scene frame rate'),
min=0.001,
- default=1, update=update_tree)
- loopFrames = IntProperty(name='Loop Frames',
+ default=1, update=update_tree
+ )
+ loopFrames = IntProperty(
+ name='Loop Frames',
description='Number of frames to make the animation loop for, zero is disabled',
min=0,
- default=0, update=update_tree)
-
-# windSpeed = FloatProperty(name='Wind Speed',
-# description='The wind speed to apply to the armature',
-# default=2.0, update=update_tree)
-# windGust = FloatProperty(name='Wind Gust',
-# description='The greatest increase over Wind Speed',
-# default=0.0, update=update_tree)
-
- wind= FloatProperty(name='Overall Wind Strength',
+ default=0, update=update_tree
+ )
+ """
+ windSpeed = FloatProperty(
+ name='Wind Speed',
+ description='The wind speed to apply to the armature',
+ default=2.0, update=update_tree
+ )
+ windGust = FloatProperty(
+ name='Wind Gust',
+ description='The greatest increase over Wind Speed',
+ default=0.0, update=update_tree
+ )
+ """
+ wind = FloatProperty(
+ name='Overall Wind Strength',
description='The intensity of the wind to apply to the armature',
- default=1.0, update=update_tree)
-
- gust = FloatProperty(name='Wind Gust Strength',
+ default=1.0, update=update_tree
+ )
+ gust = FloatProperty(
+ name='Wind Gust Strength',
description='The amount of directional movement, (from the positive Y direction)',
- default=1.0, update=update_tree)
-
- gustF = FloatProperty(name='Wind Gust Fequency',
+ default=1.0, update=update_tree
+ )
+ gustF = FloatProperty(
+ name='Wind Gust Fequency',
description='The Fequency of directional movement',
- default=0.075, update=update_tree)
-
- af1 = FloatProperty(name='Amplitude',
+ default=0.075, update=update_tree
+ )
+ af1 = FloatProperty(
+ name='Amplitude',
description='Multiplier for noise amplitude',
- default=1.0, update=update_tree)
- af2 = FloatProperty(name='Frequency',
+ default=1.0, update=update_tree
+ )
+ af2 = FloatProperty(
+ name='Frequency',
description='Multiplier for noise fequency',
- default=1.0, update=update_tree)
- af3 = FloatProperty(name='Randomness',
+ default=1.0, update=update_tree
+ )
+ af3 = FloatProperty(
+ name='Randomness',
description='Random offset in noise',
- default=4.0, update=update_tree)
-
- makeMesh = BoolProperty(name='Make Mesh',
+ default=4.0, update=update_tree
+ )
+ makeMesh = BoolProperty(
+ name='Make Mesh',
description='Convert curves to mesh, uses skin modifier, enables armature simplification',
- default=False, update=update_tree)
- armLevels = IntProperty(name='Armature Levels',
+ default=False, update=update_tree
+ )
+ armLevels = IntProperty(
+ name='Armature Levels',
description='Number of branching levels to make bones for, 0 is all levels',
min=0,
- default=2, update=update_tree)
- boneStep = IntVectorProperty(name='Bone Length',
+ default=2, update=update_tree
+ )
+ boneStep = IntVectorProperty(
+ name='Bone Length',
description='Number of stem segments per bone',
min=1,
default=[1, 1, 1, 1],
- size=4, update=update_tree)
-
- presetName = StringProperty(name='Preset Name',
+ size=4, update=update_tree
+ )
+ presetName = StringProperty(
+ name='Preset Name',
description='The name of the preset to be saved',
default='',
- subtype='FILE_NAME', update=no_update_tree)
- limitImport = BoolProperty(name='Limit Import',
+ subtype='FILE_NAME', update=no_update_tree
+ )
+ limitImport = BoolProperty(
+ name='Limit Import',
description='Limited imported tree to 2 levels & no leaves for speed',
- default=True, update=no_update_tree)
- overwrite = BoolProperty(name='Overwrite',
+ default=True, update=no_update_tree
+ )
+ overwrite = BoolProperty(
+ name='Overwrite',
description='When checked, overwrite existing preset files when saving',
- default=False, update=no_update_tree)
-
-# startCurv = FloatProperty(name='Trunk Starting Angle',
-# description=('The angle between vertical and the starting direction '
-# 'of the trunk'),
-# min=0.0,
-# max=360,
-# default=0.0, update=update_tree)
+ default=False, update=no_update_tree
+ )
+ """
+ startCurv = FloatProperty(
+ name='Trunk Starting Angle',
+ description=('The angle between vertical and the starting direction'
+ 'of the trunk'),
+ min=0.0,
+ max=360,
+ default=0.0, update=update_tree
+ )
+ """
@classmethod
def poll(cls, context):
return context.mode == 'OBJECT'
def draw(self, context):
-
layout = self.layout
# Branch specs
- #layout.label('Tree Definition')
+ # layout.label('Tree Definition')
layout.prop(self, 'chooseSet')
@@ -711,7 +908,9 @@ class AddTree(bpy.types.Operator):
# Unfortunately as_keyword doesn't work with vector properties,
# so we need something custom. This is it
data = []
- for a, b in (self.as_keywords(ignore=("chooseSet", "presetName", "limitImport", "do_update", "overwrite", "leafDupliObj"))).items():
+ for a, b in (self.as_keywords(
+ ignore=("chooseSet", "presetName", "limitImport",
+ "do_update", "overwrite", "leafDupliObj"))).items():
# If the property is a vector property then add the slice to the list
try:
len(b)
@@ -856,8 +1055,8 @@ class AddTree(bpy.types.Operator):
box.prop(self, 'horzLeaves')
box.prop(self, 'leafangle')
- #box.label(" ")
- #box.prop(self, 'bend')
+ # box.label(" ")
+ # box.prop(self, 'bend')
elif self.chooseSet == '6':
box = layout.box()
@@ -878,9 +1077,9 @@ class AddTree(bpy.types.Operator):
box.prop(self, 'frameRate')
box.prop(self, 'loopFrames')
- #row = box.row()
- #row.prop(self, 'windSpeed')
- #row.prop(self, 'windGust')
+ # row = box.row()
+ # row.prop(self, 'windSpeed')
+ # row.prop(self, 'windGust')
box.label('Wind Settings:')
box.prop(self, 'wind')
@@ -897,7 +1096,7 @@ class AddTree(bpy.types.Operator):
# Ensure the use of the global variables
global settings, useSet
start_time = time.time()
- #bpy.ops.ImportData.filename = "quaking_aspen"
+ # bpy.ops.ImportData.filename = "quaking_aspen"
# If we need to set the properties from a preset then do it here
if useSet:
for a, b in settings.items():
@@ -908,29 +1107,32 @@ class AddTree(bpy.types.Operator):
useSet = False
if not self.do_update:
return {'PASS_THROUGH'}
- addTree(self)
- #cProfile.runctx("addTree(self)", globals(), locals())
- print("Tree creation in %0.1fs" %(time.time()-start_time))
+ utils.addTree(self)
+ # cProfile.runctx("addTree(self)", globals(), locals())
+ print("Tree creation in %0.1fs" % (time.time() - start_time))
+
return {'FINISHED'}
def invoke(self, context, event):
-# global settings, useSet
-# useSet = True
- bpy.ops.sapling.importdata(filename = "quaking_aspen.py")
+ bpy.ops.sapling.importdata(filename="quaking_aspen.py")
return self.execute(context)
+
def menu_func(self, context):
self.layout.operator(AddTree.bl_idname, text="Sapling Tree Gen", icon='CURVE_DATA')
+
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_curve_add.append(menu_func)
+
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_curve_add.remove(menu_func)
+
if __name__ == "__main__":
register()