Merge pull request #934 from revarbat/revarbat_dev

Enable taper lookup tables.
This commit is contained in:
Revar Desmera 2022-08-26 14:53:44 -07:00 committed by GitHub
commit b42b4ac962
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View file

@ -1194,6 +1194,7 @@ function cylinder(h, r1, r2, center, l, r, d, d1, d2, anchor, spin=0, orient=UP)
// tex_scale = Scaling multiplier for the texture depth.
// tex_samples = Minimum number of "bend points" to have in VNF texture tiles. Default: 8
// tex_style = {{vnf_vertex_array()}} style used to triangulate heightfield textures. Default: "min_edge"
// tex_taper = If given as a number, tapers the texture height to zero over the first and last given percentage of the path. If given as a lookup table with indices between 0 and 100, uses the percentage lookup table to ramp the texture heights. Default: `undef` (no taper)
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`

View file

@ -3211,7 +3211,7 @@ function _find_vnf_tile_edge_path(vnf, val) =
/// rot = If true, rotates the texture 90º.
/// shift = [X,Y] amount to translate the top, relative to the bottom. Default: [0,0]
/// closed = If false, and shape is given as a path, then the revolved path will be sealed to the axis of rotation with untextured caps. Default: `true`
/// taper = If given, and `closed=false`, tapers the texture height to zero over the first and last given percentage of the path. Default: `undef` (no taper)
/// taper = If given, and `closed=false`, tapers the texture height to zero over the first and last given percentage of the path. If given as a lookup table with indices between 0 and 100, uses the percentage lookup table to ramp the texture heights. Default: `undef` (no taper)
/// angle = The number of degrees counter-clockwise from X+ to revolve around the Z axis. Default: `360`
/// style = The triangulation style used. See {{vnf_vertex_array()}} for valid styles. Used only with heightfield type textures. Default: `"min_edge"`
/// counts = If given instead of tex_size, gives the tile repetition counts for textures over the surface length and height.
@ -3239,7 +3239,8 @@ function _textured_revolution(
assert(counts==undef || is_vector(counts,2))
assert(tex_size==undef || is_vector(tex_size,2))
assert(is_bool(rot) || in_list(rot,[0,90,180,270]))
assert(is_undef(taper) || (is_finite(taper) && taper>=0 && taper<50))
let( taper_is_ok = is_undef(taper) || (is_finite(taper) && taper>=0 && taper<50) || is_path(taper,2) )
assert(taper_is_ok, "Bad taper= value.")
assert(in_list(atype, _ANCHOR_TYPES), "Anchor type must be \"hull\" or \"intersect\"")
let(
regions = !is_path(shape,2)? region_parts(shape) :
@ -3324,7 +3325,16 @@ function _textured_revolution(
? max(1,round(angle/360*circumf/tex_size.x))
: ceil(6*angle/360*circumf/h),
taper_lup = closed || is_undef(taper)? [[-1,1],[2,1]] :
[[-1,0], [0,0], [taper/100+EPSILON,1], [1-taper/100-EPSILON,1], [1,0], [2,0]],
is_num(taper)? [[-1,0], [0,0], [taper/100+EPSILON,1], [1-taper/100-EPSILON,1], [1,0], [2,0]] :
is_path(taper,2)? let(
retaper = [
for (t=taper)
assert(t[0]>=0 && t[0]<=100, "taper lookup indices must be betweem 0 and 100 inclusive.")
[t[0]/100, t[1]]
],
taperout = [[-1,retaper[0][1]], each retaper, [2,last(retaper)[1]]]
) taperout :
assert(false, "Bad taper= argument value."),
full_vnf = vnf_join([
for (rgn = regions) let(
rgn_wall_vnf = vnf_join([