[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4650] contrib/py/scripts/addons/ add_mesh_space_tree/__init__.py: fixed 90 degree rotation of leaf uv-map and added leaf offset option
Michel Anders
michel.anders at inter.nl.net
Sun Aug 4 10:05:14 CEST 2013
Revision: 4650
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4650
Author: varkenvarken
Date: 2013-08-04 08:05:13 +0000 (Sun, 04 Aug 2013)
Log Message:
-----------
fixed 90 degree rotation of leaf uv-map and added leaf offset option
Modified Paths:
--------------
contrib/py/scripts/addons/add_mesh_space_tree/__init__.py
Modified: contrib/py/scripts/addons/add_mesh_space_tree/__init__.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_space_tree/__init__.py 2013-08-04 00:41:01 UTC (rev 4649)
+++ contrib/py/scripts/addons/add_mesh_space_tree/__init__.py 2013-08-04 08:05:13 UTC (rev 4650)
@@ -24,7 +24,7 @@
bl_info = {
"name": "SCA Tree Generator",
"author": "michel anders (varkenvarken)",
- "version": (0, 1, 1),
+ "version": (0, 1, 2),
"blender": (2, 66, 0),
"location": "View3D > Add > Mesh",
"description": "Adds a tree created with the space colonization algorithm starting at the 3D cursor",
@@ -190,15 +190,15 @@
return mx - mn, mn
-def createLeaves(tree, probability=0.5, size=0.5, randomsize=0.1, randomrot=0.1, maxconnections=2, bunchiness=1.0):
+def createLeaves(tree, probability=0.5, size=0.5, randomsize=0.1, randomrot=0.1, maxconnections=2, bunchiness=1.0, connectoffset=-0.1):
p = bpy.context.scene.cursor_location
verts = []
faces = []
- c1 = Vector((-size / 10, -size / 2, 0))
- c2 = Vector((size, -size / 2, 0))
- c3 = Vector((size, size / 2, 0))
- c4 = Vector((-size / 10, size / 2, 0))
+ c1 = Vector((connectoffset, -size / 2, 0))
+ c2 = Vector((size+connectoffset, -size / 2, 0))
+ c3 = Vector((size+connectoffset, size / 2, 0))
+ c4 = Vector((connectoffset, size / 2, 0))
t = gauss(1.0 / probability, 0.1)
bpswithleaves = 0
for bp in tree.branchpoints:
@@ -228,7 +228,7 @@
v.rotate(rot)
verts.append(v * scale + bp.v + dvp)
n = len(verts)
- faces.append((n - 4, n - 3, n - 2, n - 1))
+ faces.append((n - 1, n - 4, n - 3, n - 2))
t += gauss(1.0 / probability, 0.1) # this is not the best choice of distribution because we might get negative values especially if sigma is large
dvp = nleavesonbp * (dv / (probability ** bunchiness)) # TODO add some randomness to the offset
@@ -402,7 +402,7 @@
def createGeometry(tree, power=0.5, scale=0.01, addleaves=False, pleaf=0.5, leafsize=0.5, leafrandomsize=0.1, leafrandomrot=0.1,
nomodifiers=True, skinmethod='NATIVE', subsurface=False,
- maxleafconnections=2, bleaf=1.0,
+ maxleafconnections=2, bleaf=1.0, connectoffset=-0.1,
timeperf=True):
timings = Timer()
@@ -565,7 +565,7 @@
# create the leaves object
if addleaves:
- mesh = createLeaves(tree, pleaf, leafsize, leafrandomsize, leafrandomrot, maxleafconnections, bleaf)
+ mesh = createLeaves(tree, pleaf, leafsize, leafrandomsize, leafrandomrot, maxleafconnections, bleaf, connectoffset)
obj_leaves = bpy.data.objects.new(mesh.name, mesh)
base = bpy.context.scene.objects.link(obj_leaves)
obj_leaves.parent = obj_new
@@ -722,6 +722,9 @@
default=0.1,
min=0.0,
soft_max=1)
+ connectoffset = FloatProperty(name="Connect Offset",
+ description=("Offset of leaf to twig"),
+ default=-0.1)
leafMaxConnections = IntProperty(name="Max Connections",
description="The maximum number of connections of an internode elegible for a leaf",
default=2,
@@ -836,7 +839,7 @@
obj_new = createGeometry(sca, self.power, self.scale, self.addLeaves, self.pLeaf, self.leafSize, self.leafRandomSize, self.leafRandomRot,
self.noModifiers, self.skinMethod, self.subSurface,
- self.leafMaxConnections, self.bLeaf,
+ self.leafMaxConnections, self.bLeaf, self.connectoffset,
self.timePerformance)
timings.add('objcreationstart')
@@ -929,6 +932,7 @@
box.prop(self, 'leafSize')
box.prop(self, 'leafRandomSize')
box.prop(self, 'leafRandomRot')
+ box.prop(self, 'connectoffset')
box.prop(self, 'leafMaxConnections')
layout.prop(self, 'addObjects', icon='MESH_DATA')
More information about the Bf-extensions-cvs
mailing list