added path gen

This commit is contained in:
Dave Griffiths 2009-10-21 19:09:26 +01:00
parent 42e08f2b5b
commit 472aa339dc

View file

@ -0,0 +1,34 @@
;; p l a n t e y e s [ copyright (c) 2009 foam vzw : gpl v3 ]
#lang scheme/base
(require scheme/class
fluxus-016/fluxus)
(provide (all-defined-out))
(define path-gen%
(class object%
(init-field
(curve 20)
(corner 0)
(pos (vector 0 0 0))
(dir (vector 0 0 1)))
(field
(t 0)
(freq (+ (* (rndf) 4) 1))
(rot (vmul (hsrndvec) curve)))
(define/public (reset p d)
(set! pos p)
(set! dir d)
(set! t 0))
(define/public (get-pos dist)
(let ((r pos))
(let ((m (mrotate (vmul rot (if (zero? corner) 1 (max 0 (* corner (sin t))))))))
(set! dir (vmul (vnormalise (vtransform dir m)) dist)))
(set! pos (vadd pos dir))
(set! t (+ t freq))
r))
(super-new)))