[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2078] contrib/py/scripts/addons/ add_curve_sapling: - Updated to 2.58 API
Andrew Hale
TrumanBlending at gmail.com
Thu Jun 30 07:09:44 CEST 2011
Revision: 2078
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2078
Author: trumanblending
Date: 2011-06-30 05:09:43 +0000 (Thu, 30 Jun 2011)
Log Message:
-----------
- Updated to 2.58 API
- Added the ability to start the tree at an angle to the ground via startCurv
- Fixed an issue where, even if the seed value was the same, the tree generated would be different
- Fixed calculation of upward attraction for correct implementation
- Added presets for CA Black Oak and Weeping Willow.
Modified Paths:
--------------
contrib/py/scripts/addons/add_curve_sapling/__init__.py
contrib/py/scripts/addons/add_curve_sapling/presets/black_tupelo.py
contrib/py/scripts/addons/add_curve_sapling/presets/quaking_aspen.py
contrib/py/scripts/addons/add_curve_sapling/utils.py
Added Paths:
-----------
contrib/py/scripts/addons/add_curve_sapling/presets/ca_black_oak.py
contrib/py/scripts/addons/add_curve_sapling/presets/weeping_willow.py
Modified: contrib/py/scripts/addons/add_curve_sapling/__init__.py
===================================================================
--- contrib/py/scripts/addons/add_curve_sapling/__init__.py 2011-06-29 19:46:48 UTC (rev 2077)
+++ contrib/py/scripts/addons/add_curve_sapling/__init__.py 2011-06-30 05:09:43 UTC (rev 2078)
@@ -19,19 +19,21 @@
bl_info = {
"name": "Sapling",
"author": "Andrew Hale (TrumanBlending)",
- "version": (0,2),
- "blender": (2, 5, 7),
- "api": 36147,
+ "version": (0, 2, 1),
+ "blender": (2, 5, 8),
+ "api": 37702,
"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'.",
- "warning": "", # used for warning icon and text in addons panel
+ "description": ("Adds a parametric tree. The method is presented by "
+ "Jason Weber & Joseph Penn in their paper 'Creation and Rendering of "
+ "Realistic Trees'."),
+ "warning": "", # used for warning icon and text in addons panel
"wiki_url": "",
"tracker_url": "",
"category": "Add Curve"}
if "bpy" in locals():
import imp
- imp.reload(utils2)
+ imp.reload(utils)
else:
from add_curve_sapling import utils
@@ -41,8 +43,8 @@
#from utils import *
from mathutils import *
-from math import pi,sin,degrees,radians,atan2,copysign
-from random import random,uniform,seed,choice,getstate,setstate
+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 *
@@ -50,84 +52,90 @@
#global splitError
useSet = False
-shapeList = [('0','Conical','Shape = 0'),
- ('1','Spherical','Shape = 1'),
- ('2','Hemispherical','Shape = 2'),
- ('3','Cylindrical','Shape = 3'),
- ('4','Tapered Cylindrical','Shape = 4'),
- ('5','Flame','Shape = 5'),
- ('6','Inverse Conical','Shape = 6'),
- ('7','Tend Flame','Shape = 7')]
+shapeList = [('0', 'Conical', 'Shape = 0'),
+ ('1', 'Spherical', 'Shape = 1'),
+ ('2', 'Hemispherical', 'Shape = 2'),
+ ('3', 'Cylindrical', 'Shape = 3'),
+ ('4', 'Tapered Cylindrical', 'Shape = 4'),
+ ('5', 'Flame', 'Shape = 5'),
+ ('6', 'Inverse Conical', 'Shape = 6'),
+ ('7', 'Tend Flame', 'Shape = 7')]
-handleList = [('0','Auto','Auto'),
- ('1','Vector','Vector')]
+handleList = [('0', 'Auto', 'Auto'),
+ ('1', 'Vector', 'Vector')]
-settings = [('0','Geometry','Geometry'),
- ('1','Branch Splitting','Branch Splitting'),
- ('2','Branch Growth','Branch Growth'),
- ('3','Pruning','Pruning'),
- ('4','Leaves','Leaves'),
- ('5','Armature','Armature')]
+settings = [('0', 'Geometry', 'Geometry'),
+ ('1', 'Branch Splitting', 'Branch Splitting'),
+ ('2', 'Branch Growth', 'Branch Growth'),
+ ('3', 'Pruning', 'Pruning'),
+ ('4', 'Leaves', 'Leaves'),
+ ('5', 'Armature', 'Armature')]
-# This operator handles writing presets to file
+
class ExportData(bpy.types.Operator):
+ '''This operator handles writing presets to file'''
bl_idname = 'sapling.export'
bl_label = 'Export Preset'
-
+
data = StringProperty()
-
- def execute(self,context):
+
+ def execute(self, context):
# Unpack some data from the input
- data,filename = eval(self.data)
+ data, filename = eval(self.data)
try:
# Check whether the file exists by trying to open it.
- f = open('2.57//scripts//addons//add_curve_sapling//presets//'+filename + '.py','r')
+ f = open(os.path.join(bpy.utils.script_paths()[0], 'addons', 'add_curve_sapling', 'presets', filename + '.py'), 'r')
f.close()
# If it exists then report an error
- self.report({'ERROR_INVALID_INPUT'},'Preset Already Exists')
+ self.report({'ERROR_INVALID_INPUT'}, 'Preset Already Exists')
return {'CANCELLED'}
except IOError:
if data:
- # If it doesn't exist, create the file and write the required data
- f = open('2.57//scripts//addons//add_curve_sapling//presets//'+filename + '.py','w')
+ # If it doesn't exist, create the file with the required data
+ f = open(os.path.join(bpy.utils.script_paths()[0], 'addons', 'add_curve_sapling', 'presets', filename + '.py'), 'w')
f.write(data)
f.close()
return {'FINISHED'}
else:
return {'CANCELLED'}
-# This operator handles importing existing presets
+
class ImportData(bpy.types.Operator):
+ '''This operator handles importing existing presets'''
bl_idname = 'sapling.import'
bl_label = 'Import Preset'
filename = StringProperty()
-
- def execute(self,context):
+
+ def execute(self, context):
# Make sure the operator knows about the global variables
- global settings,useSet
+ global settings, useSet
# Read the preset data into the global settings
- f = open('2.57//scripts//addons//add_curve_sapling//presets//'+self.filename,'r')
+ f = open(os.path.join(bpy.utils.script_paths()[0], 'addons', 'add_curve_sapling', 'presets', self.filename), 'r')
settings = f.readline()
f.close()
- settings=eval(settings)
+ settings = eval(settings)
# Set the flag to use the settings
useSet = True
return {'FINISHED'}
-# Create the preset menu by finding all preset files in the preset directory
+
class PresetMenu(bpy.types.Menu):
+ '''Create the preset menu by finding all preset files
+ in the preset directory
+ '''
bl_idname = "sapling.presetmenu"
bl_label = "Presets"
-
+
def draw(self, context):
# Get all the sapling presets
- presets = [a for a in os.listdir('2.57//scripts//addons//add_curve_sapling//presets') if a[-3:] == '.py']
+ presets = [a for a in os.listdir(os.path.join(bpy.utils.script_paths()[0], 'addons', 'add_curve_sapling', 'presets')) if a[-3:] == '.py']
layout = self.layout
# Append all to the menu
for p in presets:
- layout.operator("sapling.import",text=p[:-3]).filename=p
+ layout.operator("sapling.import", text=p[:-3]).filename = p
+
class AddTree(bpy.types.Operator):
bl_idname = "curve.tree_add"
bl_label = "Sapling"
@@ -165,34 +173,34 @@
length = FloatVectorProperty(name='Length',
description='The relative lengths of each branch level (nLength)',
min=0.0,
- default=[1,0.3,0.6,0.45],
+ default=[1, 0.3, 0.6, 0.45],
size=4)
lengthV = FloatVectorProperty(name='Length Variation',
- description='The relative length variations of each branch level (nLengthV)',
+ description='The relative length variations of each level (nLengthV)',
min=0.0,
- default=[0,0,0,0],
+ default=[0, 0, 0, 0],
size=4)
branches = IntVectorProperty(name='Branches',
- description='The number of branches sprouted at each level (nBranches)',
+ description='The number of branches grown at each level (nBranches)',
min=0,
- default=[50,30,10,10],
+ default=[50, 30, 10, 10],
size=4)
curveRes = IntVectorProperty(name='Curve Resolution',
description='The number of segments on each branch (nCurveRes)',
min=1,
- default=[3,5,3,1],
+ default=[3, 5, 3, 1],
size=4)
curve = FloatVectorProperty(name='Curvature',
description='The angle of the end of the branch (nCurve)',
- default=[0,-40,-40,0],
+ default=[0, -40, -40, 0],
size=4)
curveV = FloatVectorProperty(name='Curvature Variation',
description='Variation of the curvature (nCurveV)',
- default=[20,50,75,0],
+ default=[20, 50, 75, 0],
size=4)
curveBack = FloatVectorProperty(name='Back Curvature',
description='Curvature for the second half of a branch (nCurveBack)',
- default=[0,0,0,0],
+ default=[0, 0, 0, 0],
size=4)
baseSplits = IntProperty(name='Base Splits',
description='Number of trunk splits at its base (nBaseSplits)',
@@ -201,20 +209,20 @@
segSplits = FloatVectorProperty(name='Segment Splits',
description='Number of splits per segment (nSegSplits)',
min=0,
- default=[0,0,0,0],
+ default=[0, 0, 0, 0],
size=4)
splitAngle = FloatVectorProperty(name='Split Angle',
description='Angle of branch splitting (nSplitAngle)',
- default=[0,0,0,0],
+ default=[0, 0, 0, 0],
size=4)
splitAngleV = FloatVectorProperty(name='Split Angle Variation',
description='Variation in the split angle (nSplitAngleV)',
- default=[0,0,0,0],
+ default=[0, 0, 0, 0],
size=4)
scale = FloatProperty(name='Scale',
description='The tree scale (Scale)',
min=0.0,
- default = 13.0)
+ default=13.0)
scaleV = FloatProperty(name='Scale Variation',
description='The variation in the tree scale (ScaleV)',
default=3.0)
@@ -238,27 +246,30 @@
description='The fraction of tapering on each branch (nTaper)',
min=0.0,
max=1.0,
- default=[1,1,1,1],
+ default=[1, 1, 1, 1],
size=4)
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)',
+ 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)
downAngle = FloatVectorProperty(name='Down Angle',
- description='The angle between a new branch and the one it grew from (nDownAngle)',
- default=[90,60,45,45],
+ description=('The angle between a new branch and the one it grew '
+ 'from (nDownAngle)'),
+ default=[90, 60, 45, 45],
size=4)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list