added path gen
This commit is contained in:
parent
42e08f2b5b
commit
472aa339dc
1 changed files with 34 additions and 0 deletions
34
plant-eyes/scripts/path-gen.ss
Normal file
34
plant-eyes/scripts/path-gen.ss
Normal 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)))
|
Loading…
Reference in a new issue