34 lines
905 B
Scheme
34 lines
905 B
Scheme
;; 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)))
|