[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1222] contrib/py/scripts/addons: == Masonry ==

Luca Bonavita mindrones at gmail.com
Fri Dec 3 12:02:07 CET 2010


Revision: 1222
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1222
Author:   mindrones
Date:     2010-12-03 12:02:07 +0100 (Fri, 03 Dec 2010)

Log Message:
-----------
== Masonry ==

- added here, moved info below bl_addon_info for addons panel speedup
- pending changes I asked in the addon tracker

== Fix Vertex Groups ==

- renamed to mesh_fix_vertex_groups.py
- tiny fixes to bl_addon_info

Added Paths:
-----------
    contrib/py/scripts/addons/add_mesh_masonry.py
    contrib/py/scripts/addons/mesh_fix_vertex_groups.py

Removed Paths:
-------------
    contrib/py/scripts/addons/mesh_fix_vert_groups.py

Added: contrib/py/scripts/addons/add_mesh_masonry.py
===================================================================
--- contrib/py/scripts/addons/add_mesh_masonry.py	                        (rev 0)
+++ contrib/py/scripts/addons/add_mesh_masonry.py	2010-12-03 11:02:07 UTC (rev 1222)
@@ -0,0 +1,2372 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you may 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
+#
+# or go online at: http://www.gnu.org/licenses/ to view license options.
+#
+# ***** END GPL LICENCE BLOCK *****
+
+bl_addon_info = {
+    "name": "Masonry",
+    "author": "Paul Spooner, Dudecon, Ziggy",
+    "version": (0, 56),
+    "blender": (2, 5, 4),
+    "api": 32261,
+    "location": "View3D > Add > Mesh > Masonry",
+    "description": "Add Stonework - walls, towers, path, block meshes.",
+    "warning": "WIP - updates pending and API not final for Blender",
+    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
+        "Scripts/Add_Mesh/Masonry",
+    "tracker_url": "http://projects.blender.org/tracker/index.php?"\
+        "func=detail&aid=24980&group_id=153&atid=468",
+    "category": "Add Mesh"
+}
+
+"""
+    This script builds a wall; at current 3D-Cursor location.
+    The wall can be modified to be a disc (radial), curved (slope), or dome (radial+slope).
+    Actually, it could be a path, or a tower, or anything made with blocks.
+    Crenelations also work which can double as arrow slits or support beam holes.
+    Slots, both vertical and horizontal, can be added as openings.
+    Steps and platforms may be added as extensions to the wall.
+
+ --- not true yet:
+
+If a curve is the active object the wall will follow the curve (as long as a
+closed curve is a circle, let me know if you can find a work-around for this).
+
+In this way, castles or large citys can be quickly made by creating curve 
+circles for the towers and curve segments for the walls.
+
+Let me know about suggested improvements, I'll try to work them in!
+"""
+
+# Using SourceForge commit number as version until official release.
+VERSION = '\n\tAdd Masonry v0.56' # show on load (add to menu)
+
+# Version History
+# v0.56 2010/11/19	Revised UI for property access/display.
+# V0.55 2010/11/15	Added stairs, improved shelf, fixed plan generation.
+# V0.54 2010/11/11	Changed version number to match sourceforge check-in,
+# 			basic shelf, and, some general cleanup.
+# V0.5 2010/10/31	Converted to Blender 2.5.4
+# V0.4 2009/11/29	Converted to Blender 2.5
+# V0.3 2009/11/28	Re-did much of the internals, everything works better, 
+# 			especially edge finding.
+# V0.2 2008/03/??	Reworked nearly all the code, many new features
+# V0.1 2007/09/14	First release!
+
+##
+#
+# Module notes:
+#
+# All uses for tlist are commented out for release
+# (time tracking disabled).
+#
+##
+
+# <pep8-80 compliant>
+
+import bpy, time, math
+from random import random
+from math import fmod, sqrt, sin, cos, atan
+
+#A few constants
+SMALL = 0.000000000001
+NOTZERO = 0.01 # for values that must be != 0; see UI options/variables - 
+# sort of a bug to be fixed.
+PI = math.pi
+
+#global variables
+
+#General masonry Settings
+settings = {'w': 1.2, 'wv': 0.3, 'h': .6, 'hv': 0.3, 'd': 0.3, 'dv': 0.1, 
+            'g': 0.1, 'gv': 0.07, 'gd': 0.01, 'gdv': 0.0, 'b': 0, 'bv': 0, 
+            'f': 0.0, 'fv': 0.0, 't': 0.0, 'sdv': 0.1, 'hwt': 0.5, 'aln':0, 
+            'wm': 0.8, 'hm': 0.3, 'dm':0.1, 
+            'woff':0.0, 'woffv':0.0, 'eoff':0.3, 'eoffv':0.0, 'rwhl':1, 
+            'hb':0, 'ht':0, 'ge':0, 'physics':0}
+# 'w':width 'wv':widthVariation 
+# 'h':height 'hv':heightVariation 
+# 'd':depth 'dv':depthVariation
+# 'g':grout 'gv':groutVariation 'gd':groutDepth 'gdv':groutDepthVariation 
+# 'b':bevel 'bv':bevelVariation
+# 'f':flawSize 'fv':flawSizeVariation 'ff':flawFraction 
+# 't':taper 
+# 'sdv':subdivision(distance or angle)
+# 'hwt':row height effect on block widths in the row (0=no effect, 
+#     1=1:1 relationship, negative values allowed, 0.5 works well)
+# 'aln':alignment(0=none, 1=rows w/features, 2=features w/rows)
+#     (currently un-used)
+# 'wm':width minimum 'hm':height minimum 'dm':depth minimum
+# 'woff':row start offset(fraction of width) 
+# 'woffv':width offset variation(fraction of width)
+# 'eoff':edge offset 'eoffv':edge offset variation 
+# 'rwhl':row height lock(1 is all blocks in row have same height)
+# 'hb':bottom row height 'ht': top row height 'ge': grout the edges
+# 'physics': set up for physics
+
+# dims = area of wall (face)
+dims = {'s':0, 'e':PI*3/2, 'b':0.1, 't':12.3} # radial
+#'s':start x or theta 'e':end x or theta 'b':bottom z or r 't':top z or r
+# 'w' = e-s and h = t-b; calculated to optimize for various operations/usages
+#dims = {'s':-12, 'e':15, 'w':27, 'b':-15., 't':15., 'h':30}
+#dims = {'s':-bayDim/2, 'e':bayDim/2, 'b':-5., 't':10.} # bay settings?
+
+radialized = 0 # Radiating from one point - round/disc; instead of square
+slope = 0 # Warp/slope; curved over like a vaulted tunnel
+# 'bigblock': merge adjacent blocks into single large blocks 
+bigBlock = 0 # Merge blocks
+shelfExt = 0 # Extend blocks to make platforms
+
+# Gaps in blocks for various apertures.
+#openingSpecs = []
+openingSpecs = [{'w':0.5, 'h':0.5, 'x':0.8, 'z':2.7, 'rp':1, 'b':0.0, 
+                 'v':0, 'vl':0, 't':0, 'tl':0}]
+# 'w': opening width, 'h': opening height, 
+# 'x': horizontal position, 'z': vertical position, 
+# 'rp': make multiple openings, with a spacing of x, 
+# 'b': bevel the opening, inside only, like an arrow slit.
+# 'v': height of the top arch, 'vl':height of the bottom arch,
+# 't': thickness of the top arch, 'tl': thickness of the bottom arch
+
+# Extend blocks to make platforms.
+#shelfSpecs = []
+shelfSpecs = {'w':0.5, 'h':0.5, 'd': 0.3, 'x':0.8, 'z':2.7}
+# 'w': block width, 'h': block height, 'd': block depth (shelf size; offset from wall)
+# 'x': horizontal start position, 'z': vertical start position
+
+# Add blocks to make steps.
+stepSpecs = {'x':0.0, 'z':-10, 'w':10.0, 'h':10.0,
+	'v':0.7, 't':1.0, 'd':1.0 }
+# 'x': horizontal start position, 'z': vertical start position,
+# 'w': step area width, 'h': step area height,
+# 'v': riser height, 't': tread width, 'd': block depth (step size; offset from wall)
+
+
+#tlist = [(time.clock(),'start')]
+# example sample tlist += [(time.clock(),'make pancakes')]
+
+    #easier way to get to the random function
+def rnd(): return random()
+
+    #random number from -0.5 to 0.5
+def rndc(): return (random() - 0.5)
+
+    #random number from -1.0 to 1.0
+def rndd(): return (random() - 0.5)*2.0
+
+
+#Opening Test suite
+#opening test function
+
+def test(TestN = 13):
+    dims = {'s':-29., 'e':29., 'b':-6., 't':TestN*7.5}
+    openingSpecs = []
+    for i in range(TestN):
+        x = (random() - 0.5) * 6
+        z = i*7.5
+        v = .2 + i*(3./TestN)
+        vl = 3.2 - i*(3./TestN)
+        t = 0.3 + random()
+        tl = 0.3 + random()
+        rn = random()*2
+        openingSpecs += [{'w':3.1 + rn, 'h':0.3 + rn, 'x':float(x), 
+                          'z':float(z), 'rp':0, 'b':0., 
+                          'v':float(v), 'vl':float(vl), 
+                          't':float(t), 'tl':float(tl)}]
+    return dims, openingSpecs
+
+#dims, openingSpecs = test(15)
+
+
+#For filling a linear space with divisions
+def fill(left, right, avedst, mindst=0.0, dev=0.0, pad=(0.0,0.0), num=0, 
+         center=0):
+    __doc__ = '''\
+	Fills a linear range with points and returns an ordered list of those points 
+	including the end points.
+
+	left: the lower boundary
+	right: the upper boundary
+	avedst: the average distance between points
+	mindst: the minimum distance between points
+	dev: the maximum random deviation from avedst
+	pad: tends to move the points near the bounds right (positive) or 
+	    left (negative).
+	    element 0 pads the lower bounds, element 1 pads the upper bounds
+	num: substitutes a numerical limit for the right limit.  fill will then make
+	    a num+1 element list
+	center: flag to center the elements in the range, 0 == disabled
+        '''
+
+    poslist = [left]
+    curpos = left+pad[0]
+
+    # Set offset by average spacing, then add blocks (fall through); 
+    # clip to right edge.
+    if center:
+        curpos += ((right-left-mindst*2)%avedst)/2+mindst
+        if curpos-poslist[-1]<mindst: curpos = poslist[-1]+mindst+rnd()*dev/2
+
+        if (right-curpos<mindst) or (right-curpos< mindst-pad[1]):
+            poslist.append(right)
+            return poslist
+
+        else: poslist.append(curpos)
+
+    #unused... for now.
+    if num:
+        idx = len(poslist)
+
+        while idx<num+1:
+            curpos += avedst+rndd()*dev
+            if curpos-poslist[-1]<mindst:
+                curpos = poslist[-1]+mindst+rnd()*dev/2
+            poslist.append(curpos)
+            idx += 1
+
+        return poslist
+
+    # make block edges
+    else:
+        while True: # loop for blocks	
+            curpos += avedst+rndd()*dev		
+            if curpos-poslist[-1]<mindst:
+                curpos = poslist[-1]+mindst+rnd()*dev/2
+            # close off edges at limit
+            if (right-curpos<mindst) or (right-curpos< mindst-pad[1]):
+                poslist.append(right)
+                return poslist
+
+            else: poslist.append(curpos)
+
+
+#For generating block geometry
+def MakeABlock(bounds, segsize, vll=0, Offsets=None, FaceExclude=[], 
+               bevel=0, xBevScl=1):
+    __doc__ = '''\
+	MakeABlock returns lists of points and faces to be made into a square
+            cornered block, subdivided along the length, with optional bevels.
+	bounds: a list of boundary positions:
+        0:left, 1:right, 2:bottom, 3:top, 4:back, 5:front
+	segsize: the maximum size before lengthwise subdivision occurs

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list