Forum: Poser - OFFICIAL


Subject: Bagginsbill's Sketchbook

bagginsbill opened this issue on Jul 30, 2012 · 130 posts


bagginsbill posted Mon, 30 July 2012 at 3:47 PM

You guys can't use this script because it requires geometry libraries I have never shared. But I thought some might find it interesting to see how it's done.

 

def splineTransform(fx, fy, fz, t):
        dt = .001
        tp = t + dt/2
        tn = t - dt / 2
        x,y,z = fx(t), fy(t), fz(t)
        dx = (fx(tp) - fx(tn)) / dt
        dy = (fy(tp) - fy(tn)) / dt
        dz = (fz(tp) - fz(tn)) / dt
        tx = MatrixFromVector(Vector(dx, dy, dz))
        tx.w = Vector(x, y, z)
        return tx

r = 3 * inch
p = 8 * r
R = 12 * r

def tube(i, dr, ys, tw):
        a = i / 3.0
        k = 8
        def fx(t):
                return r * sin(2 * pi * (t + a))
        def fy(t):
                return r/2 * sin(4 * pi * (t + a))
        def fz(t):
                return -p * t

        pl = PolyList()
        p0 = ucircleSOUTH(dr, 36) >> Scale(tw, 1, 1)
        pa = None
        for t in lerps(0, k, k * 40):
                tx = splineTransform(fx, fy, fz, t)
                tx = tx * Scale(1, ys, 1) * Trans(0, R, -fz(t)) * XRot(-t * 360.0 / k)
                pb = p0 >> tx
                if pa:
                        pl << pb.bridge(pa)
                pa = pb
        return pl
def braid(morph=None):
        if morph == '?':
                return [
                        ('Tube Size', 0),
                        ('Tube Width', 0),
                        ('Flatten', 0),
                ]
        dr = .666 * r
        if morph == 'Tube Size':
                dr = r
        if morph == 'Tube Width':
                tw = 1.5
        else:
                tw = 1
        if morph == 'Flatten':
                ys = .5
        else:
                ys = 1
        pl = PolyList()
        for i in xrange(3):
                pl << tube(i, dr, ys, tw).weld()
        return pl

Morphing(braid, 'Braid')

Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)