Newer
Older
# GPL # "authors": dudecon, jambay
# Module notes:
#
# Grout needs to be implemented.
# consider removing wedge crit for small "c" and "cl" values
# wrap around for openings on radial stonework?
# auto-clip wall edge to SMALL for radial and domes.
# unregister doesn't release all references.
# repeat for opening doesn't distribute evenly when radialized - see wrap around
# if opening width == indent*2 the edge blocks fail (row of blocks cross opening).
# if openings overlap fills inverse with blocks - see h/v slots.
# Negative grout width creates a pair of phantom blocks, separated by grout
# width, inside the edges.
# if block width variance is 0, and edging is on, right edge blocks create a "vertical seam"
from random import random
from math import (
fmod, sqrt,
sin, cos, atan,
pi as PI,
)
# Set to True to enable debug_prints
DEBUG = False
SMALL = 0.000000000001
# for values that must be != 0; see UI options/variables - sort of a bug to be fixed
NOTZERO = 0.01
# Global variables
# ------------------------
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
}
"""
settings DOCUMENTATION:
'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 unused)
'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
"""
dims DOCUMENTATION:
'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
# Gaps in blocks for various apertures
# ------------------------
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}
]
"""
openingSpecs DOCUMENTATION:
'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
"""
# Add blocks to make platforms
# ------------------------
shelfExt = 0
shelfSpecs = {
'w': 0.5, 'h': 0.5, 'd': 0.3, 'x': 0.8, 'z': 2.7
}
"""
shelfSpecs DOCUMENTATION:
'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
# ------------------------
stepMod = 0
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
stepSpecs = {
'x': 0.0, 'z': -10, 'w': 10.0, 'h': 10.0,
'v': 0.7, 't': 1.0, 'd': 1.0
}
"""
stepSpecs DOCUMENTATION:
'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)
"""
stepLeft = 0
shelfBack = 0
stepOnly = 0
stepBack = 0
# switchable prints
def debug_prints(func="", text="Message", var=None):
global DEBUG
if DEBUG:
print("\n[{}]\nmessage: {}".format(func, text))
if var:
print("Error: ", var)
# pass variables just like for the regular prints
def debug_print_vars(*args, **kwargs):
global DEBUG
if DEBUG:
print(*args, **kwargs)
# 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
Loading
Loading full blame...