[Bf-extensions-cvs] [ed94314c] master: Remove: add_mesh_space_tree: unsupported: T63750
meta-androcto
noreply at git.blender.org
Sun Apr 21 03:28:19 CEST 2019
Commit: ed94314c26d2c45a97ed8788d98cc4aa519039d4
Author: meta-androcto
Date: Sun Apr 21 11:28:03 2019 +1000
Branches: master
https://developer.blender.org/rBACed94314c26d2c45a97ed8788d98cc4aa519039d4
Remove: add_mesh_space_tree: unsupported: T63750
===================================================================
D add_mesh_space_tree/__init__.py
D add_mesh_space_tree/kdtree.py
D add_mesh_space_tree/sca.py
D add_mesh_space_tree/simplefork.py
D add_mesh_space_tree/timer.py
===================================================================
diff --git a/add_mesh_space_tree/__init__.py b/add_mesh_space_tree/__init__.py
deleted file mode 100644
index 61d32a01..00000000
--- a/add_mesh_space_tree/__init__.py
+++ /dev/null
@@ -1,1122 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-# SCA Tree Generator, a Blender add-on
-# (c) 2013 Michel J. Anders (varkenvarken)
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# 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 #####
-
-# <pep8 compliant>
-
-bl_info = {
- "name": "SCA Tree Generator",
- "author": "michel anders (varkenvarken)",
- "version": (0, 1, 3),
- "blender": (2, 77, 0),
- "location": "View3D > Add > Mesh",
- "description": "Create a tree using the space colonization algorithm starting at the 3D cursor",
- "warning": "",
- "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
- "Scripts/Add_Mesh/Add_Space_Tree",
- "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
- "category": "Add Mesh"
-}
-
-import bpy
-from random import (
- gauss, random,
-)
-from functools import partial
-from math import (
- cos, sin,
-)
-from bpy.props import (
- BoolProperty,
- EnumProperty,
- FloatProperty,
- IntProperty,
-)
-from mathutils import (
- Euler,
- Vector,
- Quaternion,
-)
-# simple skinning algorithm building blocks
-from .simplefork import (
- quadfork, bridgequads,
-)
-# the core class that implements the space colonization
-# algorithm and the definition of a segment
-from .sca import (
- SCA, Branchpoint,
-)
-from .timer import Timer
-
-
-def availableGroups(self, context):
- return [(name, name, name, n) for n, name in enumerate(bpy.data.collections.keys())]
-
-
-def availableGroupsOrNone(self, context):
- groups = [('None', 'None', 'None', 1)]
- return groups + [(name, name, name, n + 1) for n, name in enumerate(bpy.data.collections.keys())]
-
-
-def availableObjects(self, context):
- return [(name, name, name, n + 1) for n, name in enumerate(bpy.data.objects.keys())]
-
-
-def ellipsoid(r=5, rz=5, p=Vector((0, 0, 8)), taper=0):
- r2 = r * r
- z2 = rz * rz
- if rz > r:
- r = rz
- while True:
- x = (random() * 2 - 1) * r
- y = (random() * 2 - 1) * r
- z = (random() * 2 - 1) * r
- f = (z + r) / (2 * r)
- f = 1 + f * taper if taper >= 0 else (1 - f) * -taper
- if f * x * x / r2 + f * y * y / r2 + z * z / z2 <= 1:
- yield p + Vector((x, y, z))
-
-
-def pointInsideMesh(pointrelativetocursor, ob):
- # adapted from http://blenderartists.org/forum/showthread.php?"
- # "195605-Detecting-if-a-point-is-inside-a-mesh-2-5-API&p=1691633&viewfull=1#post1691633
- mat = ob.matrix_world.inverted()
- orig = mat * (pointrelativetocursor + bpy.context.scene.cursor.location)
- count = 0
- axis = Vector((0, 0, 1))
- while True:
- # Note: address changes introduced to object.ray_cast return (see T54414)
- result, location, normal, index = ob.ray_cast(orig, orig + axis * 10000.0)
- if index == -1:
- break
- count += 1
- orig = location + axis * 0.00001
- if count % 2 == 0:
- return False
- return True
-
-
-def ellipsoid2(rxy=5, rz=5, p=Vector((0, 0, 8)), surfacebias=1, topbias=1):
- while True:
- phi = 6.283 * random()
- theta = 3.1415 * (random() - 0.5)
- r = random() ** (surfacebias / 2)
- x = r * rxy * cos(theta) * cos(phi)
- y = r * rxy * cos(theta) * sin(phi)
- st = sin(theta)
- st = (((st + 1) / 2) ** topbias) * 2 - 1
- z = r * rz * st
- # print(">>>%.2f %.2f %.2f "%(x,y,z))
- m = p + Vector((x, y, z))
- reject = False
- for ob in bpy.context.selected_objects:
- # probably we should check if each object is a mesh
- if pointInsideMesh(m, ob):
- reject = True
- break
- if not reject:
- yield m
-
-
-def halton3D(index):
- """
- return a quasi random 3D vector R3 in [0,1].
- each component is based on a halton sequence.
- quasi random is good enough for our purposes and is
- more evenly distributed then pseudo random sequences.
- See en.m.wikipedia.org/wiki/Halton_sequence
- """
-
- def halton(index, base):
- result = 0
- f = 1.0 / base
- I = index
- while I > 0:
- result += f * (I % base)
- I = int(I / base)
- f /= base
- return result
- return Vector((halton(index, 2), halton(index, 3), halton(index, 5)))
-
-
-def insidegroup(pointrelativetocursor, group):
- if bpy.data.collections.find(group) < 0:
- return False
- for ob in bpy.data.collections[group].objects:
- if pointInsideMesh(pointrelativetocursor, ob):
- return True
- return False
-
-
-def groupdistribution(crowngroup, shadowgroup=None, seed=0, size=Vector((1, 1, 1)),
- pointrelativetocursor=Vector((0, 0, 0))):
- if crowngroup == shadowgroup:
- shadowgroup = None # safeguard otherwise every marker would be rejected
- nocrowngroup = bpy.data.collections.find(crowngroup) < 0
- noshadowgroup = (shadowgroup is None) or (bpy.data.collections.find(shadowgroup) < 0) or (shadowgroup == 'None')
- index = 100 + seed
- nmarkers = 0
- nyield = 0
- while True:
- nmarkers += 1
- v = halton3D(index)
- v[0] *= size[0]
- v[1] *= size[1]
- v[2] *= size[2]
- v += pointrelativetocursor
- index += 1
- insidecrown = nocrowngroup or insidegroup(v, crowngroup)
- outsideshadow = noshadowgroup or not insidegroup(v, shadowgroup)
- # if shadowgroup overlaps all or a significant part of the crowngroup
- # no markers will be yielded and we would be in an endless loop.
- # so if we yield too few correct markers we start yielding them anyway.
- lowyieldrate = (nmarkers > 200) and (nyield / nmarkers < 0.01)
- if (insidecrown and outsideshadow) or lowyieldrate:
- nyield += 1
- yield v
-
-
-def groupExtends(group):
- """
- return a size,minimum tuple both Vector elements, describing the size and position
- of the bounding box in world space that encapsulates all objects in a group.
- """
- bb = []
- if bpy.data.collections.find(group) >= 0:
- for ob in bpy.data.collections[group].objects:
- rot = ob.matrix_world.to_quaternion()
- scale = ob.matrix_world.to_scale()
- translate = ob.matrix_world.translation
- for v in ob.bound_box: # v is not a vector but an array of floats
- p = ob.matrix_world * Vector(v[0:3])
- bb.extend(p[0:3])
- mx = Vector((max(bb[0::3]), max(bb[1::3]), max(bb[2::3])))
- mn = Vector((min(bb[0::3]), min(bb[1::3]), min(bb[2::3])))
- return mx - mn, mn
-
-
-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((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:
- if bp.connections < maxconnections:
-
- dv = tree.branchpoints[bp.parent].v - bp.v if bp.parent else Vector((0, 0, 0))
- dvp = Vector((0, 0, 0))
-
- bpswithleaves += 1
- nleavesonbp = 0
- while t < bpswithleaves:
- nleavesonbp += 1
- rx = (random() - 0.5) * randomrot * 6.283 # TODO vertical tilt in direction of tropism
- ry = (random() - 0.5) * randomrot * 6.283
- rot = Euler((rx, ry, random() * 6.283), 'ZXY')
- scale = 1 + (random() - 0.5) * randomsize
- v = c1.copy()
- v.rotate(rot)
- verts.append(v * scale + bp.v + dvp)
- v = c2.copy()
- v.rotate(rot)
- verts.append(v * scale + bp.v + dvp)
- v = c3.copy()
- v.rotate(rot)
- verts.append(v * scale + bp.v + dvp)
- v = c4.copy()
- v.rotate(rot)
- verts.append(v * scale + bp.v + dvp)
- n = len(verts)
- faces.append((n - 1, n - 4, n - 3, n - 2))
- # this is not the best choice of distribution because we might
- # get negative values especially if sigma is large
- t += gauss(1.0 / probability, 0.1)
- dvp = nleavesonbp * (dv / (probability ** bunchiness)) # TODO add some randomness to the offset
-
- mesh = bpy.data.meshes.new('Leaves')
- mesh.from_pydata(verts, [], faces)
- mesh.update(calc_edges=True)
- mesh.uv_textures.new()
- return mesh
-
-
-def createMarkers(tree, scale=0.05):
- # not used as markers are parented to tree object that is created at the cursor position
- # p=bpy.context.scene.cursor.location
-
- verts = []
- faces = []
-
- tetraeder = [Vector((-1, 1, -1)), Vector((1, -1, -1)), Vector((1, 1, 1)), Vector((-1, -1, 1))]
- tetraeder = [v * scale for v in tetraeder]
- tfaces = [(0, 1, 2), (0, 1, 3), (1, 2, 3), (0, 3, 2)]
-
- for ep in tree.endpoints:
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list