Snippets

John Martini line connection between nodes

Created by John Martini
delete objects
pA = point pos:(random [-10,5,0] [0,0,0]) size:4 wirecolor:yellow
pB = point pos:(random [10,5,0] [0,0,0]) size:4 wirecolor:green

distThreshold = 30
dist = distance pA.pos pB.pos
clearlistener()

format "Dist: %\n" dist

offset = 5
if dist < distThreshold do
(
	local mult = dist / distThreshold
	offset *= mult
	format "Offset: %\n" offset
)

sp = splineshape wirecolor:white optimize:false
addnewspline sp
outvec = pA.pos + ([1,0,0] * offset)
invec = pB.pos + ([-1,0,0] * offset)
addKnot sp 1 #bezierCorner #curve pA.pos pA.pos outvec
addKnot sp 1 #bezierCorner #curve pB.pos invec pB.pos
updateShape sp

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.