mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-12-09 15:29:09 +00:00
Add bezier_sheet example, fix missing normals arg
This commit is contained in:
parent
839a8981b5
commit
d9197b40ea
2 changed files with 20 additions and 3 deletions
14
beziers.scad
14
beziers.scad
|
|
@ -1595,7 +1595,7 @@ function bezier_patch_normals(patch, u, v) =
|
|||
// splinesteps = Number of segments on the border edges of the bezier surface. You can specify [USTEPS,VSTEPS]. Default: 16
|
||||
// balanced = if true, then offset the bezier surface by half the specified thickness on each side. This increases execution time because two offsets must be performed. The sign of `thickness` does not matter. Default: false
|
||||
// style = {{vnf_vertex_array()}} style to use. Default: "default"
|
||||
// Example(3D):
|
||||
// Example(3D): Because the "inside" of this bezier patch is on the underside of this view, a positive thickness extends downward from that side of the surface.
|
||||
// patch = [
|
||||
// // u=0,v=0 u=1,v=0
|
||||
// [[-50,-50, 0], [-16,-50, 20], [ 16,-50, -20], [50,-50, 0]],
|
||||
|
|
@ -1605,6 +1605,18 @@ function bezier_patch_normals(patch, u, v) =
|
|||
// // u=0,v=1 u=1,v=1
|
||||
// ];
|
||||
// vnf_polyhedron(bezier_sheet(patch, 10));
|
||||
// Example(3D): Using the previous example, setting `balanced=true` causes half the specified thickness to be extended from each side of the sheet. This is somewhat slower because it requires two separate offset operations. The original bezier patch is shown solid, with the thicker sheet shown transparent.
|
||||
// patch = [
|
||||
// // u=0,v=0 u=1,v=0
|
||||
// [[-50,-50, 0], [-16,-50, 20], [ 16,-50, -20], [50,-50, 0]],
|
||||
// [[-50,-16, 20], [-16,-16, 20], [ 16,-16, -20], [50,-16, 20]],
|
||||
// [[-50, 16, 20], [-16, 16, -20], [ 16, 16, 20], [50, 16, 20]],
|
||||
// [[-50, 50, 0], [-16, 50, -20], [ 16, 50, 20], [50, 50, 0]],
|
||||
// // u=0,v=1 u=1,v=1
|
||||
// ];
|
||||
// vnf_polyhedron(bezier_vnf(patch));
|
||||
// vnf_polyhedron(bezier_sheet(patch, 10, balanced=true));
|
||||
|
||||
function bezier_sheet(patch, thickness, splinesteps=16, style="default", balanced=false) =
|
||||
assert(is_bezier_patch(patch))
|
||||
assert(all_nonzero([thickness]), "thickness must be nonzero")
|
||||
|
|
|
|||
9
vnf.scad
9
vnf.scad
|
|
@ -65,6 +65,10 @@ EMPTY_VNF = [[],[]]; // The standard empty VNF with no vertices or faces.
|
|||
// the number of data points must equal the tile count times the number of entries in the tile minus `tex_skip` plus `tex_extra`.
|
||||
// Note that `tex_extra` defaults to 1 along dimensions that are not wrapped. For a VNF tile you need to have the the point
|
||||
// count equal to the tile count times tex_samples, plus one if wrapping is disabled.
|
||||
// .
|
||||
// For creating the texture, `vnf_vertex_array()` uses normals to the surface that it estimates from the surface data itself.
|
||||
// If you have more accurate normals or need the normals to take particular values, you can pass an array of normals
|
||||
// using the `normals` parameter.
|
||||
// Arguments:
|
||||
// points = A list of vertices to divide into columns and rows.
|
||||
// ---
|
||||
|
|
@ -89,6 +93,7 @@ EMPTY_VNF = [[],[]]; // The standard empty VNF with no vertices or faces.
|
|||
// sidecaps = if `col_wrap==false` this controls whether to cap any floating ends of a VNF tile on the texture. Does not affect the main texture surface. Ignored it doesn't apply. Default: false
|
||||
// sidecap1 = set sidecap only for the `points[][0]` edge of the output
|
||||
// sidecap2 = set sidecap only for the `points[][max]` edge of the output
|
||||
// normals = array of normal vectors to each point in the point array for more accurate texture height calculation
|
||||
// cp = (module) Centerpoint for determining intersection anchors or centering the shape. Determines the base of the anchor vector. Can be "centroid", "mean", "box" or a 3D point. Default: "centroid"
|
||||
// anchor = (module) Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `"origin"`
|
||||
// spin = (module) Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||
|
|
@ -304,7 +309,7 @@ function vnf_vertex_array(
|
|||
style="default",
|
||||
triangulate = false,
|
||||
texture, tex_reps, tex_size, tex_samples, tex_inset=false, tex_rot=0,
|
||||
tex_depth=1, tex_extra, tex_skip, sidecaps,sidecap1,sidecap2
|
||||
tex_depth=1, tex_extra, tex_skip, sidecaps,sidecap1,sidecap2, normals
|
||||
) =
|
||||
assert(in_list(style,["default","alt","quincunx", "convex","concave", "min_edge","min_area","flip1","flip2"]))
|
||||
assert(is_matrix(points[0], n=3),"Point array has the wrong shape or points are not 3d")
|
||||
|
|
@ -314,7 +319,7 @@ function vnf_vertex_array(
|
|||
_textured_point_array(points=points, texture=texture, tex_reps=tex_reps, tex_size=tex_size,
|
||||
tex_inset=tex_inset, tex_samples=tex_samples, tex_rot=tex_rot,
|
||||
col_wrap=col_wrap, row_wrap=row_wrap, tex_depth=tex_depth, caps=caps, cap1=cap1, cap2=cap2, reverse=reverse,
|
||||
style=style, tex_extra=tex_extra, tex_skip=tex_skip, sidecaps=sidecaps, sidecap1=sidecap1, sidecap2=sidecap2,triangulate=triangulate)
|
||||
style=style, tex_extra=tex_extra, tex_skip=tex_skip, sidecaps=sidecaps, sidecap1=sidecap1, sidecap2=sidecap2,normals=normals,triangulate=triangulate)
|
||||
:
|
||||
assert(!(any([caps,cap1,cap2]) && !col_wrap), "col_wrap must be true if caps are requested (without texture)")
|
||||
assert(!(any([caps,cap1,cap2]) && row_wrap), "Cannot combine caps with row_wrap (without texture)")
|
||||
|
|
|
|||
Loading…
Reference in a new issue