Skip to content

Commit 4f0b7e5

Browse files
Merge pull request #1626 from adrianVmariano/master
textured sweeps & textured_tile bugfix
2 parents 6d60492 + 1faf261 commit 4f0b7e5

File tree

5 files changed

+167
-78
lines changed

5 files changed

+167
-78
lines changed

drawing.scad

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,6 @@ function _rounded_arc(radius, rounding=0, angle, n) =
899899
let(
900900
rounding = force_list(rounding,3),
901901
dir = sign(angle),
902-
903-
// inner_corner_radius = abs(angle)==180?0 : abs(angle)>180 ? -dir*rounding[0] : dir*rounding[0],
904902
inner_corner_radius = abs(angle)>180 ? -dir*rounding[0] : dir*rounding[0],
905903
arc1_opt_radius = radius - rounding[1],
906904
arc2_opt_radius = radius - rounding[2],

shapes3d.scad

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ function regular_prism(n,
12261226
// Example(3D,NoAxes,VPT=[-0.0852782,0.259593,0.139667],VPR=[58.5,0,345.1],VPD=36.0994): Attaching a tile to a cube
12271227
// cuboid([12,12,4]) attach(TOP,BOT)
12281228
// textured_tile("trunc_pyramids", 10, tex_reps=[5,5], style="convex");
1229-
// Example(3D,NoScales,VPT = [-0.0788193, 0.10015, -0.0938629], VPR = [57.8, 0, 34.1], VPD = 29.2405): This inset texture doesn't look obviously different, but you can see that the object is below the XY plane.
1229+
// Example(3D,NoScales,VPT = [-0.0788193, 0.10015, -0.0938629], VPR = [57.8, 0, 34.1], VPD = 29.2405): This inset texture doesn't look obviously different, but you can see that the object is below the XY plane.
12301230
// textured_tile("trunc_pyramids_vnf", 10, tex_reps=[5,5], tex_inset=true);
12311231
// Example(3D,NoAxes,VPT=[0.242444,0.170054,-0.0714754],VPR=[67.6,0,33.4],VPD=36.0994): Here we use the `diff` option combined with {{diff()}} to attach the inset texture to the front of a parent cuboid.
12321232
// diff()
@@ -1250,36 +1250,6 @@ function regular_prism(n,
12501250
// textured_tile("trunc_ribs", 10, tex_reps=[5,2], tex_skip=1);
12511251

12521252

1253-
// This is like _tile_edge_path_list in that it finds the paths
1254-
// on the x=0 or y=0 face of a VNF tile. But instead of returning
1255-
// paths it turns them into a VNF. The open path is closed to the specified
1256-
// z coordinate.
1257-
1258-
function _tile_edge_vnf(vnf, axis, z, maxopen=1) =
1259-
let(
1260-
verts = vnf[0],
1261-
faces = vnf[1],
1262-
segs = [for(face=faces, edge=pair(select(verts,face),wrap=true)) if (approx(edge[0][axis],0) && approx(edge[1][axis],0)) [edge[1],edge[0]]],
1263-
paths = _assemble_partial_paths(segs),
1264-
facelist = [
1265-
for(path=paths)
1266-
if (!(len(path)<=3 && path[0]==last(path)))
1267-
path[0]==len(path) ? [list_unwrap(path),[count(len(path)-1)]]
1268-
: [
1269-
[
1270-
point3d(point2d(path[0]),z),
1271-
each path,
1272-
point3d(point2d(last(path)),z)
1273-
],
1274-
[count(len(path)+2)]
1275-
]
1276-
],
1277-
openlist = [for(entry=facelist) if (!are_ends_equal(entry[0])) 1]
1278-
)
1279-
assert(len(openlist)<=maxopen, str("VNF has ",len(openlist)," open paths on an edge and at most ",maxopen," is supported."))
1280-
vnf_join(facelist);
1281-
1282-
12831253
module textured_tile(
12841254
texture,
12851255
size,
@@ -1382,6 +1352,7 @@ function textured_tile(
13821352
tex_reps = is_def(tex_reps) ? tex_reps
13831353
: [round(size.x/tex_size.x), round(size.y/tex_size.y)],
13841354
scale = [size.x/tex_reps.x, size.y/tex_reps.y],
1355+
setz=function (v,z) [v.x,v.y,z],
13851356
vnf = !is_vnf(texture) ?
13861357
let(
13871358
texsteps = [len(texture[0]), len(texture)],
@@ -1412,18 +1383,57 @@ function textured_tile(
14121383
],
14131384
scaled_vnf = scale(scale, zadj_vnf),
14141385
tiled_vnf = [for(i=[0:1:tex_reps.x-1], j=[0:1:tex_reps.y-1]) move([scale.x*i,scale.y*j], scaled_vnf)],
1415-
unscaled_hedge=_tile_edge_vnf(zadj_vnf,1,-height/2),
1416-
hedge = unscaled_hedge==EMPTY_VNF ? [] : xscale(scale.x, unscaled_hedge),
1417-
unscaled_vedge=_tile_edge_vnf(zadj_vnf,0,-height/2),
1418-
vedge = unscaled_vedge==EMPTY_VNF ? [] : yscale(scale.y, unscaled_vedge),
1419-
hedge_flip = hedge==[] ? hedge : back(size.y,vnf_reverse_faces(hedge)),
1420-
vedge_flip = vedge==[] ? vedge : right(size.x,vnf_reverse_faces(vedge)),
1421-
front_edge = hedge==[] ? [] : [for(i=[0:1:tex_reps.x-1]) xmove(scale.x*i, hedge)],
1422-
left_edge = vedge==[] ? [] : [for(j=[0:1:tex_reps.y-1]) ymove(scale.y*j, vedge)],
1423-
back_edge = hedge==[] ? [] : [for(i=[0:1:tex_reps.x-1]) xmove(scale.x*i, hedge_flip)],
1424-
right_edge = vedge==[] ? [] : [for(j=[0:1:tex_reps.y-1]) ymove(scale.y*j, vedge_flip)],
1386+
1387+
yedge_list = _tile_edge_path_list(zadj_vnf, 0),
1388+
xedge_list = _tile_edge_path_list(zadj_vnf, 1),
1389+
1390+
front_back_closed = [for(i=[0:1:tex_reps.x-1], cpath=xedge_list[1])
1391+
each [[xscale(scale.x,xmove(i,cpath)), [count(cpath)]],
1392+
[xscale(scale.x,move([i,size.y],cpath)),[count(cpath,reverse=true)]]]],
1393+
sides_closed = [for(j=[0:1:tex_reps.y-1], cpath=yedge_list[1])
1394+
each [[yscale(scale.y,ymove(j,cpath)), [count(cpath)]],
1395+
[yscale(scale.y,move([size.x, j], cpath)),[count(cpath,reverse=true)]]]],
1396+
1397+
leftpath = yedge_list[0]==[] ? []
1398+
: deduplicate([for(j=[0:1:tex_reps.y-1]) each reverse(yscale(scale.y,ymove(j,yedge_list[0][0])))]),
1399+
frontpath = xedge_list[0]==[] ? []
1400+
: deduplicate([for(i=[0:1:tex_reps.x-1]) each xscale(scale.x,xmove(i,xedge_list[0][0]))]),
1401+
1402+
base = frontpath==[] || leftpath==[] ? []
1403+
: [
1404+
[
1405+
[setz(frontpath[0],-height/2),
1406+
each frontpath,
1407+
setz(last(frontpath), -height/2)
1408+
],
1409+
[count(len(frontpath)+2)]
1410+
],
1411+
[
1412+
[setz(last(leftpath),-height/2),
1413+
each reverse(leftpath),
1414+
setz(leftpath[0], -height/2)
1415+
],
1416+
[count(len(leftpath)+2)]
1417+
],
1418+
[
1419+
back(size.y,
1420+
[setz(last(frontpath),-height/2),
1421+
each reverse(frontpath),
1422+
setz(frontpath[0],-height/2)
1423+
]),
1424+
[count(len(frontpath)+2)]
1425+
],
1426+
[right(size.x,
1427+
[setz(leftpath[0],-height/2),
1428+
each leftpath,
1429+
setz(last(leftpath),-height/2)
1430+
]),
1431+
[count(len(leftpath)+2)]
1432+
]
1433+
],
1434+
14251435
bottom = [path3d(rect(point2d(size),anchor=FWD+LEFT),-height/2), [[3,2,1,0]]],
1426-
result = vnf_join(concat(tiled_vnf, front_edge, left_edge, right_edge, back_edge, [bottom]))
1436+
result = vnf_join(concat(tiled_vnf,front_back_closed, sides_closed,base,[bottom]))
14271437
)
14281438
move([-size.x/2,-size.y/2],result),
14291439
trans_vnf = is_undef(h_w1_w2_shift) ? vnf

0 commit comments

Comments
 (0)