@@ -1226,7 +1226,7 @@ function regular_prism(n,
1226
1226
// 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
1227
1227
// cuboid([12,12,4]) attach(TOP,BOT)
1228
1228
// 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.
1230
1230
// textured_tile("trunc_pyramids_vnf", 10, tex_reps=[5,5], tex_inset=true);
1231
1231
// 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.
1232
1232
// diff()
@@ -1250,36 +1250,6 @@ function regular_prism(n,
1250
1250
// textured_tile("trunc_ribs", 10, tex_reps=[5,2], tex_skip=1);
1251
1251
1252
1252
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
-
1283
1253
module textured_tile(
1284
1254
texture,
1285
1255
size,
@@ -1382,6 +1352,7 @@ function textured_tile(
1382
1352
tex_reps = is_def(tex_reps) ? tex_reps
1383
1353
: [round (size.x/tex_size.x), round (size.y/tex_size.y)],
1384
1354
scale = [size.x/tex_reps.x, size.y/tex_reps.y],
1355
+ setz= function (v,z) [v.x,v.y,z],
1385
1356
vnf = ! is_vnf(texture) ?
1386
1357
let(
1387
1358
texsteps = [len(texture[0 ]), len(texture)],
@@ -1412,18 +1383,57 @@ function textured_tile(
1412
1383
],
1413
1384
scaled_vnf = scale (scale , zadj_vnf),
1414
1385
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
+
1425
1435
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]))
1427
1437
)
1428
1438
move([- size.x/2 ,- size.y/2 ],result),
1429
1439
trans_vnf = is_undef(h_w1_w2_shift) ? vnf
0 commit comments